#!/bin/bash
#CentOS7.2 Install the openstack-HA cluster
#author:yongbangyan
#mail:229026497@qq.com
Ipaddr=$(ifconfig eno33554984 |grep "inet " | awk '{print $2}')
HostName=$(hostnamectl | grep "Static" | awk '{print $3}')
setup_select()
{
clear
cat << menu
++++++++++++++ CentOS7.2 Install the openstack-HA cluster ++++++++++++++++++++++
note:all of the need soft must be located in root directory!!!!
1. Openstack preparation environment
2. Install ceph
3. Install rabiitmq
4. Install mariadb
5. Install pacemaker
6. Install haproxy
7. Install keystone and apache
8. Install glance
9. Install nova
10.Install neutron
11.Install dashboard
12.Install cinder-控制节点
13.Install cinder-计算节点
14.Install compute-calculation node installation
15.Configure PCS
Q. quit
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
menu
echo -e -n " Please Select [1,2,3,Q] > "
#read -p "please select [1,2,3,Q] >:" Select
}
###########################################################
amp_setup()
{
setup_select
read select
case $select in
1)
echo "###############Openstack preparation environment################"
sleep 3
#1.环境部署准备
read -p "please enter the hostname:" host
for NAME in $host
do
hostnamectl set-hostname $NAME
done
yum -y install wget net-tools ntp ntpdate lrzsz >> /dev/null
systemctl restart ntpdate.service ntpd.service
systemctl enable ntpd.service ntpdate.service >> /dev/null
systemctl disable firewalld.service >> /dev/null
systemctl stop firewalld.service
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS-CR.repo CentOS-CR.repo.bak
mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
mv CentOS-fasttrack.repo CentOS-fasttrack.repo.bak
mv CentOS-Media.repo CentOS-Media.repo.bak
mv CentOS-Sources.repo CentOS-Sources.repo.bak
mv CentOS-Vault.repo CentOS-Vault.repo.bak
cat > /etc/yum.repos.d/openstack-newton.repo << EOF
[openstack-newton]
name=openstack-newton
baseurl=http://10.1.1.125/openstack-newton/
gpgcheck=0
enabled=1
[ha-pcs]
name=ha-pcs
baseurl=http://10.1.1.125/pcs/
gpgcheck=0
enabled=1
[ha-clustering]
name=ha-clustering
baseurl=http://10.1.1.125/ha-clustering/CentOS_CentOS-7/
gpgcheck=0
enabled=1
[epel]
name=epel
baseurl=http://10.1.1.125/epel/7/x86_64/
gpgcheck=0
enabled=1
[mariadb]
name=mariadb10.1
baseurl=http://10.1.1.125/mariadb10.1/
gpgcheck=0
enabled=1
[CentOS7.2]
name=CentOS7.2
baseurl=http://10.1.1.125/centos7.2/os/x86_64/
gpgcheck=0
enabled=1
EOF
yum clean all >> /dev/null
yum makecache >> /dev/null
if [ $? -eq 0 ]
then
reboot
fi
amp_setup
;;
2)
echo "###############INSTALL ceph################"
sleep 3
read -p "please enter the hostname:" host
for NAME in $host
do
hostnamectl set-hostname $NAME
done
#1.关闭防火墙和selinux
systemctl disable firewalld.service >> /dev/null
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
#2.安装ntp使时间同步
yum -y install wget net-tools ntp ntpdate lrzsz >> /dev/null
systemctl enable ntpd.service ntpdate.service >> /dev/null
systemctl restart ntpdate.service ntpd.service
#3.配置ceph yum源
yum clean all >> /dev/null
rm -rf /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo >> /dev/null
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >> /dev/null
sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
cat > /etc/yum.repos.d/ceph.repo << EOF
[ceph]
name=ceph
baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/x86_64/
gpgcheck=0
[ceph-noarch]
name=cephnoarch
baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/noarch/
gpgcheck=0
EOF
yum clean all >> /dev/null
yum makecache >> /dev/null
yum update -y >> /dev/null
if [ $? -eq 0 ]
then
Date=`date +%F/%H:%M`
echo "$Date update success" >> /dev/null
fi
echo "update success!!!!"
sleep 3
#4.安装ceph-deploy
yum install ceph-deploy -y >> /dev/null
if [ $? -eq 0 ]
then
mkdir /etc/ceph
cd /etc/ceph
fi
echo "ceph-deploy install success!!!!"
sleep 3
amp_setup
;;
3)
echo "###############INSTALL rabbitmq################"
sleep 3
#1.安装rabbitmq
yum clean all
yum makecache
if [ $? -eq 0 ]
then
yum install -y erlang rabbitmq-server >> /dev/null
fi
systemctl enable rabbitmq-server.service >> /dev/null
systemctl restart rabbitmq-server.service
if [ $? -eq 0 ]
then
rabbitmqctl add_user openstack devops >> /dev/null
rabbitmqctl set_permissions openstack ".*" ".*" ".*" >> /dev/null
rabbitmqctl set_user_tags openstack administrator >> /dev/null
rabbitmqctl list_users >> /dev/null
fi
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent >> /dev/null
# scp /var/lib/rabbitmq/.erlang.cookie controller2:/var/lib/rabbitmq/.erlang.cookie >> /dev/null
# scp /var/lib/rabbitmq/.erlang.cookie controller3:/var/lib/rabbitmq/.erlang.cookie >> /dev/null
#2.优化rabbitmq
echo "fs.file-max = 1000000" >> /etc/sysctl.conf
echo "* soft nofile 655350" >> /etc/security/limits.conf
echo "* hard nofile 655350" >> /etc/security/limits.conf
echo "DefaultLimitNOFILE=1024000" >> /etc/systemd/system.conf
echo "DefaultLimitNPROC=1024000" >> /etc/systemd/system.conf
systemctl restart rabbitmq-server.service
if [ $? -eq 0 ]
then
reboot
fi
amp_setup
;;
4)
#CentOS7.2 Install the openstack-HA cluster
#author:yongbangyan
#mail:229026497@qq.com
Ipaddr=$(ifconfig eno33554984 |grep "inet " | awk '{print $2}')
HostName=$(hostnamectl | grep "Static" | awk '{print $3}')
setup_select()
{
clear
cat << menu
++++++++++++++ CentOS7.2 Install the openstack-HA cluster ++++++++++++++++++++++
note:all of the need soft must be located in root directory!!!!
1. Openstack preparation environment
2. Install ceph
3. Install rabiitmq
4. Install mariadb
5. Install pacemaker
6. Install haproxy
7. Install keystone and apache
8. Install glance
9. Install nova
10.Install neutron
11.Install dashboard
12.Install cinder-控制节点
13.Install cinder-计算节点
14.Install compute-calculation node installation
15.Configure PCS
Q. quit
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
menu
echo -e -n " Please Select [1,2,3,Q] > "
#read -p "please select [1,2,3,Q] >:" Select
}
###########################################################
amp_setup()
{
setup_select
read select
case $select in
1)
echo "###############Openstack preparation environment################"
sleep 3
#1.环境部署准备
read -p "please enter the hostname:" host
for NAME in $host
do
hostnamectl set-hostname $NAME
done
yum -y install wget net-tools ntp ntpdate lrzsz >> /dev/null
systemctl restart ntpdate.service ntpd.service
systemctl enable ntpd.service ntpdate.service >> /dev/null
systemctl disable firewalld.service >> /dev/null
systemctl stop firewalld.service
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS-CR.repo CentOS-CR.repo.bak
mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
mv CentOS-fasttrack.repo CentOS-fasttrack.repo.bak
mv CentOS-Media.repo CentOS-Media.repo.bak
mv CentOS-Sources.repo CentOS-Sources.repo.bak
mv CentOS-Vault.repo CentOS-Vault.repo.bak
cat > /etc/yum.repos.d/openstack-newton.repo << EOF
[openstack-newton]
name=openstack-newton
baseurl=http://10.1.1.125/openstack-newton/
gpgcheck=0
enabled=1
[ha-pcs]
name=ha-pcs
baseurl=http://10.1.1.125/pcs/
gpgcheck=0
enabled=1
[ha-clustering]
name=ha-clustering
baseurl=http://10.1.1.125/ha-clustering/CentOS_CentOS-7/
gpgcheck=0
enabled=1
[epel]
name=epel
baseurl=http://10.1.1.125/epel/7/x86_64/
gpgcheck=0
enabled=1
[mariadb]
name=mariadb10.1
baseurl=http://10.1.1.125/mariadb10.1/
gpgcheck=0
enabled=1
[CentOS7.2]
name=CentOS7.2
baseurl=http://10.1.1.125/centos7.2/os/x86_64/
gpgcheck=0
enabled=1
EOF
yum clean all >> /dev/null
yum makecache >> /dev/null
if [ $? -eq 0 ]
then
reboot
fi
amp_setup
;;
2)
echo "###############INSTALL ceph################"
sleep 3
read -p "please enter the hostname:" host
for NAME in $host
do
hostnamectl set-hostname $NAME
done
#1.关闭防火墙和selinux
systemctl disable firewalld.service >> /dev/null
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
#2.安装ntp使时间同步
yum -y install wget net-tools ntp ntpdate lrzsz >> /dev/null
systemctl enable ntpd.service ntpdate.service >> /dev/null
systemctl restart ntpdate.service ntpd.service
#3.配置ceph yum源
yum clean all >> /dev/null
rm -rf /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo >> /dev/null
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >> /dev/null
sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
cat > /etc/yum.repos.d/ceph.repo << EOF
[ceph]
name=ceph
baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/x86_64/
gpgcheck=0
[ceph-noarch]
name=cephnoarch
baseurl=http://mirrors.163.com/ceph/rpm-jewel/el7/noarch/
gpgcheck=0
EOF
yum clean all >> /dev/null
yum makecache >> /dev/null
yum update -y >> /dev/null
if [ $? -eq 0 ]
then
Date=`date +%F/%H:%M`
echo "$Date update success" >> /dev/null
fi
echo "update success!!!!"
sleep 3
#4.安装ceph-deploy
yum install ceph-deploy -y >> /dev/null
if [ $? -eq 0 ]
then
mkdir /etc/ceph
cd /etc/ceph
fi
echo "ceph-deploy install success!!!!"
sleep 3
amp_setup
;;
3)
echo "###############INSTALL rabbitmq################"
sleep 3
#1.安装rabbitmq
yum clean all
yum makecache
if [ $? -eq 0 ]
then
yum install -y erlang rabbitmq-server >> /dev/null
fi
systemctl enable rabbitmq-server.service >> /dev/null
systemctl restart rabbitmq-server.service
if [ $? -eq 0 ]
then
rabbitmqctl add_user openstack devops >> /dev/null
rabbitmqctl set_permissions openstack ".*" ".*" ".*" >> /dev/null
rabbitmqctl set_user_tags openstack administrator >> /dev/null
rabbitmqctl list_users >> /dev/null
fi
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent >> /dev/null
# scp /var/lib/rabbitmq/.erlang.cookie controller2:/var/lib/rabbitmq/.erlang.cookie >> /dev/null
# scp /var/lib/rabbitmq/.erlang.cookie controller3:/var/lib/rabbitmq/.erlang.cookie >> /dev/null
#2.优化rabbitmq
echo "fs.file-max = 1000000" >> /etc/sysctl.conf
echo "* soft nofile 655350" >> /etc/security/limits.conf
echo "* hard nofile 655350" >> /etc/security/limits.conf
echo "DefaultLimitNOFILE=1024000" >> /etc/systemd/system.conf
echo "DefaultLimitNPROC=1024000" >> /etc/systemd/system.conf
systemctl restart rabbitmq-server.service
if [ $? -eq 0 ]
then
reboot
fi
amp_setup
;;
4)