设为首页 收藏本站
查看: 838|回复: 0

[经验分享] centOS 7 部署SaltStack

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-1 10:28:13 | 显示全部楼层 |阅读模式
环境
IP地址
角色
系统环境
192.168.72.120
master
CentOS 7
192.168.72.121
minion
CentOS 7

==========================================================================================

安装pip
1
2
3
4
5
6
首先安装epel扩展源:
sudo yum -y install epel-release
然后安装python-pip
sudo yum -y install python-pip
安装完之后别忘了清除一下cache
sudo yum clean all




PyYAML模块安装


1
2
3
4
5
6
7
8
wget
# tar xvzf yaml-0.1.5.tar.gz
# cd yaml-0.1.5
# ./configure --prefix=/usr/local
# make --jobs=`grep processor /proc/cpuinfo | wc -l`
# make install

pip install PyYAML



报错:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[iyunv@localhost yaml-0.1.5]# pip install pyyaml
Collecting pyyaml
  Using cached PyYAML-3.12.tar.gz
Installing collected packages: pyyaml
  Running setup.py install for pyyaml ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_ljXXW/pyyamltup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3DSGFN-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating buildb.linux-x86_64-2.7
    creating buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/error.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/__init__.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/dumper.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/resolver.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/scanner.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/events.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/emitter.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yamlrializer.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/representer.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/constructor.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yamlaml.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/reader.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/parser.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/loader.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yamldes.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/composer.py -> buildb.linux-x86_64-2.7/yaml
    copying lib/yaml/tokens.py -> buildb.linux-x86_64-2.7/yaml
    running build_ext
    creating build/temp.linux-x86_64-2.7
    checking if libyaml is compilable
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7eck_libyaml.c -o build/temp.linux-x86_64-2.7eck_libyaml.o
    checking if libyaml is linkable
    gcc -pthread build/temp.linux-x86_64-2.7eck_libyaml.o -L/usrb64 -lyaml -o build/temp.linux-x86_64-2.7eck_libyaml
    building '_yaml' extension
    creating build/temp.linux-x86_64-2.7/ext
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
    ext/_yaml.c:4:20: 致命错误:Python.h:没有那个文件或目录
     #include "Python.h"
                        ^
    编译中断。
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_ljXXW/pyyamltup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3DSGFN-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_ljXXW/pyyaml/
[iyunv@localhost yaml-0.1.5]#



解决方法:
1
yum install python-devel




setuptools模块安装
1
pip install setuptools



markupsafe模块安装
1
pip install markupsafe



jinja2模块安装
1
pip install jinja2



pyzmq模块安装
1
pip install pyzmq



autoconf安装
1
yum install autoconf



## 其他依赖库安装

1
2
3
# yum -y install libuuid.x86_64 libuuid-devel.x86_64
# yum -y install uuid.x86_64 uuid-devel.x86_64
# yum -y install uuid-c++.x86_64 uuid-c++-devel.x86_64



1
2
3
4
5
6
7
wget
# tar xvzf libsodium-1.0.1.tar.gz
# cd libsodium-1.0.1
# ./autogen.sh
# ./configure --prefix=/usr/local
# make --jobs=`grep processor /proc/cpuinfo | wc -l`
# make install




1
2
3
./autogen.sh 报错:
Can't exec "aclocal": 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: 没有那个文件或目录



解决方法:
1
yum install automake



1
2
3
4
5
6
7
报错:
configure.ac:418: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
解决方法:
yum install libtool



1
安装zeromq



1
2
3
4
5
6
# tar xvzf zeromq-4.0.5.tar.gz
# cd zeromq-4.0.5
# ./autogen.sh
# ./configure --prefix=/usr/local
# make --jobs=`grep processor /proc/cpuinfo | wc -l`
# make install



M2Crypto模块安装
1
2
3
yum -y install swig.x86_64
yum -y install openssl
yum -y install openssl-devel



1
pip install M2Crypto



msgpack模块安装
1
pip install msgpack-python



msgpack-pure模块安装
1
pip install msgpack-python



pycrypto模块安装
1
pip install pycrypto



requests模块安装
1
pip install requests




其他模块安装
1
2
3
4
5
https://pypi.python.org/packages/source/l/libnacl/libnacl-1.3.5.tar.gz
https://pypi.python.org/packages ... /ioflo-1.0.2.tar.gz
https://pypi.python.org/packages/source/s/six/six-1.8.0.tar.gz
https://pypi.python.org/packages/source/r/raet/raet-0.4.2.tar.gz
https://pypi.python.org/packages/source/M/Mako/Mako-1.0.0.tar.gz



注意:
以上模块为REAT通信模式所依赖的模块,作为可选项,非必要。
saltstack安装
1
2
3
4
wget https://github.com/saltstack/sal ... alt-2014.7.0.tar.gz
# tar xvzf salt-2014.7.0.tar.gz
# cd salt-2014.7.0
# python setup.py install



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@localhost salt-2014.7.0]# salt --versions-report
           Salt: 2014.7.0
         Python: 2.7.5 (default, Aug 18 2016, 15:58:25)
         Jinja2: 2.8
       M2Crypto: 0.25.1
