cd /srv/salt nginx
vim top.slsvim
base:
'server4.lalala.com':
- nginx.install
'server1.lalala.com':
- nginx.install
[root@server3 files]# pwd 服務器
/srv/salt/nginx/files less
[root@server3 files]# ls nide
ginx-1.10.1.tar.gzui
vim /srv/salt/nginx/install.slsspa
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
高級狀態的執行(多節點)orm
[root@server13 nginx]# salt '' state.highstate test=Trueserver
[root@server13 nginx]# salt '' state.highstaterabbitmq
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 請求響應