码迷,mamicode.com
首页 > 其他好文 > 详细

SaltStack(一)-- SaltStack介绍及CentOS 6.7安装SaltStack

时间:2015-11-29 06:59:37      阅读:800      评论:0      收藏:0      [点我收藏+]

标签:linux   saltstack   

一、SaltStack介绍

    SaltStack是一个开源Apache 2.0 license的基于Python开发的配置管理系统及分布式远程执行工具。

    Salt有local、Master/Minion、Salt SSH三种工作模式可以适用不同的使用环境。通常采用master/minion模式这种模式扩展方便部署灵活支持单IDC部署及跨IDC部署单个Master最好管理小于1000台minion可以采用Sydnic进行扩展。

    Salt采用ZeroMQ保证命令发送到远程系统是并行而非串行。使用公钥和Master进行认证使用AES加密通信流量Salt中加密和认证机制是必不可少的通信更加安全。使用msgpack进行通信具有更高的效率产生更少的网络流量。

    Salt可以稳定的运行在RHEL/CentOS/Ubuntu/FreeBSD/Oracle Linux/Amazon Linux等系统上。另外windows不支持salt master但是支持salt minion的安装及运行。

    本文在CentOS  6.7  2.6.32-573.el6.x86_64下安装及测试。Salt版本为2015.5.5 (Lithium)。另安装可以参考官网链接https://docs.saltstack.com/en/latest/topics/installation/index.html



二、SaltStack安装

1、公共仓库安装(SaltStack 2015.5.5)

    1)说明

    从0.9.4版本开始支持EPEL源安装

    官方文档说使用EPEL仓库安装会有各种依赖问题需要解决目前使用阿里云的yum仓库安装没有出现问题。


    官方文档提到的问题主要有

        a最新版的SaltStack不会及时在EPEL中更新

        bpython-jinja2从EPEL移至"RHEL Server Optional Channel"

        cSaltStack 2015.8需要python-crypto(2.6.1及以上)和python-tornado4.2.1及以上但是Redhat5和6的EPEL中没有

        4、需要启用EPEL仓库


    2)使用yum安装master

[root@centos67 yum.repos.d]# yum install -y salt-master
已加载插件fastestmirror, security
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                             | 3.7 kB     00:00     
epel                                                                                                                                                             | 4.3 kB     00:00     
extras                                                                                                                                                           | 3.4 kB     00:00     
updates                                                                                                                                                          | 3.4 kB     00:00     
解决依赖关系
--> 执行事务检查
.......

依赖关系解决

========================================================================================================================================================================================
 软件包                                                        架构                             版本                                             仓库                              大小
========================================================================================================================================================================================
正在安装:
 salt-master                                                   noarch                           2015.5.5-1.el6                                   epel                             989 k
为依赖而安装:
 PyYAML                                                        x86_64                           3.10-3.1.el6                                     base                             157 k
 libyaml                                                       x86_64                           0.1.3-4.el6_6                                    base                              52 k
 m2crypto                                                      x86_64                           0.20.2-9.el6                                     base                             471 k
 openpgm                                                       x86_64                           5.1.118-3.el6                                    epel                             165 k
 python-babel                                                  noarch                           0.9.4-5.1.el6                                    base                             1.4 M
 python-backports                                              x86_64                           1.0-5.el6                                        base                             5.5 k
 python-backports-ssl_match_hostname                           noarch                           3.4.0.2-4.el6.centos                             extras                            13 k
 python-chardet                                                noarch                           2.2.1-1.el6                                      base                             230 k
 python-jinja2                                                 x86_64                           2.2.1-2.el6_5                                    base                             466 k
 python-msgpack                                                x86_64                           0.4.6-1.el6                                      epel                              69 k
 python-requests                                               noarch                           2.6.0-3.el6                                      base                              95 k
 python-six                                                    noarch                           1.9.0-2.el6                                      base                              28 k
 python-urllib3                                                noarch                           1.10.2-1.el6                                     base                             101 k
 python-zmq                                                    x86_64                           14.3.1-1.el6                                     epel                             467 k
 salt                                                          noarch                           2015.5.5-1.el6                                   epel                             4.2 M
 zeromq3                                                       x86_64                           3.2.5-1.el6                                      epel                             338 k

