centos5安裝salt-master

曲珂發表於2014-10-29

本篇文件主要解決2個問題:

1. centos5通過yum安裝的master版本肯定低於centos6安裝的minion,所以必須升級salt-master

2. zeromq版本太低會報這個錯

2014-10-29 14:36:04,597 [salt.master      ][WARNING ] You have a version of ZMQ less than ZMQ 3.2! There are known connection keep-alive issues with ZMQ < 3.2 which may result in loss of contact with minions. Please upgrade your ZMQ!

通過pip安裝salt-master之前需要先安裝zeromq,因為yum安裝的版本太低,啟動salt-master會出現上面那個警告,然後master就退出了

原始碼編譯安裝zeromq

wget http://download.zeromq.org/zeromq-3.2.5.tar.gz

 解壓後,通用的編譯安裝步驟就可以了

cd zeromq-3.2.5
.configure && make && make install

 然後pip安裝pyzmq

/usr/local/python/bin/pip install pyzmq --install-option="--zmq=/usr/lib"

 安裝salt

/usr/local/python/bin/pip install salt

 這樣salt是安裝在python的bin目錄中

/usr/local/python/bin/
|-- 2to3
|-- django-admin
|-- django-admin.py
|-- django-admin.pyc
|-- easy_install
|-- easy_install-2.7
|-- idle
|-- pip
|-- pip2
|-- pip2.7
|-- pydoc
|-- python -> python2
|-- python-config -> python2-config
|-- python2 -> python2.7
|-- python2-config -> python2.7-config
|-- python2.7
|-- python2.7-config
|-- salt
|-- salt-call
|-- salt-cloud
|-- salt-cp
|-- salt-key
|-- salt-master
|-- salt-minion
|-- salt-run
|-- salt-ssh
|-- salt-syndic
`-- smtpd.py

 這樣通過python的pip安裝的salt是沒有啟動指令碼的,這裡附上啟動指令碼(yum安裝的salt-master啟動指令碼在/etc/init.d/salt-master)

#!/bin/bash
#
# salt master startup system-v script

DEBIAN_VERSION=/etc/debian_version
SUSE_RELEASE=/etc/SuSE-release
# Source function library.
if [ -f $DEBIAN_VERSION ]; then
   break   
elif [ -f $SUSE_RELEASE -a -r /etc/rc.status ]; then
    . /etc/rc.status
else
    . /etc/rc.d/init.d/functions
fi

SALTMASTER=/usr/local/python/bin/salt-master
python=/usr/local/python/bin/python
SERVICE=salt-master
PROCESS=salt-master

start() {
    echo -n 'starting salt-master daemon:'
    daemon --check $SERVICE $SALTMASTER -d
    RETVAL=$?
    echo
    return $RETVAL
}

stop() {
    echo -n 'stoping salt-master daemon:'
    killproc $PROCESS
    RETVAL=$?
    echo
}

restart() {
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    status)
        if [ -f $SUSE_RELEASE ]; then
            echo -n "Checking for service salt-master "
            checkproc $SALTMASTER
            rc_status -v
        elif [ -f $DEBIAN_VERSION ]; then
            if [ -f $LOCKFILE ]; then
                RETVAL=0
                echo "salt-master is running."
            else
                RETVAL=1
                echo "salt-master is stopped."
            fi
        else
            status $PROCESS
            RETVAL=$?
        fi
        ;;
    condrestart)
        [ -f $LOCKFILE ] && restart || :
        ;;
    reload)
        echo "can't reload configuration, you have to restart it"
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        exit 1
        ;;
esac
exit $RETVAL

 

相關文章