首页 > 代码库 > saltstack之多节点nginx安装配置
saltstack之多节点nginx安装配置
多节点nginx安装配置
定义多节点
cd /srv/salt
vim top.sls
base:
‘server4.lalala.com‘:
- nginx.install
‘server1.lalala.com‘:
- nginx.install
把要共享的文件放在指定目录
[root@server3 files]# pwd
/srv/salt/nginx/files
[root@server3 files]# ls n
ginx-1.10.1.tar.gz
vim /srv/salt/nginx/install.sls
nginx-install:
pkg.installed: #安装包的依赖性
- pkgs:
- gcc
- pcre-devel
- openssl-devel
file.managed:
- name: /mnt/nginx-1.10.1.tar.gz #安装在客户端的位置
- source: salt://nginx/files/nginx-1.10.1.tar.gz #服务器共享文件的位置
cmd.run:
- name: cd /mnt;tar zxf nginx-1.10.1.tar.gz;cd nginx-1.10.1;./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads &> /dev/null && make &> /dev/null && make install &> /dev/null
高级状态的执行(多节点)
[root@server13 nginx]# salt ‘‘ state.highstate test=True
[root@server13 nginx]# salt ‘‘ state.highstate
vim install.sls
include:
- pkg.install
- user.nginx
nginx-source:
file.managed:
- name: /mnt/nginx-1.10.1.tar.gz
- source: salt://nginx/files/nginx-1.10.1.tar.gz
nginx-install:
cmd.run:
- name: cd /mnt;tar zxf nginx-1.10.1.tar.gz;cd nginx-1.10.1;./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads &> /dev/null && make &> /dev/null && make install &> /dev/null
- creates: /usr/local/nginx
- require:
- pkg: pkg-install
- file: nginx-source
- user: nginx-user
vim service.sls
include:
- nginx.install
nginx-config:
file.managed:
- name: /usr/local/nginx/conf/nginx.conf
- source: salt://nginx/files/nginx.conf
nginx-init:
file.managed:
- name: /etc/init.d/nginx
- source: salt://nginx/files/nginx
- mode: 755
cmd.run:
- name: chkconfig --add nginx
- unless: chkconfig --list nginx #如果不存在,就执行以上语句
- require:
- file: nginx-init
service.running:
- name: nginx
- enable: True
- reload: True
- watch:
- file: nginx-config
需要推给客户端信息
[root@server13 files]# ls nginx nginx-1.10.1.tar.gz nginx.conf [root@server13 files]#
编辑启动脚本
vim nginx
36 nginx=${NGINX-/usr/local/nginx/sbin/nginx}
37 prog=`/bin/basename $nginx`
38 conffile=${CONFFILE-/usr/local/nginx/conf/nginx.conf}
39 lockfile=${LOCKFILE-/var/lock/subsys/nginx}
40 pidfile=${PIDFILE-/usr/local/nginx/logs/nginx.pid}
编辑主配置文件
vim nginx.conf
user nginx nginx;
listen 8000;
检测
[root@server3 files]# salt ‘*‘ state.sls nginx.service
可以看到,1,3主机 的8000端口,被打开被nginx占用
[root@server3 files]# lsof -i :4505 -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
salt-mast 2339 root 16u IPv4 14683 0t0 TCP *:4505 (LISTEN)
salt-mast 2339 root 18u IPv4 53804 0t0 TCP 172.25.88.3:4505->172.25.88.1:49253 (ESTABLISHED)
salt-mast 2339 root 19u IPv4 37637 0t0 TCP 172.25.88.3:4505->172.25.88.4:59132 (ESTABLISHED)
消息队列,长连接方式,一直保持established,不用请求和回复,所以快
kafka zeromq rabbitmq
req系统 4506 请求响应
本文出自 “12049878” 博客,谢绝转载!
saltstack之多节点nginx安装配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。