事务概要
========================================================================================================================================================================================
Install      17 Package(s)


    3)使用yum安装minion

[root@centos67 yum.repos.d]# yum install -y salt-minion
......


    4)设置开机启动及运行

#设置开机启动
[root@centos67 yum.repos.d]# chkconfig --level 2345 salt-master on
[root@centos67 yum.repos.d]# chkconfig --level 2345 salt-minion on


#检查设置
[root@centos67 yum.repos.d]# chkconfig --list |grep salt
salt-master     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
salt-minion     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭


#启动master
[root@centos67 yum.repos.d]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [确定]


#启动minion
[root@centos67 yum.repos.d]# /etc/init.d/salt-minion start
Starting salt-minion daemon:                               [确定]



2、SaltStack仓库安装(官方推荐可惜仓库访问不了大家都懂的.....SaltStack 2015.8.1)

    从2015.8.0版本后Salt在RHEL5、6、7上的安装可以使用SaltStack仓库。

    1)下载并安装SaltStack仓库的公钥并导入

#下载公钥
[root@centos67 ~]# wget https://repo.saltstack.com/yum/rhel6/SALTSTACK-GPG-KEY.pub   
--2015-11-15 21:28:00--  https://repo.saltstack.com/yum/rhel6/SALTSTACK-GPG-KEY.pub
正在解析主机 repo.saltstack.com... 198.199.77.106
正在连接 repo.saltstack.com|198.199.77.106|:443... 已连接。
已发出 HTTP 请求正在等待回应... 200 OK
长度1744 (1.7K)
正在保存至: “SALTSTACK-GPG-KEY.pub”
100%[==================================================================================================================>] 1,744       --.-K/s   in 0s      
2015-11-15 21:28:12 (244 MB/s) - 已保存 “SALTSTACK-GPG-KEY.pub” [1744/1744])


[root@centos67 ~]# rpm --import SALTSTACK-GPG-KEY.pub 


#查看本机安装的公钥
[root@centos67 ~]# rpm -qa gpg-pubkey*   
gpg-pubkey-de57bfbe-53a9be98
gpg-pubkey-c105b9de-4e0fd3a3


#查看公钥信息
[root@centos67 ~]# rpm -qi gpg-pubkey-de57bfbe-53a9be98    
Name        : gpg-pubkey                   Relocations: (not relocatable)
Version     : de57bfbe                          Vendor: (none)
Release     : 53a9be98                      Build Date: 2015年11月15日 星期日 21时29分18秒
Install Date: 2015年11月15日 星期日 21时29分18秒      Build Host: localhost
Group       : Public Keys                   Source RPM: (none)
Size        : 0                                License: pubkey
Signature   : (none)
Summary     : gpg(SaltStack Packaging Team <packaging@saltstack.com>)
Description :
-----BEGIN PGP PUBLIC KEY BLOCK-----


#删除公钥
[root@centos67 ~]# rm -f SALTSTACK-GPG-KEY.pub


    2)编辑SaltStack yum仓库配置文件/etc/yum.repos.d/saltstack.repo添加如下信息

[root@centos67 ~]# vim /etc/yum.repos.d/saltstack.repo
####################
# Enable SaltStack‘s package repository
[saltstack-repo]
name=SaltStack repo for RHEL/CentOS 6
baseurl=https://repo.saltstack.com/yum/rhel6
enabled=1
gpgcheck=1
gpgkey=https://repo.saltstack.com/yum/rhel6/SALTSTACK-GPG-KEY.pub

    

    3运行yum clean expire-cache刷新yum仓库缓存

