安装master端:
[root@vm01 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:28:16:11 inet addr:192.168.0.21 Bcast:192.168.1.255 Mask:255.255.254.0 inet6 addr: fe80::5054:ff:fe28:1611/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2648004 errors:0 dropped:0 overruns:0 frame:0 TX packets:21384 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:338622498 (322.9 MiB) TX bytes:1884671 (1.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:39 errors:0 dropped:0 overruns:0 frame:0 TX packets:39 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2694 (2.6 KiB) TX bytes:2694 (2.6 KiB) [root@vm01 ~]# yum install epel-release -y [root@vm01 ~]# yum install salt-master -y [root@vm01 ~]# salt-master --version salt-master 2015.5.8 (Lithium) [root@vm01 ~]# /etc/init.d/salt-master start Starting salt-master daemon: [ OK ] [root@vm01 ~]# ss -lnpt | grep 45 LISTEN 0 100 *:4505 *:* users:(("salt-master",4882,12)) LISTEN 0 100 *:4506 *:* users:(("salt-master",4902,20)) [root@vm01 ~]#
#启动salt-master端
====================================================================
安装minion端:
[root@vm02 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 52:54:00:20:B9:98 inet addr:192.168.0.22 Bcast:192.168.1.255 Mask:255.255.254.0 inet6 addr: fe80::5054:ff:fe20:b998/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2561616 errors:0 dropped:0 overruns:0 frame:0 TX packets:17514 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:328408944 (313.1 MiB) TX bytes:1569597 (1.4 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@vm02 ~]# yum install epel-release -y [root@vm02 ~]# yum install salt-minion -y [root@vm02 ~]# salt-minion --version salt-minion 2015.5.8 (Lithium) [root@vm02 ~]# sed -i ‘s@^#master:.*@master: 192.168.0.21@‘ /etc/salt/minion
#192.168.0.21是我master端的IP地址
[root@vm02 ~]# /etc/init.d/salt-minion start Starting salt-minion daemon: [ OK ] [root@vm02 ~]# ps -ef | grep salt-minion root 3983 1 0 15:59 ? 00:00:00 /usr/bin/python2.6 /usr/bin/salt-minion -d root 4139 3755 0 16:08 pts/0 00:00:00 grep salt-minion [root@vm02 ~]#
#启动salt-minion端
master端:
[root@vm01 ~]# salt-key -L Accepted Keys: Denied Keys: Unaccepted Keys: vm02 Rejected Keys: [root@vm01 ~]#
#出现了vm02的key
#salt-key常用的选项有
# -a -A -l -L -d -D -y
#接受vm02的key
[root@vm01 ~]# salt-key -a vm02 The following keys are going to be accepted: Unaccepted Keys: vm02 Proceed? [n/Y] y Key for minion vm02 accepted. [root@vm01 ~]# [root@vm01 ~]# salt "*" test.ping vm02: True [root@vm01 ~]# [root@vm01 ~]# salt "*" cmd.run "ifconfig" vm02: eth0 Link encap:Ethernet HWaddr 52:54:00:20:B9:98 inet addr:192.168.0.22 Bcast:192.168.1.255 Mask:255.255.254.0 inet6 addr: fe80::5054:ff:fe20:b998/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2654870 errors:0 dropped:0 overruns:0 frame:0 TX packets:18851 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:336733440 (321.1 MiB) TX bytes:1832351 (1.7 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@vm01 ~]#
#至此,你的salt已经安装成功!!
#更多的使用方法请查官网文档!!!!
本文出自 “逢场做戏。” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1763038
原文地址:http://xiaofengmo.blog.51cto.com/10116365/1763038