jgfh 发表于 2016-9-1 10:28:13

centOS 7 部署SaltStack

环境

IP地址角色系统环境
192.168.72.120masterCentOS 7
192.168.72.121minionCentOS 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
# 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/
#




解决方法:

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/source/i/ioflo/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/salt/releases/download/v2014.7.0/salt-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
# 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
#




SaltStack配置
(1)、master端

1
2
3
4
5
6
7
#mkdir /etc/salt
# cp -a conf/master /etc/salt/
# cp -a pkg/suse/salt-master /etc/init.d/
# chmod +x /etc/init.d/salt-master
# chkconfig --level 235 salt-master on
# mkdir -p /var/log/salt /srv/salt
#





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
完毕!
# 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
# ps aux | grep python
root       7180.02.2 324020 22812 ?      Ssl12:45   0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root      12940.01.8 553060 18220 ?      Ssl12:46   0:02 /usr/bin/python -Es /usr/sbin/tuned -l -P
root   454220.02.2 289988 22944 ?      S    16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root   454230.74.4 355560 44420 ?      S    16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454240.02.2 371916 22884 ?      Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root   454250.02.2 371916 22692 ?      Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root   454300.02.2 289988 22596 ?      S    16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root   454310.64.4 439916 44472 ?      Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454320.74.4 439912 44476 ?      Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454330.74.4 439912 44476 ?      Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454340.74.4 439920 44580 ?      Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454350.74.4 439648 44552 ?      Sl   16:37   0:02 /usr/bin/python /usr/bin/salt-master -d
root   454360.02.2 666844 22956 ?      Sl   16:37   0:00 /usr/bin/python /usr/bin/salt-master -d
root   459710.00.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
#ps aux | grep python
root       7200.12.3 324024 23580 ?      Ssl18:29   0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
root      12970.01.6 553072 16348 ?      Ssl18:29   0:00 /usr/bin/python -Es /usr/sbin/tuned -l -P
root      25210.92.8 374904 28436 ?      Sl   18:36   0:00 /usr/bin/python /usr/bin/salt-minion -d
root      25420.00.0 112664   976 pts/0    R+   18:36   0:00 grep --color=auto python
#




4、SaltStack简单使用
## 查看当前的salt key信息

1
2
3
4
5
# salt-key -L
Accepted Keys:
Unaccepted Keys:
Rejected Keys:
#





页: [1]
查看完整版本: centOS 7 部署SaltStack