环境
IP地址 |
角色 | 系统环境 |
192.168.72.120 |
master |
CentOS 7 |
192.168.72.121 |
minion |
CentOS 7 |
==========================================================================================
安装pip
首先安装epel扩展源: sudoyum-yinstallepel-release 然后安装python-pip sudoyum-yinstallpython-pip 安装完之后别忘了清除一下cache sudoyumcleanall
PyYAML模块安装
wget #tarxvzfyaml-0.1.5.tar.gz #cdyaml-0.1.5 #./configure--prefix=/usr/local #make--jobs=`grepprocessor/proc/cpuinfo|wc-l` #makeinstall pipinstallPyYAML
报错:
[root@localhostyaml-0.1.5]#pipinstallpyyaml Collectingpyyaml UsingcachedPyYAML-3.12.tar.gz Installingcollectedpackages:pyyaml Runningsetup.pyinstallforpyyaml...error Completeoutputfromcommand/usr/bin/python-u-c"importsetuptools,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: runninginstall runningbuild runningbuild_py creatingbuild creatingbuildb.linux-x86_64-2.7 creatingbuildb.linux-x86_64-2.7/yaml copyinglib/yaml/error.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/__init__.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/dumper.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/resolver.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/scanner.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/events.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/emitter.py->buildb.linux-x86_64-2.7/yaml copyinglib/yamlrializer.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/representer.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/constructor.py->buildb.linux-x86_64-2.7/yaml copyinglib/yamlaml.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/reader.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/parser.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/loader.py->buildb.linux-x86_64-2.7/yaml copyinglib/yamldes.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/composer.py->buildb.linux-x86_64-2.7/yaml copyinglib/yaml/tokens.py->buildb.linux-x86_64-2.7/yaml runningbuild_ext creatingbuild/temp.linux-x86_64-2.7 checkingiflibyamliscompilable 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-cbuild/temp.linux-x86_64-2.7eck_libyaml.c-obuild/temp.linux-x86_64-2.7eck_libyaml.o checkingiflibyamlislinkable gcc-pthreadbuild/temp.linux-x86_64-2.7eck_libyaml.o-L/usrb64-lyaml-obuild/temp.linux-x86_64-2.7eck_libyaml building'_yaml'extension creatingbuild/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-fPIC-I/usr/include/python2.7-cext/_yaml.c-obuild/temp.linux-x86_64-2.7/ext/_yaml.o ext/_yaml.c:4:20:致命错误:Python.h:没有那个文件或目录 #include"Python.h" ^ 编译中断。 error:command'gcc'Failedwithexitstatus1 ---------------------------------------- Command"/usr/bin/python-u-c"importsetuptools,'exec'))"install--record/tmp/pip-3DSGFN-record/install-record.txt--single-version-externally-managed--compile"Failedwitherrorcode1in/tmp/pip-build-_ljXXW/pyyaml/ [root@localhostyaml-0.1.5]#
解决方法:
yuminstallpython-devel
setuptools模块安装
pipinstallsetuptools
markupsafe模块安装
pipinstallmarkupsafe
jinja2模块安装
pipinstalljinja2
pyzmq模块安装
pipinstallpyzmq
autoconf安装
yuminstallautoconf
## 其他依赖库安装
#yum-yinstalllibuuid.x86_64libuuid-devel.x86_64 #yum-yinstalluuid.x86_64uuid-devel.x86_64 #yum-yinstalluuid-c++.x86_64uuid-c++-devel.x86_64
wget #tarxvzflibsodium-1.0.1.tar.gz #cdlibsodium-1.0.1 #./autogen.sh #./configure--prefix=/usr/local #make--jobs=`grepprocessor/proc/cpuinfo|wc-l` #makeinstall
./autogen.sh报错: Can'texec"aclocal":没有那个文件或目录at/usr/share/autoconf/Autom4te/FileUtils.pmline326. autoreconf:Failedtorunaclocal:没有那个文件或目录
解决方法:
yuminstallautomake
报错: configure.ac:418:error:possiblyundefinedmacro:AC_LIBTOOL_WIN32_DLL Ifthistokenandothersarelegitimate,pleaseusem4_pattern_allow. SeetheAutoconfdocumentation. autoreconf:/usr/bin/autoconfFailedwithexitstatus:1 解决方法: yuminstalllibtool
安装zeromq
#tarxvzfzeromq-4.0.5.tar.gz #cdzeromq-4.0.5 #./autogen.sh #./configure--prefix=/usr/local #make--jobs=`grepprocessor/proc/cpuinfo|wc-l` #makeinstall
M2Crypto模块安装
yum-yinstallswig.x86_64 yum-yinstallopenssl yum-yinstallopenssl-devel
pipinstallM2Crypto
msgpack模块安装
pipinstallmsgpack-python
msgpack-pure模块安装
pipinstallmsgpack-python
pycrypto模块安装
pipinstallpycrypto
requests模块安装
pipinstallrequests
其他模块安装
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安装
wgethttps://github.com/saltstack/salt/releases/download/v2014.7.0/salt-2014.7.0.tar.gz #tarxvzfsalt-2014.7.0.tar.gz #cdsalt-2014.7.0 #pythonsetup.pyinstall
[root@localhostsalt-2014.7.0]#salt--versions-report Salt:2014.7.0 Python:2.7.5(default,Aug182016,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:NotInstalled PyYAML:3.12 ioflo:NotInstalled PyZMQ:15.4.0 RAET:NotInstalled ZMQ:4.1.5 Mako:NotInstalled [root@localhostsalt-2014.7.0]#
SaltStack配置
(1)、master端
[root@localhostsalt-2014.7.0]#mkdir/etc/salt [root@localhostsalt-2014.7.0]#cp-aconf/master/etc/salt/ [root@localhostsalt-2014.7.0]#cp-apkg/suse/salt-master/etc/init.d/ [root@localhostsalt-2014.7.0]#chmod+x/etc/init.d/salt-master [root@localhostsalt-2014.7.0]#chkconfig--level235salt-masteron [root@localhostsalt-2014.7.0]#mkdir-p/var/log/salt/srv/salt [root@localhostsalt-2014.7.0]#
#vim/etc/salt/master interface:192.168.72.120 auto_accept:True
#ln-s/usr/local/bin/salt-master/usr/bin/ #servicesalt-masterstart
完毕! [root@localhostPackages]#ss-ntlp StateRecv-QSend-QLocalAddress:PortPeerAddress:Port LISTEN0128*:22*:*users:(("sshd",pid=1296,fd=3)) LISTEN0100192.168.72.120:4505*:*users:(("salt-master",pid=45424,fd=18)) LISTEN0100127.0.0.1:25*:*users:(("master",pid=1998,fd=13)) LISTEN0100192.168.72.120:4506*:*users:(("salt-master",pid=45436,fd=30)) LISTEN0128:::22:::*users:(("sshd",fd=4)) LISTEN0100::1:25:::*users:(("master",fd=14))
[root@localhostPackages]#psaux|greppython root7180.02.232402022812?Ssl12:450:00/usr/bin/python-Es/usr/sbin/firewalld--nofork--nopid root12940.01.855306018220?Ssl12:460:02/usr/bin/python-Es/usr/sbin/tuned-l-P root454220.02.228998822944?S16:370:00/usr/bin/python/usr/bin/salt-master-d root454230.74.435556044420?S16:370:02/usr/bin/python/usr/bin/salt-master-d root454240.02.237191622884?Sl16:370:00/usr/bin/python/usr/bin/salt-master-d root454250.02.237191622692?Sl16:370:00/usr/bin/python/usr/bin/salt-master-d root454300.02.228998822596?S16:370:00/usr/bin/python/usr/bin/salt-master-d root454310.64.443991644472?Sl16:370:02/usr/bin/python/usr/bin/salt-master-d root454320.74.443991244476?Sl16:370:02/usr/bin/python/usr/bin/salt-master-d root454330.74.443991244476?Sl16:370:02/usr/bin/python/usr/bin/salt-master-d root454340.74.443992044580?Sl16:370:02/usr/bin/python/usr/bin/salt-master-d root454350.74.443964844552?Sl16:370:02/usr/bin/python/usr/bin/salt-master-d root454360.02.266684422956?Sl16:370:00/usr/bin/python/usr/bin/salt-master-d root459710.00.0112664976pts/0R+16:420:00grep--color=autopython
(2)、minion端
#mkdir/etc/salt #cp-aconf/minion/etc/salt/ #cp-apkg/suse/salt-minion/etc/init.d/ #chmod+x/etc/init.d/salt-minion #chkconfig--level235salt-minionon
#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/ #servicesalt-minionstart
[root@minion192~]#psaux|greppython root7200.12.332402423580?Ssl18:290:00/usr/bin/python-Es/usr/sbin/firewalld--nofork--nopid root12970.01.655307216348?Ssl18:290:00/usr/bin/python-Es/usr/sbin/tuned-l-P root25210.92.837490428436?Sl18:360:00/usr/bin/python/usr/bin/salt-minion-d root25420.00.0112664976pts/0R+18:360:00grep--color=autopython [root@minion192~]#
4、SaltStack简单使用
## 查看当前的salt key信息
[root@minion192~]#salt-key-L AcceptedKeys: UnacceptedKeys: RejectedKeys: [root@minion192~]#