环境
IP地址 | | | 192.168.72.120 | | | 192.168.72.121 | | |
========================================================================================== 安装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模块安装
markupsafe模块安装
jinja2模块安装
pyzmq模块安装
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
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
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
|
msgpack模块安装
1
| pip install msgpack-python
|
msgpack-pure模块安装
1
| pip install msgpack-python
|
pycrypto模块安装
requests模块安装
其他模块安装
注意:
以上模块为REAT通信模式所依赖的模块,作为可选项,非必要。
saltstack安装
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 ~]#
|
|