1:操作系统环境
root@iZ23f6c5z8tZ:~# lsb_release -a No LSB modules are available. Distributor ID:Ubuntu Description:Ubuntu 14.04.2 LTS Release:14.04 Codename:trusty root@iZ23f6c5z8tZ:/etc/apt# uname -m x86_64 root@iZ23f6c5z8tZ:/etc/apt# uname -r 3.13.0-32-generic 注:机器操作系统均为ubuntu14.04 64bit
角色
192.168.1.10 salt-master 192.168.1.11 salt-minion-node1
2:安装salt-master
更新 root@iZ23f6c5z8tZ:~# apt-get update
root@iZ23f6c5z8tZ:~# apt-get install software-properties-common 注意从Ubuntu 12.10(Raring Ringtail)开始, add-apt-repository 在作为一部分包含在 software-properties-common 包里。
安装salt-master root@iZ23f6c5z8tZ:~# apt-get install salt-master -y
查看salt-master程序
root@iZ23f6c5z8tZ:~# ps -ef|grep salt root 4452 1 0 16:46 ? 00:00:02 /usr/bin/python /usr/bin/salt-master root 4461 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4468 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4469 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4470 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4471 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4476 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4477 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4478 4452 0 16:46 ? 00:00:00 /usr/bin/python /usr/bin/salt-master root 4816 1376 0 17:04 pts/1 00:00:00 grep --color=auto salt
master启动后默认监听4505和4506两个端口。4505(publish_port)为salt的消息发布系统,4506(ret_port)为salt客户端与服务端通信的端口。
root@iZ23f6c5z8tZ:~# netstat -ntpl|grep python tcp 0 0 0.0.0.0:4505 0.0.0.0:* LISTEN 4468/python tcp 0 0 0.0.0.0:4506 0.0.0.0:* LISTEN 4452/python
salt-master配置文件
root@iZ23f6c5z8tZ:/etc/salt# pwd /etc/salt root@iZ23f6c5z8tZ:/etc/salt# ls master master.bak master.d pki root@iZ23f6c5z8tZ:/etc/salt# grep '^[a-Z]' /etc/salt/master interface: 121.40.139.41 //监听IP
重启salt-master
root@iZ23f6c5z8tZ:/etc/salt# service salt-master restart salt-master stop/waiting salt-master start/running, process 5009
4:安装salt-minion
root@iZ2803zsab7Z:~# apt-get update root@iZ2803zsab7Z:~# apt-get install salt-minion -y
salt-minion状态
root@iZ2803zsab7Z:~# service salt-minion status salt-minion start/running, process 4305
salt-minion配置文件
root@iZ2803zsab7Z:/etc/salt# pwd /etc/salt root@iZ2803zsab7Z:/etc/salt# ls minion minion.bak minion.d minion_id pki root@iZ2803zsab7Z:/etc/salt# grep '^[a-z]' minion master: 121.40.139.41//连接master端IP地址 注:id是客户端主机名(其实也就是认证key的名字)用来和master进行认证,如果没有更改的话。会找minion主机名作为
以上就是salt的master和minion安装
root@iZ23f6c5z8tZ:~# salt-key -L//查看minion列表 Accepted Keys: Unaccepted Keys: iZ2803zsab7Z Rejected Keys:
root@iZ23f6c5z8tZ:~# salt-key -A//接受所有key,在提示中提示y确认即可.接下来便可以向minion发送命令了,-a 指定单个 The following keys are going to be accepted: Unaccepted Keys: iZ2803zsab7Z Proceed? [n/Y] y Key for minion iZ2803zsab7Z accepted.
root@iZ23f6c5z8tZ:~# salt '*' test.ping iZ2803zsab7Z: True
本文出自 “村里的男孩” 博客,转载请与作者联系!