由两部分组成,BS架构的OMserver作为UI客户端交互和saltstack作为主控端服务。
选择saltstack的原因
1. 基于Python,便于二次开发
2. saltstack使用消息队列zeroMQ传输数据,更快更稳,ansible基于ssh协议传输数据
3. 使用salt-ssh 安装 salt-minion ,平衡了ansible 不需要安装代理的优势
搭建OMserver脚本如下:
function install_pcre(){
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make && make install
echo "################################# install pcre success"
cd ..
}
function install_nginx(){
wget http://nginx.org/download/nginx-1.5.9.tar.gz
tar zxvf nginx-1.5.9.tar.gz
cd nginx-1.5.9
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-cc-opt='-O3' --with-cpu-opt=opteron
make
make install
echo "################################# install nginx success"
cd ..
}
function install_uwsgi(){
wget http://projects.unbit.it/downloads/uwsgi-2.0.4.tar.gz
tar zxvf uwsgi-2.0.4.tar.gz
cd uwsgi-2.0.4
ls
make
cp uwsgi /usr/bin
#error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
# 32bit
#ln -s /usr/local/lib/libpcre.so.1 /lib
# 64bit
ln -s /usr/local/lib/libpcre.so.1 /lib64
echo "################################# install pcre success"
cd ..
}
function install_django(){
wget --no-check-certificate https://www.djangoproject.com/m/releases/1.4/Django-1.4.9.tar.gz
tar zxvf Django-1.4.9.tar.gz
cd Django-1.4.9
python setup.py install
echo "################################# install django success"
cd ..
}
function install_mysql_python(){
wget https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
python setup.py install
cd ..
}
function install_django_debug_toolbar(){
wget https://github.com/robhudson/django-debug-toolbar/archive/master.zip
mv master.zip django-debug-toolbar.zip
unzip django-debug-toolbar.zip
cd django-debug-toolbar-master/
python setup.py install
cd ..
}
cd /data
mkdir auto_operator
cd auto_operator/
mdkir /data/logs
mkdir -p /data/www/OMserverweb
install_pcre
# nginx 安装需要zlib
# 解决没有Python.h
sudo yum -y install zlib-devel zlib python-devel.x86_64
install_nginx
install_uwsgi
install_django
install_mysql_python
install_django_debug_toolbar
echo "config nginx.conf"
#vim /usr/local/nginx/conf/nginx.conf
echo "config uwsgi.ini"
#vim /usr/local/nginx/conf/uwsgi.ini
echo "start uwsgi"
#/usr/bin/uwsgi --ini /usr/local/nginx/conf/uwsgi.ini
echo "start nginx"
#/usr/local/nginx/sbin/nginx