由于我的服务器是centos5,安装后还要把zeromq升级,有点蛋疼
一:服务端的安装:
rpm -Uvh http://mirror.pnl.gov/epel/5/i386/epel-release-5-4.noarch.rpm yum install salt-master chkconfig salt-master on service salt-master start
二、客户端的安装:
rpm -Uvh http://mirror.pnl.gov/epel/5/i386/epel-release-5-4.noarch.rpm yum install salt-minion chkconfig salt-minion on #修改/etc/salt/minion配置: master: 192.168.1.100 #服务端IP id: 192.168.1.101 #标识,我用本机IP做标识 service salt-minion start
起始以为就这样快乐的安装完了,但测试过程中发现minion端会产生一个僵尸进程,问了群上的大神绿肥才知道这是一个BUG,要把minion端升级到2014.1.1版本:
yum --enablerepo=epel-testing install salt-minion service salt-minion restart
这样僵尸进程的BUG总算解决了,后来网上一看原来centos5安装salt还有一个BUG,就是zeromq的版本太低,还需要升级一下,于是又找到这个办法来升级:
wget -O /etc/yum.repos.d/ownsource.repo http://www.comingchina.com:8080/testing/ownsource/ownsource.repo yum clean all yum update zeromq libzmq3 python26-zmq service salt-minion restart
检查一下版本:
[root@localhost Server]# salt-minion --versions-report Salt: 2014.1.1 Python: 2.6.8 (unknown, Nov 7 2012, 14:47:45) Jinja2: unknown M2Crypto: 0.21.1 msgpack-python: 0.1.12 msgpack-pure: Not Installed pycrypto: 2.3 PyYAML: 3.08 PyZMQ: 13.1.0 ZMQ: 3.2.2
确实是升级成功了,于是后面就想用salt的state功能来完成剩下机器的升级,可是不会弄呀,果断网上抄一份配置:
getownsourcerepo: cmd.run: - name: wget -O /etc/yum.repos.d/ownsource.repo http://www.comingchina.com:8080/testing/ownsource/ownsource.repo - unless: test -f /etc/yum.repos.d/ownsource.repo zeromqs: pkg.installed: - pkgs: - zeromq - libzmq3 - python26-zmq - require: - cmd: getownsourcerepo salt-minion: service.running: - enable: True - watch: - pkg: zeromqs
放在/etc/salt/updatezeromq.sls,然后先找一台机器测试一下:
salt '192.168.1.102' state.sls updatezeromq
哇,好神奇,这样就可以更新了,等命令跑完,看一下版本,还是没变,擦,这是什么情况,认真看了一下日志,是zeromq python26-zmq这两个包已经存在,没有升级,于是找了一下文档,看看pkg.installed 怎么升级软件,突然发现原来还可以指定版本的,果断把sls文件改成:
getownsourcerepo: cmd.run: - name: wget -O /etc/yum.repos.d/ownsource.repo http://www.comingchina.com:8080/testing/ownsource/ownsource.repo - unless: test -f /etc/yum.repos.d/ownsource.repo zeromqs: pkg.installed: - pkgs: - zeromq: 3.2.2-13.1 - libzmq3 - python26-zmq: 13.1.0-1 - require: - cmd: getownsourcerepo salt-minion: service.running: - enable: True - watch: - pkg: zeromqs
再来一次:
[root@localhost salt]# salt '192.168.1.102' state.sls updatezeromq 192.168.1.102: ---------- ID: getownsourcerepo Function: cmd.run Name: wget -O /etc/yum.repos.d/ownsource.repo http://www.comingchina.com:8080/testing/ownsource/ownsource.repo Result: True Comment: Command "wget -O /etc/yum.repos.d/ownsource.repo http://www.comingchina.com:8080/testing/ownsource/ownsource.repo" run Changes: ---------- pid: 29228 retcode: 0 stderr: --2014-04-09 17:35:22-- http://www.comingchina.com:8080/testing/ownsource/ownsource.repo Resolving www.comingchina.com... 202.103.191.13 Connecting to www.comingchina.com|202.103.191.13|:8080... connected. HTTP request sent, awaiting response... 200 OK Length: 150 [text/plain] Saving to: `/etc/yum.repos.d/ownsource.repo' 0K 100% 14.3M=0s 2014-04-09 17:35:23 (14.3 MB/s) - `/etc/yum.repos.d/ownsource.repo' saved [150/150] stdout: ---------- ID: zeromqs Function: pkg.installed Result: True Comment: 3 targeted packages were installed/updated. Changes: ---------- libzmq3: ---------- new: 3.2.2-13.1 old: python26-zmq: ---------- new: 13.1.0-1 old: 2.1.9-3.el5 zeromq: ---------- new: 3.2.2-13.1 old: 2.2.0-4.el5 ---------- ID: salt-minion Function: service.running Result: True Comment: Service restarted Changes: ---------- salt-minion: True Summary ------------ Succeeded: 3 Failed: 0 ------------ Total: 3
终于顺利升级成功!感觉玩这东西还真不容易。。。