[root@centos67 ~]# yum clean expire-cache
已加载插件fastestmirror, security
Cleaning repos: base epel extras saltstack-repo updates

    

    4)在需要安装master的机器安装master

[root@centos67 ~]# yum install -y salt-master
已加载插件fastestmirror, security
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
解决依赖关系
--> 执行事务检查
---> Package salt-master.noarch 0:2015.8.1-1.el6 will be 安装
--> 处理依赖关系 salt = 2015.8.1-1.el6它被软件包 salt-master-2015.8.1-1.el6.noarch 需要
--> 执行事务检查
..............
--> 完成依赖关系计算
依赖关系解决
========================================================================================================================================================================================
 软件包                                                      架构                           版本                                           仓库                                    大小
========================================================================================================================================================================================
正在安装:
 salt-master                                                 noarch                         2015.8.1-1.el6                                 saltstack-repo                         1.2 M
为依赖而安装:
 PyYAML                                                      x86_64                         3.11-1.el6                                     saltstack-repo                         152 k
 libyaml                                                     x86_64                         0.1.3-4.el6_6                                  base                                    52 k
 python-babel                                                noarch                         0.9.4-5.1.el6                                  base                                   1.4 M
 python-backports                                            x86_64                         1.0-5.el6                                      base                                   5.5 k
 python-backports-ssl_match_hostname                         noarch                         3.4.0.2-4.el6.centos                           extras                                  13 k
 python-chardet                                              noarch                         2.2.1-1.el6                                    base                                   230 k
 python-futures                                              noarch                         3.0.3-1.el6                                    saltstack-repo                          26 k
 python-jinja2                                               x86_64                         2.2.1-2.el6_5                                  base                                   466 k
 python-markupsafe                                           x86_64                         0.11-10.el6                                    saltstack-repo                          24 k
 python-msgpack                                              x86_64                         0.4.6-1.el6                                    epel                                    69 k
 python-requests                                             noarch                         2.6.0-3.el6                                    base                                    95 k
 python-six                                                  noarch                         1.9.0-2.el6                                    base                                    28 k
 python-tornado                                              x86_64                         4.2.1-1.el6                                    saltstack-repo                         661 k
 python-urllib3                                              noarch                         1.10.2-1.el6                                   base                                   101 k
 python-zmq                                                  x86_64                         14.5.0-2.el6                                   saltstack-repo                         479 k
 salt                                                        noarch                         2015.8.1-1.el6                                 saltstack-repo                         5.1 M
 zeromq                                                      x86_64                         4.0.5-1.el6                                    saltstack-repo                         568 k
 python-crypto                                               x86_64                         2.6.1-2.el6                                    saltstack-repo                         501 k
事务概要
========================================================================================================================================================================================
Install      18 Package(s)


    5)在需要安装minion的机器安装minion

[root@centos67 ~]# yum install salt-minion
.......


    6)设置开机启动及运行

#设置开机启动
[root@centos67 yum.repos.d]# chkconfig --level 2345 salt-master on
[root@centos67 yum.repos.d]# chkconfig --level 2345 salt-minion on


#检查设置
[root@centos67 yum.repos.d]# chkconfig --list |grep salt
salt-master     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
salt-minion     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭


#启动master
[root@centos67 yum.repos.d]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [确定]


#启动minion
[root@centos67 yum.repos.d]# /etc/init.d/salt-minion start
Starting salt-minion daemon:                               [确定]


4、pip安装&源码安装

不推荐这两种方法安装并没有什么本质的提升而且安装麻烦



本文出自 “王潇苒” 博客,请务必保留此出处http://wangxiaoran85.blog.51cto.com/8199070/1717620

SaltStack(一)-- SaltStack介绍及CentOS 6.7安装SaltStack

标签:linux   saltstack   

原文地址:http://wangxiaoran85.blog.51cto.com/8199070/1717620

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!