saltstack 入门

Saltstack是什么?

saltstack 是一个异构平台基础设施管理工具,具有远程执行、配置管理、云管理、只需花费数分钟就可以运行起来,扩展性足以支撑上万台服务器,速度快,服务器之间秒级通讯数秒钟即可完成数据传递。

Saltstack三大功能

  • 远程执行
  • 配置管理(状态)
  • 云管理

Saltstack四种运行方式

  local  本地运行

  minion/master 传统方式运行

  syndic   分布式

  salt SSH

Saltstack常用网址

saltstack官方网站

saltstack官方文档

Saltstack快速安装

实验环境

[root@salt0-master yum.repos.d]# uname -a   //内核参数
Linux salt0-master 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@salt0-master yum.repos.d]# hostname   //主机名
salt0-master
[root@salt0-master yum.repos.d]# hostname -I  //主机ip
10.0.0.51 172.16.1.51 
[root@salt0-master yum.repos.d]# cat /etc/redhat-release  //系统版本
CentOS Linux release 7.5.1804 (Core) 

  1、配置salt官方阿里云yum仓库

[root@salt0-master ~]# yum install -y  \
https://mirrors.aliyun.com/saltstack/yum/redhat/salt-repo-latest-2.el7.noarch.rpm

[root@salt0-master ~]# sed -i \
"s/repo.saltstack.com/mirrors.aliyun.com\/saltstack/g" /etc/yum.repos.d/salt-latest.repo
[root@salt0-master ~]# yum makecache

注:要确保主机名与文档一致  

配置完后,安装Matser,启动服务

[root@salt0-master ~]# yum install salt-master -y
[root@salt0-master ~]# systemctl enable salt-master
[root@salt0-master ~]# systemctl start salt-master

查看端口

[root@master yum.repos.d]# systemctl start salt-master
[root@master yum.repos.d]# netstat -lntup
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      938/sshd            
tcp        0      0 0.0.0.0:4505            0.0.0.0:*               LISTEN      1679/python         
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1022/master         
tcp        0      0 0.0.0.0:4506            0.0.0.0:*               LISTEN      1685/python         
tcp6       0      0 :::3307                 :::*                    LISTEN      933/mysqld          
tcp6       0      0 :::3308                 :::*                    LISTEN      934/mysqld          
tcp6       0      0 :::3309                 :::*                    LISTEN      936/mysqld          
tcp6       0      0 :::3310                 :::*                    LISTEN      940/mysqld          
tcp6       0      0 :::22                   :::*                    LISTEN      938/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1022/master         

  2、安装salt-minion指向salt-master 网络地址  

 新起一台机器,安装salt-minion

[root@salt1-minion ~]# yum install salt-minion -y

#配置master地址或主机名, 建议使用主机名方式
[root@salt1-minion ~]# sed -i '/master: /c\master: salt0-master' /etc/salt/minion
[root@salt1-minion ~]# systemctl enable salt-minion
[root@salt1-minion ~]# systemctl start salt-minion

  安装时出现的报错

Error: Package: salt-2018.3.3-1.el7.noarch (salt-latest)
           Requires: systemd-python
Error: Package: salt-master-2018.3.3-1.el7.noarch (salt-latest)
           Requires: systemd-python
Error: Package: python-urllib3-1.10.2-1.el7.noarch (salt-latest)
           Requires: python-backports-ssl_match_hostname
Error: Package: python-tornado-4.2.1-1.el7.x86_64 (salt-latest)
           Requires: python-backports-ssl_match_hostname
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

解决办法:

  查看本地的/ect/yum.repos.d/目录下是否有Base源,如果没有,去阿里云镜像网站,下载centos7系统的base源,安装完成即可解决。

安装完成salt-minion 查看 进程

[root@salt1-minion ~]# ps aux |  grep salt
root       1733  1.2  1.5 234856 15632 ?        Ss   09:51   0:00 /usr/bin/python /usr/bin/salt-minion
root       1736  4.1  2.6 530784 26416 ?        Sl   09:51   0:00 /usr/bin/python /usr/bin/salt-minion
root       1764  0.0  0.0 112704   968 pts/0    R+   09:51   0:00 grep --color=auto salt

  3、salt-master主机验证

[root@salt0-master yum.repos.d]# salt-key
Accepted Keys:
Denied Keys:
Unaccepted Keys:
salt1-minion
Rejected Keys:

猜你喜欢

转载自www.cnblogs.com/tim1blog/p/9987313.html