msgpack-python: 0.4.8
   msgpack-pure: 0.1.3
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.12
          ioflo: Not Installed
          PyZMQ: 15.4.0
           RAET: Not Installed
            ZMQ: 4.1.5
           Mako: Not Installed
[iyunv@localhost salt-2014.7.0]#



SaltStack配置
(1)、master端
1
2
3
4
5
6
7
[iyunv@localhost salt-2014.7.0]#  mkdir /etc/salt
[iyunv@localhost salt-2014.7.0]# cp -a conf/master /etc/salt/
[iyunv@localhost salt-2014.7.0]# cp -a pkg/suse/salt-master /etc/init.d/
[iyunv@localhost salt-2014.7.0]# chmod +x /etc/init.d/salt-master
[iyunv@localhost salt-2014.7.0]# chkconfig --level 235 salt-master on
[iyunv@localhost salt-2014.7.0]# mkdir -p /var/log/salt /srv/salt
[iyunv@localhost salt-2014.7.0]#



1
2
3
# vim /etc/salt/master
interface: 192.168.72.120
auto_accept: True



1
2
# ln -s /usr/local/bin/salt-master /usr/bin/
# service salt-master start



1
2
3
4
5
6
7
8
9
完毕!
[iyunv@localhost Packages]# ss -ntlp
State       Recv-Q Send-Q                 Local Address:Port                                Peer Address:Port              
LISTEN      0      128                                *:22                                             *:*                   users:(("sshd",pid=1296,fd=3))
LISTEN      0      100                   192.168.72.120:4505                                           *:*                   users:(("salt-master",pid=45424,fd=18))
LISTEN      0      100                        127.0.0.1:25                                             *:*                   users:(("master",pid=1998,fd=13))
LISTEN      0      100                   192.168.72.120:4506                                           *:*                   users:(("salt-master",pid=45436,fd=30))
LISTEN      0      128                               :::22                                            :::*                   users:(("sshd",pid=1296,fd=4))
LISTEN      0      100                              ::1:25                                            :::*                   users:(("master",pid=1998,fd=14))



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@localhost Packages]# ps aux | grep python
root       718  0.0  2.2 324020 22812 ?        Ssl  12:45   0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root      1294  0.0  1.8 553060 18220 ?        Ssl  12:46   0:02 /usr/bin/python -Es /usr/sbin/tuned -l -P
root     45422  0.0  2.2 289988 22944 ?        S    16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root     45423  0.7  4.4 355560 44420 ?        S    16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45424  0.0  2.2 371916 22884 ?        Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root     45425  0.0  2.2 371916 22692 ?        Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root     45430  0.0  2.2 289988 22596 ?        S    16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root     45431  0.6  4.4 439916 44472 ?        Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45432  0.7  4.4 439912 44476 ?        Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45433  0.7  4.4 439912 44476 ?        Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45434  0.7  4.4 439920 44580 ?        Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45435  0.7  4.4 439648 44552 ?        Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root     45436  0.0  2.2 666844 22956 ?        Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root     45971  0.0  0.0 112664   976 pts/0    R+   16:42   0:00 grep --color=auto python




(2)、minion端

1
2
3
4
5
# mkdir /etc/salt
# cp -a conf/minion /etc/salt/
# cp -a pkg/suse/salt-minion /etc/init.d/
# chmod +x /etc/init.d/salt-minion
# chkconfig --level 235 salt-minion on





1
# mkdir -p /var/log/salt





# vim /etc/salt/minion
master: 192.168.72.120
id: minion192.168.72.121


1
2
# ln -s /usr/local/bin/salt-minion /usr/bin/
# service salt-minion start



1
2
3
4
5
6
[iyunv@minion192 ~]#  ps aux | grep python
root       720  0.1  2.3 324024 23580 ?        Ssl  18:29   0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root      1297  0.0  1.6 553072 16348 ?        Ssl  18:29   0:00 /usr/bin/python -Es /usr/sbin/tuned -l -P
root      2521  0.9  2.8 374904 28436 ?        Sl   18:36   0:00 /usr/bin/python /usr/bin/salt-minion -d
root      2542  0.0  0.0 112664   976 pts/0    R+   18:36   0:00 grep --color=auto python
[iyunv@minion192 ~]#



4、SaltStack简单使用
## 查看当前的salt key信息
1
2
3
4
5
[iyunv@minion192 ~]# salt-key -L
Accepted Keys:
Unaccepted Keys:
Rejected Keys:
[iyunv@minion192 ~]#





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-266076-1-1.html 上篇帖子: 部署自动化运维工具SaltStack 下篇帖子: centOS 6.5 部署SaltStack
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表