===============================步骤说明===============
===========
os: centos6.5 64bits(需是Basic server版本)
账号:root
密码:123456
此处需要注意,安装时使用root账号操作。使用的os用户名和密码被使用在配置文件中,与登录数据库postgresql有关系。
勿使用其他账号和密码;可以在安装完成后再修改os密码;
1.上传certus-FlexScape-ver03.tar.gz(个性化),rails,vmdb.tar.gz(个性化), install.py(个性化), sql.sh, start.py 和 update.py到/root目录下;
2.在/root目录下执行 python install.py
3.在/root目录下执行 source sql.sh
4.在/root目录下执行 python start.py
5.在/root目录下执行 python update.py
certus-FlexScape-ver03.tar.gz这种是rmp源,真正安装哪个是在install.py中决定的
os.system("yum -y install expect-5.44.1.15-5.el6_4.x86_64.rpm ")
##yum -y install expect 在线安装,由于有时会因nameservice解析的问题安装不了,所以在一次成功之后将相应的rmp下载出来,这个可以在yum的缓存中获取,放在本地仓库expect.tar.gz
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/release/expect.tar.gz . $CM_PASSWORD #qpid-cpp-client... lost
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/instalexpect.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/sql.sh . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/start.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/rails . $CM_PASSWORD
//yum的一些用法
http://www.jb51.net/LINUXjishu/32189.html
# yum install bochs(即可从本地获取rmp也可从源头获取)
如果本地有相关的 rpm 文件,可以用
# yum localinstall ur.rpm
前者导致 yum 搜索现有 repository 中的数据(一般先会连接到这些 repository 下载更新数据),如果发现有此软件,则会通过分析其 dependencies 然后下载并安装所需软件。
=============================================================
#!/bin/bash
#we need this
set -e
DISABLE_MANO=$1
ROOT_DIR=/root #must be exist or we can create one
CM_USER=cm
CM_IP=172.16.33.166
CM_PASSWORD=cm2012
CM_RELEASE_ROOT_DIR=/home/cm/iCloud/release-latest
CM_SCAPE_ROOT_DIR=$CM_RELEASE_ROOT_DIR/scape
CM_MANO_ROOT_DIR=$CM_RELEASE_ROOT_DIR/nfv-mano
# release-latest/
# |-- nfv-mano
# | |-- release
# | | |-- init-sql
# | | | |-- db.sql
# | | | |-- index.sql
# | | | |-- init.sql
# | | | `-- table.sql
# | | |-- mano-war
# | | | |-- mano-nfvo.war
# | | | |-- mano-vim.war
# | | | |-- mano-vnfm.war
# | | | `-- mano.war
# | | `-- scripts
# | | |-- ascp
# | | |-- mysql-init-passwd.sh
# | | `-- psql-cmd.sh
# | `-- software
# | |-- MySQL-5.6.21-1.el6.x86_64.rpm-bundle.tar
# | |-- apache-tomcat-7.0.57.tar.gz
# | `-- jdk-7u75-linux-x64.tar.gz
# `-- scape
# |-- release
# | |-- certus-FlexScape-ver03.tar.gz
# | `-- vmdb
# | |-- vmdb-2015-04-12.tar.gz
# | `-- vmdb-latest.tar.gz -> vmdb-2015-04-12.tar.gz
# `-- scripts
# |-- FlexScape--install-step-by-step.txt
# |-- install.py
# |-- rails
# |-- sql.sh
# `-- start.py
###########################prepare 1 ####################################################
scp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/release/scripts/ascp $ROOT_DIR/ascp
chmod u+x $ROOT_DIR/ascp
##yum -y install expect
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/release/scripts/psql-cmd.sh $ROOT_DIR/psql-cmd.sh $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/release/scripts/mysql-init-passwd.sh $ROOT_DIR/mysql-init-passwd.sh $CM_PASSWORD
chmod u+x $ROOT_DIR/psql-cmd.sh
chmod u+x $ROOT_DIR/mysql-init-passwd.sh
###########这里是我做的一段离线安装源expect.tar.gz ,instalexpect.py 这两个是我自己改造的
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/release/expect.tar.gz . $CM_PASSWORD #qpid-cpp-client... lost
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/instalexpect.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/sql.sh . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/start.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/rails . $CM_PASSWORD
###########################prepare 2 ####################################################
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/release/certus-FlexScape-ver03.tar.gz . $CM_PASSWORD #qpid-cpp-client... lost
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/install.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/sql.sh . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/start.py . $CM_PASSWORD
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/scripts/rails . $CM_PASSWORD
###########################install flexscap ####################################################
cd $ROOT_DIR
python install.py
#bugfix remove => "[[ -s /opt/rh/postgresql92/enable ]] && source /opt/rh/postgresql92/enable"
#from /var/www/miq/system/LINK/etc/default/evm
#from sql.sh
DELETE_LINE=`grep -n 'postgresql92' /var/www/miq/system/LINK/etc/default/evm |awk -F ':' '{print $1}'`
sed "${DELETE_LINE}d" -i /var/www/miq/system/LINK/etc/default/evm
source sql.sh
python start.py
############################update vmdb####################################################
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_SCAPE_ROOT_DIR/release/vmdb/vmdb-latest.tar.gz vmdb.tar.gz $CM_PASSWORD
cd $ROOT_DIR
tar -xzf vmdb.tar.gz
cp -rf /var/www/miq/vmdb /var/www/miq/vmdb.bak
cp -rf ./vmdb /var/www/miq/
cp -rf ./vmdb/fog-1.19.0/lib /usr/share/gems/gems/fog-1.19.0/
###########################recreate database####################################################
cd $ROOT_DIR
$ROOT_DIR/psql-cmd.sh 'drop database "vmdb_production";'
$ROOT_DIR/psql-cmd.sh 'create database "vmdb_production" with owner="root";'
cd /var/www/miq/vmdb
bundle exec rake db:migrate
/sbin/chkconfig --add evmserverd
service evmserverd restart
###########################disable iptables####################################################
service iptables stop
/sbin/chkconfig --level 2345 iptables off
#############################################################################################
if [ $DISABLE_MANO ]; then
exit
fi
##########################install mysql ####################################################
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/software/MySQL-5.6.21-1.el6.x86_64.rpm-bundle.tar . $CM_PASSWORD
tar -xf MySQL-5.6.21-1.el6.x86_64.rpm-bundle.tar
MYSQL_CURRENT=`rpm -qa | grep -i mysql`
if [ $MYSQL_CURRENT ] ;then
rpm -e $MYSQL_CURRENT --nodeps
fi
rpm -ivh MySQL-server-5.6.21-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.21-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.21-1.el6.x86_64.rpm
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
service mysql start
RANDOM_PASSWORD=`cat ~/.mysql_secret |awk -F ' ' '{print $NF}'`
MYSQL_PASSWORD=123456
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/release/init-sql/*.sql . $CM_PASSWORD
$ROOT_DIR/mysql-init-passwd.sh $RANDOM_PASSWORD $MYSQL_PASSWORD
mysql -v -uroot -p$MYSQL_PASSWORD -e "use mysql;update user set host='%' where user='root' and host='localhost';flush privileges;"
/sbin/chkconfig mysql on
/sbin/chkconfig --list |grep mysql
mysql -uroot -p$MYSQL_PASSWORD < db.sql
mysql -uroot -p$MYSQL_PASSWORD < table.sql
#don't known how to do ,, we have 'set -e'
echo `mysql -uroot -p$MYSQL_PASSWORD < index.sql`
mysql -uroot -p$MYSQL_PASSWORD < init.sql
##install jdk####################################################
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/software/jdk-7u75-linux-x64.tar.gz . $CM_PASSWORD
cd /usr/local/
tar -xzf $ROOT_DIR/jdk-7u75-linux-x64.tar.gz
##########################install mysql ####################################################
cd $ROOT_DIR
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/software/apache-tomcat-7.0.57.tar.gz . $CM_PASSWORD
cd /usr/local
tar -xzf $ROOT_DIR/apache-tomcat-7.0.57.tar.gz
INSERT_LINE=`grep -n 'PRGDIR=.*dirname .*PRG' /usr/local/apache-tomcat-7.0.57/bin/catalina.sh |awk -F ':' '{print $1}'`
echo $INSERT_LINE
INSERT_CONTENT="CATALINA_OPTS=\"$CATALINA_OPTS -server -Xmx2048m -XX:MaxPermSize=512m -Xdebug -Xnoagent -Djava.compiler=NONE\""
sed "${INSERT_LINE} a${INSERT_CONTENT}" -i /usr/local/apache-tomcat-7.0.57/bin/catalina.sh
cp /usr/local/apache-tomcat-7.0.57/bin/catalina.sh /etc/init.d/tomcat
#vim /etc/init.d/tomcat
INSERT_CONTENT="# chkconfig: 2345 10 90 \n# description: Tomcat service\nCATALINA_HOME=/usr/local/apache-tomcat-7.0.57\nJAVA_HOME=/usr/local/jdk1.7.0_75\nexport CATALINA_HOME\nexport JAVA_HOME\n"
INSERT_LINE=`grep -n 'os400=false' /etc/init.d/tomcat |awk -F ':' '{print $1}'`
sed "${INSERT_LINE} a${INSERT_CONTENT}" -i /etc/init.d/tomcat
chkconfig --add tomcat
###########################install war packages####################################################
$ROOT_DIR/ascp $CM_USER@$CM_IP:$CM_MANO_ROOT_DIR/release/mano-war/*.war /usr/local/apache-tomcat-7.0.57/webapps $CM_PASSWORD
###########################start tomcat ####################################################
/usr/local/apache-tomcat-7.0.57/bin/startup.sh
###########################config reverse proxy rules####################################################
cp /var/www/miq/vmdb/others/nfv/nfv_apache_config/cfme-redirects-nfv /etc/httpd/conf.d/ ####???????
INSERT_CONTENT="Include conf.d/cfme-redirects-nfv\n"
INSERT_LINE=`grep -n 'VirtualHost.*.*443' /etc/httpd/conf.d/cfme-https-application.conf |awk -F ':' '{print $1}'`
sed "${INSERT_LINE} a${INSERT_CONTENT}" -i /etc/httpd/conf.d/cfme-https-application.conf
##########################restart httpd and evmserverd#########################################
$ROOT_DIR/ascp
[email protected]:/etc/httpd/conf.d/cfme-redirects-ui /etc/httpd/conf.d/ 123456 ##############FIXME
$ROOT_DIR/ascp
[email protected]:/etc/httpd/conf.d/cfme-redirects-ws /etc/httpd/conf.d/ 123456 ##############FIXME
service httpd restart
echo "DONE!!!!!!!!!!!!!!"