saltstack学习一:安装与升级

简介:

由于我的服务器是centos5,安装后还要把zeromq升级,有点蛋疼


一:服务端的安装:

1
2
3
4
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


二、客户端的安装:

1
2
3
4
5
6
7
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版本:

1
2
yum --enablerepo=epel-testing  install  salt-minion
service salt-minion restart

这样僵尸进程的BUG总算解决了,后来网上一看原来centos5安装salt还有一个BUG,就是zeromq的版本太低,还需要升级一下,于是又找到这个办法来升级:

1
2
3
4
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

检查一下版本:

1
2
3
4
5
6
7
8
9
10
11
[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功能来完成剩下机器的升级,可是不会弄呀,果断网上抄一份配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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,然后先找一台机器测试一下:

1
salt  '192.168.1.102'  state.sls updatezeromq

哇,好神奇,这样就可以更新了,等命令跑完,看一下版本,还是没变,擦,这是什么情况,认真看了一下日志,是zeromq python26-zmq这两个包已经存在,没有升级,于是找了一下文档,看看pkg.installed 怎么升级软件,突然发现原来还可以指定版本的,果断把sls文件改成:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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

再来一次:

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[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

终于顺利升级成功!感觉玩这东西还真不容易。。。

本文转自运维笔记博客51CTO博客,原文链接http://blog.51cto.com/lihuipeng/1393013如需转载请自行联系原作者


lihuipeng

相关文章
|
存储 JSON 应用服务中间件
saltstack学习自动化
saltstack学习自动化
110 0
|
消息中间件 监控 网络协议
SaltStack安装Apache/Mysql/PHP部署Wordpress
SaltStack是一个服务器基础架构集中化管理平台,具备配置管理、远程执行、监控等功能,基于Python语言实现,结合轻量级消息队列(ZeroMQ)与Python第三方模块(Pyzmq、PyCrypto、Pyjinjia2、python-msgpack和PyYAML等)构建。 SaltStack 采用 C/S模式,server端就是salt的master,client端就是minion,minion与master之间通过ZeroMQ消息队列通信。 master监听4505和4506端口,4505对应的是ZMQ的PUB system,用来发送消息,4506对应的是REP system是来接受
179 0
|
关系型数据库 应用服务中间件 测试技术
|
Python 消息中间件 运维