openstack-HA(shell脚本)

这是一个用于在CentOS7.2上自动化安装OpenStack-HA集群的shell脚本。脚本包括了环境准备、Ceph、RabbitMQ、MariaDB、Pacemaker、Haproxy、Keystone、Glance、Nova、Neutron、Dashboard、Cinder等组件的安装和配置。此外,脚本还涉及到了如ntp、firewalld、selinux的设置以及yum源的配置。
摘要由CSDN通过智能技术生成
#!/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)
         
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值