源码安装saltstack
之前在redhat6.2_x64上装saltstack比较容易,当时考虑到服务器没有联网,就用的本地yum源和所需的包进行安装的,当时也比较顺利,光盘中的包以及自己下载的包都能够很好的方便的进行安装;后来又使用同样的方法在master端起一个httpd服务将所需的包作为网络中的yum源,继续在redhat6.2上安装saltstack真是屡试不爽;但是,今天再次尝试使用以上2种方法在redhat5.7上安装saltstack时就问题多多,无论是联网安装还是做yum的方法安装均不成功,遂就尝试用源码的方式安装saltstack。过程比较曲折,在这里整理下,以飨后人。
下边便是整个安装过程,部分安装命令的输出已省略。
===========================================================
源码安装saltstack
1、操作系统信息
[root@linux3 ~]# uname -a Linux linux3 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux [root@linux3 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.7 (Tikanga)
2、所需软件包
[root@linux3 ~]# mkdir saltinstall [root@linux3 ~]# cd saltinstall/ [root@linux3 saltinstall]# ls -ltr total 32832 -rw-r--r-- 1 root root 571091 Jan 15 15:03 zlib-1.2.8.tar.gz -rw-r--r-- 1 root root 256862 Jan 15 15:03 setuptools-0.6c11.tar.gz -rw-r--r-- 1 root root 232384 Jan 15 15:03 python-dateutil-1.5.tar.gz -rw-r--r-- 1 root root 4434910 Jan 15 15:03 openssl-1.0.1k.tar.gz -rw-r--r-- 1 root root 248685 Jan 15 15:03 PyYAML-3.11.tar.gz -rw-r--r-- 1 root root 443445 Jan 15 15:03 pycrypto-2.6.tar.gz -rw-r--r-- 1 root root 13416 Jan 15 15:03 MarkupSafe-0.23.tar.gz -rw-r--r-- 1 root root 378470 Jan 15 15:03 Jinja2-2.7.3.tar.gz -rw-r--r-- 1 root root 2153667 Jan 15 15:03 zeromq-4.0.5.tar.gz -rw-r--r-- 1 root root 503012 Jan 15 15:03 yaml-0.1.6.tar.gz -rw-r--r-- 1 root root 995366 Jan 15 15:03 pyzmq-14.4.1.tar.gz -rw-r--r-- 1 root root 14846119 Jan 15 15:03 Python-2.7.8.tgz -rw-r--r-- 1 root root 113908 Jan 15 15:03 msgpack-python-0.4.4.tar.gz -rw-r--r-- 1 root root 3584 Jan 15 15:03 msgpack-pure-0.1.3.tar.gz -rw-r--r-- 1 root root 74795 Jan 15 15:03 M2Crypto-0.22.3.tar.gz -rw-r--r-- 1 root root 5310295 Jan 15 15:03 swig-2.0.11.tar.gz -rw-r--r-- 1 root root 2845127 Jan 15 15:37 salt-2014.1.4.tar.gz
3、安装gcc相关包
[root@linux3 ~]# mount /dev/cdrom /mnt mount: block device /dev/cdrom is write-protected, mounting read-only [root@linux3 ~]# cat /etc/yum.repos.d/local.repo [rhel-localrepos] name=Red Hat Enterprise Linux $releasever - $basearch baseurl=file:///mnt/Server enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [root@linux3 ~]# yum install gcc* -y
4、安装python
[root@linux3 saltinstall]# tar xzvf Python-2.7.8.tgz [root@linux3 saltinstall]# cd Python-2.7.8 [root@linux3 Python-2.7.8]# ./configure [root@linux3 Python-2.7.8]# make [root@linux3 Python-2.7.8]# make install [root@linux3 Python-2.7.8]# ./python -V Python 2.7.8
修改环境变量使用最新的python
[root@linux3 ~]# which python /usr/local/bin/python [root@linux3 bin]# pwd /usr/local/bin [root@linux3 bin]# mv python python_bak [root@linux3 bin]# ln -s /root/saltinstall/Python-2.7.8/python python [root@linux3 bin]# python -V Python 2.7.8
5、安装zlib
[root@linux3 ~]# yum install zlib-devel -y [root@linux3 saltinstall]# tar -zxvf zlib-1.2.8.tar.gz [root@linux3 saltinstall]# cd zlib-1.2.8 [root@linux3 zlib-1.2.8]# ./configure --prefix=/usr/local/zlib-1.2.8 -share [root@linux3 zlib-1.2.8]# make [root@linux3 zlib-1.2.8]# make install
配置库文件搜索路径
[root@linux3 zlib-1.2.8]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf ##add start /usr/local/zlib-1.2.8/lib ##add end [root@linux3 zlib-1.2.8]# /sbin/ldconfig -v [root@linux3 zlib-1.2.8]# ln -s /usr/local/zlib-1.2.8 /usr/local/zlib
6、安装setuptools
[root@linux3 saltinstall]# tar xzvf setuptools-0.6c11.tar.gz [root@linux3 saltinstall]# cd setuptools-0.6c11 [root@linux3 setuptools-0.6c11]# python setup.py build [root@linux3 setuptools-0.6c11]# python setup.py install
7、安装python-dateutil
[root@linux3 saltinstall]# tar xzvf python-dateutil-1.5.tar.gz [root@linux3 saltinstall]# cd python-dateutil-1.5 [root@linux3 python-dateutil-1.5]# python setup.py install
8、安装openssl
[root@linux3 saltinstall]# tar zxvf openssl-1.0.1k.tar.gz [root@linux3 saltinstall]# cd openssl-1.0.1k [root@linux3 openssl-1.0.1k]# ./config -fPIC [root@linux3 openssl-1.0.1k]# ./config shared zlib-dynamic --prefix=/usr/local/openssl-1.0.1k --with-zlib-lib=/usr/local/zlib-1.2.8/lib --with-zlib-include=/usr/local/zlib-1.2.8/include -enable-shared --prefix=/usr/local/openssl-1.0.1k [root@linux3 openssl-1.0.1k]# make [root@linux3 openssl-1.0.1k]# make install [root@linux3 ~]# openssl version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 [root@linux3 ~]# which openssl /usr/bin/openssl [root@linux3 ~]# cd /usr/bin/ [root@linux3 bin]# mv openssl openssl_bak [root@linux3 bin]# ln -s /usr/local/openssl-1.0.1k/bin/openssl openssl [root@linux3 bin]# openssl version OpenSSL 1.0.1k 8 Jan 2015
配置库文件搜索路径
[root@linux3 ~]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf ##add start /usr/local/zlib-1.2.8/lib /usr/local/openssl-1.0.1k/lib ##add end [root@linux3 ~]# /sbin/ldconfig -v
9、安装PyYAML
[root@linux3 saltinstall]# tar xzvf PyYAML-3.11.tar.gz [root@linux3 saltinstall]# cd PyYAML-3.11 [root@linux3 PyYAML-3.11]# python setup.py install
10、安装MarkupSafe
[root@linux3 saltinstall]# tar xzvf MarkupSafe-0.23.tar.gz [root@linux3 saltinstall]# cd MarkupSafe-0.23 [root@linux3 MarkupSafe-0.23]# python setup.py install
11、安装Jinja2
[root@linux3 saltinstall]# tar xzvf Jinja2-2.7.3.tar.gz [root@linux3 saltinstall]# cd Jinja2-2.7.3 [root@linux3 Jinja2-2.7.3]# python setup.py install
12、安装pycrypto
[root@linux3 saltinstall]# tar xzvf pycrypto-2.6.tar.gz [root@linux3 saltinstall]# cd pycrypto-2.6 [root@linux3 pycrypto-2.6]# python setup.py install
13、安装zeromq
[root@linux3 saltinstall]# tar xzvf zeromq-4.0.5.tar.gz [root@linux3 saltinstall]# cd zeromq-4.0.5 [root@linux3 zeromq-4.0.5]# ./configure [root@linux3 zeromq-4.0.5]# make [root@linux3 zeromq-4.0.5]# make install
14、安装pyzmq
[root@linux3 saltinstall]# tar xzvf pyzmq-14.4.1.tar.gz [root@linux3 saltinstall]# cd pyzmq-14.4.1 [root@linux3 pyzmq-14.4.1]# python setup.py install
15、安装msgpack-python
[root@linux3 saltinstall]# tar xvzf msgpack-python-0.4.4.tar.gz [root@linux3 saltinstall]# cd msgpack-python-0.4.4 [root@linux3 msgpack-python-0.4.4]# python setup.py install
16、安装yaml
[root@linux3 saltinstall]# tar xzvf yaml-0.1.6.tar.gz [root@linux3 saltinstall]# cd yaml-0.1.6 [root@linux3 yaml-0.1.6]# ./configure [root@linux3 yaml-0.1.6]# make [root@linux3 yaml-0.1.6]# make install
17、安装msgpack-pure
[root@linux3 saltinstall]# tar xvzf msgpack-pure-0.1.3.tar.gz [root@linux3 saltinstall]# cd msgpack-pure-0.1.3 [root@linux3 msgpack-pure-0.1.3]# python setup.py install
18、安装pcre-devel
[root@linux3 ~]# yum -y install pcre-devel
19、安装swig
[root@linux3 saltinstall]# tar xvzf swig-2.0.11.tar.gz [root@linux3 saltinstall]# cd swig-2.0.11 [root@linux3 swig-2.0.11]# ./configure [root@linux3 swig-2.0.11]# make [root@linux3 swig-2.0.11]# make install
20、安装M2Crypto
[root@linux3 saltinstall]# tar xzvf M2Crypto-0.22.3.tar.gz [root@linux3 saltinstall]# cd M2Crypto-0.22.3 [root@linux3 M2Crypto-0.22.3]# python setup.py build build_ext --openssl=/usr/local/openssl-1.0.1k/ [root@linux3 M2Crypto-0.22.3]# python setup.py install
21、安装salt
[root@linux3 saltinstall]# tar xzvf salt-2014.1.4.tar.gz [root@linux3 saltinstall]# cd salt-2014.1.4 python setup.py install
22、检查安装情况
[root@linux3 ~]# salt-minion --versions-report Salt: 2014.1.4 Python: 2.7.8 (default, Jan 15 2015, 15:08:48) Jinja2: 2.7.3 M2Crypto: 0.22 msgpack-python: 0.4.4 msgpack-pure: 0.1.3 pycrypto: 2.6 PyYAML: 3.11 PyZMQ: 14.4.1 ZMQ: 4.0.5
23、拷贝minion配置文件到/etc/salt下
[root@linux3 ~]# mkdir -p /etc/salt/ [root@linux3 ~]# cp /root/saltinstall/salt-2014.1.4/conf/minion /etc/salt/ [root@linux3 ~]# salt salt salt-call salt-cloud salt-cp salt-key salt-master salt-minion salt-run salt-ssh salt-syndic [root@linux3 ~]# salt-minion -d
24、在master端进行测试
[root@linux0 init.d]# salt-key -L Accepted Keys: Unaccepted Keys: linux1_192.168.88.131 linux3_192.168.88.133 Rejected Keys: [root@linux0 init.d]# salt-key -A The following keys are going to be accepted: Unaccepted Keys: linux1_192.168.88.131 linux3_192.168.88.133 Proceed? [n/Y] y Key for minion linux1_192.168.88.131 accepted. Key for minion linux3_192.168.88.133 accepted. [root@linux0 init.d]# salt '*' cmd.run "ifconfig -a|grep add" linux1_192.168.88.131: eth0 Link encap:Ethernet HWaddr 00:0C:29:81:67:36 inet addr:192.168.88.131 Bcast:192.168.88.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe81:6736/64 Scope:Link inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host linux3_192.168.88.133: eth0 Link encap:Ethernet HWaddr 00:0C:29:FA:0F:D8 inet addr:192.168.88.133 Bcast:192.168.88.255 Mask:255.255.255.0 inet addr:127.0.0.1 Mask:255.0.0.0
===========================================================
如果报以下错
[root@linux3 M2Crypto-0.22.3]# salt-minion --versions-report Salt: 2014.1.4 Python: 2.7.8 (default, Jan 14 2015, 13:02:31) Jinja2: 2.7.3 M2Crypto: Not Installed msgpack-python: 0.4.4 msgpack-pure: 0.1.3 pycrypto: 2.6 PyYAML: 3.11 PyZMQ: 14.4.1 ZMQ: 4.0.5 [root@linux3 salt-2014.1.4]# cp ../salt-2014.1.4/conf/minion /etc/salt/ [root@linux3 salt-2014.1.4]# salt-minion [ERROR ] An un-handled exception was caught by salt's global exception handler: NameError: global name 'RSA' is not defined Traceback (most recent call last): File "/usr/local/bin/salt-minion", line 14, in salt_minion() File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 35, in salt_minion minion.start() File "/usr/local/lib/python2.7/site-packages/salt/__init__.py", line 221, in start self.prepare() File "/usr/local/lib/python2.7/site-packages/salt/__init__.py", line 209, in prepare self.minion = salt.minion.Minion(self.config) File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 544, in __init__ self.authenticate(timeout, safe) File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 1063, in authenticate self.tok = auth.gen_token('salt') File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 232, in gen_token return self.get_keys().private_encrypt(clear_tok, 5) File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 223, in get_keys self.opts.get('user')) File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 96, in gen_keys gen = RSA.gen_key(keysize, 65537, callback=lambda x, y, z: None) NameError: global name 'RSA' is not defined Traceback (most recent call last): File "/usr/local/bin/salt-minion", line 14, in salt_minion() File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 35, in salt_minion minion.start() File "/usr/local/lib/python2.7/site-packages/salt/__init__.py", line 221, in start self.prepare() File "/usr/local/lib/python2.7/site-packages/salt/__init__.py", line 209, in prepare self.minion = salt.minion.Minion(self.config) File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 544, in __init__ self.authenticate(timeout, safe) File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 1063, in authenticate self.tok = auth.gen_token('salt') File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 232, in gen_token return self.get_keys().private_encrypt(clear_tok, 5) File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 223, in get_keys self.opts.get('user')) File "/usr/local/lib/python2.7/site-packages/salt/crypt.py", line 96, in gen_keys gen = RSA.gen_key(keysize, 65537, callback=lambda x, y, z: None) NameError: global name 'RSA' is not defined
需要修改文件
[root@linux3 SWIG]# pwd /root/saltinstall/M2Crypto-0.22.3/SWIG [root@linux3 SWIG]# ls -l _ssl.i -rw-r--r-- 1 501 games 22546 Jan 15 10:34 _ssl.i
添加以下行
+#ifndef OPENSSL_NO_SSL2 %rename(sslv2_method) SSLv2_method; extern SSL_METHOD *SSLv2_method(void); +#endif
注意openssl动态链接库