自动化运维

自动化运维介绍

saltstack安装

1.两台机器都做一下host,都安装saltstack yum源 https://repo.saltstack.com/#rhel

[root@centos-02 ~]# hostname
centos-02
[root@centos-02 ~]# vim /etc/hosts
[root@centos-02 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.133.88 centos02
192.168.133.66 centos03
[root@centos-02 ~]# 
[root@centos-03 ~]# hostname
centos-03
[root@centos-03 ~]# vim /etc/hosts
[root@centos-03 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.133.88 centos02
192.168.133.66 centos03

[root@centos-03 ~]# 
[root@centos-02 ~]# sudo yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm
[root@centos-03 ~]# sudo yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm

2.查看下yum源安装的包

[root@centos-02 ~]# yum list |grep salt

3.服务器安装两个包,客户端安装一个包

[root@centos-02 ~]# yum install -y salt-master salt-minion
[root@centos-03 ~]# yum install -y salt-minion

1.查看已安装的包

[root@centos-02 ~]# rpm -qa |grep salt
salt-master-2018.3.0-1.el7.noarch
salt-repo-latest-2.el7.noarch
salt-2018.3.0-1.el7.noarch
salt-minion-2018.3.0-1.el7.noarch
[root@centos-02 ~]# 

2.如果将那台机器作为控制中心就安装saltmaster,如果不是控制中心只安装一个saltminion就可以了

3.修改配置文件,将master前面的注释去掉,修改为自己的主机名 

[root@centos-02 ~]# vim /etc/salt/minion
[[root@centos-02 ~]# cat /etc/salt/minion|grep 'master: centos02'
master: centos02
[root@centos-02 ~]# 
[root@centos-03 ~]# vim /etc/salt/minion
[root@centos-03 ~]# cat /etc/salt/minion|grep 'centos02'
master: centos02
[root@centos-03 ~]# 

4.启动minion,minion是不监听端口的

[root@centos-03 ~]# systemctl start salt-minion
[root@centos-03 ~]# ps aux|grep salt
root       3523 32.5  2.1 313608 21292 ?        Ss   22:43   0:04 /usr/bin/python /usr/bin/salt-minion
root       3533 51.3  2.7 455036 27640 ?        Dl   22:43   0:03 /usr/bin/python /usr/bin/salt-minion
root       3541  0.3  2.0 410996 20064 ?        S    22:43   0:00 /usr/bin/python /usr/bin/salt-minion
root       3543  0.0  0.0 112664   932 pts/0    R+   22:43   0:00 grep --color=auto salt
[root@centos-03 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1365/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2155/master         
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      1212/zabbix_agentd  
tcp        0      0 192.168.133.66:27017    0.0.0.0:*               LISTEN      2276/mongod         
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      2276/mongod         
tcp6       0      0 :::3306                 :::*                    LISTEN      1591/mysqld         
tcp6       0      0 :::22                   :::*                    LISTEN      1365/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2155/master         
tcp6       0      0 :::10050                :::*                    LISTEN      1212/zabbix_agentd  
[root@centos-03 ~]# 

5.启动marster(如果启动失败解决方案:sudo pip install --upgrade psutil

[root@centos-02 ~]# systemctl start salt-minion
[root@centos-02 ~]# 
[root@centos-02 ~]# systemctl start salt-master
[root@centos-02 ~]# ps aux|grep salt
root       3838  6.5  4.1 396068 41556 ?        Ss   23:15   0:03 /usr/bin/python /usr/bin/salt-master
root       3847  0.0  2.0 314108 20896 ?        S    23:15   0:00 /usr/bin/python /usr/bin/salt-master
root       3852  0.3  3.5 476912 35224 ?        Sl   23:15   0:00 /usr/bin/python /usr/bin/salt-master
root       3855  0.0  3.4 394984 34744 ?        S    23:15   0:00 /usr/bin/python /usr/bin/salt-master
root       3856  4.8  3.9 405652 39740 ?        S    23:15   0:02 /usr/bin/python /usr/bin/salt-master
root       3857  2.2  3.5 396068 35488 ?        S    23:15   0:01 /usr/bin/python /usr/bin/salt-master
root       3858  0.2  3.5 576316 35972 ?        Sl   23:15   0:00 /usr/bin/python /usr/bin/salt-master
root       3865 13.5  4.1 402888 41708 ?        S    23:15   0:06 /usr/bin/python /usr/bin/salt-master
root       3866  1.3  3.5 469800 35764 ?        Sl   23:15   0:00 /usr/bin/python /usr/bin/salt-master
root       3868 12.5  4.1 401372 41268 ?        R    23:15   0:05 /usr/bin/python /usr/bin/salt-master
root       3869 12.1  4.1 401380 41448 ?        R    23:15   0:05 /usr/bin/python /usr/bin/salt-master
root       3870 12.3  4.1 401376 41460 ?        R    23:15   0:05 /usr/bin/python /usr/bin/salt-master
root       3872 12.6  4.1 401508 41544 ?        R    23:15   0:05 /usr/bin/python /usr/bin/salt-master
root       3895  3.0  0.0 112664   936 pts/0    R+   23:16   0:00 grep --color=auto salt
root       3896  0.0  4.0 401760 40456 ?        R    23:16   0:00 /usr/bin/python /usr/bin/salt-master
[root@centos-02 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1041/sshd           
tcp        0      0 0.0.0.0:4505            0.0.0.0:*               LISTEN      3852/python         
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1867/master         
tcp        0      0 0.0.0.0:4506            0.0.0.0:*               LISTEN      3858/python         
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      1406/zabbix_server  
tcp        0      0 192.168.133.88:27017    0.0.0.0:*               LISTEN      2147/mongod         
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      2147/mongod         
tcp6       0      0 :::3306                 :::*                    LISTEN      1394/mysqld         
tcp6       0      0 :::80                   :::*                    LISTEN      743/httpd           
tcp6       0      0 :::22                   :::*                    LISTEN      1041/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1867/master         
tcp6       0      0 :::10051                :::*                    LISTEN      1406/zabbix_server  
[root@centos-02 ~]# 

saltstack配置认证

1.

  

  

  

  

猜你喜欢

转载自www.cnblogs.com/sunyujun/p/9080559.html