环境
IP地址 |
角色 |
系统环境 |
192.168.72.120 |
master |
CentOS 7 |
192.168.72.121 |
minion |
CentOS 7 |
==========================================================================================
安装pip
首先安装epel扩展源: sudo yum -y install epel-release 然后安装python-pip sudo yum -y install python-pip 安装完之后别忘了清除一下cache sudo yum clean all
PyYAML模块安装
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
报错:
[[email protected] 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/ [[email protected] yaml-0.1.5]#
解决方法:
yum install python-devel
setuptools模块安装
pip install setuptools
markupsafe模块安装
pip install markupsafe
jinja2模块安装
pip install jinja2
pyzmq模块安装
pip install pyzmq
autoconf安装
yum install autoconf
## 其他依赖库安装
# 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
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
./autogen.sh 报错: Can‘t exec "aclocal": 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 326. autoreconf: failed to run aclocal: 没有那个文件或目录
解决方法:
yum install automake
报错: 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
安装zeromq
# 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模块安装
yum -y install swig.x86_64 yum -y install openssl yum -y install openssl-devel
pip install M2Crypto
msgpack模块安装
pip install msgpack-python
msgpack-pure模块安装
pip install msgpack-python
pycrypto模块安装
pip install pycrypto
requests模块安装
pip install requests
其他模块安装
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安装
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
[[email protected] 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 [[email protected] salt-2014.7.0]#
SaltStack配置
(1)、master端
[[email protected] salt-2014.7.0]# mkdir /etc/salt [[email protected] salt-2014.7.0]# cp -a conf/master /etc/salt/ [[email protected] salt-2014.7.0]# cp -a pkg/suse/salt-master /etc/init.d/ [[email protected] salt-2014.7.0]# chmod +x /etc/init.d/salt-master [[email protected] salt-2014.7.0]# chkconfig --level 235 salt-master on [[email protected] salt-2014.7.0]# mkdir -p /var/log/salt /srv/salt [[email protected] salt-2014.7.0]#
# vim /etc/salt/master interface: 192.168.72.120 auto_accept: True
# ln -s /usr/local/bin/salt-master /usr/bin/ # service salt-master start
完毕! [[email protected] 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))
[[email protected] 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端
# 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
# mkdir -p /var/log/salt
# vim /etc/salt/minion
master: 192.168.72.120
id: minion192.168.72.121
# ln -s /usr/local/bin/salt-minion /usr/bin/ # service salt-minion start
[[email protected] ~]# 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 [[email protected] ~]#
4、SaltStack简单使用
## 查看当前的salt key信息
[[email protected] ~]# salt-key -L Accepted Keys: Unaccepted Keys: Rejected Keys: [[email protected] ~]#
时间: 2024-10-14 04:35:33