Centos8最小化部署安装OpenStack Ussuri的详细教程

论坛 期权论坛 脚本     
niminba   2021-5-23 04:22   1994   0

Centos8最小化部署安装OpenStack Ussuri的教程如下所示:

#!/bin/bash

#Centos8最小化部署安装OpenStack Ussuri
#共两台主机,分别是一台控制节点,一台计算节点
#1、控制节点内存4096M。双网卡,分别为eth0:10.0.0.11,eth1:10.0.0.12
#2、计算节点内存2048M。双网卡,分别为eth0:10.0.0.31,eth1:10.0.0.32

#设置阿里云yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
rm -f /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-PowerTools.repo /etc/yum.repos.d/CentOS-centosplus.repo /etc/yum.repos.d/CentOS-Extras.repo && rm -rf /var/cache/yum && yum makecache && yum -y update && yum -y autoremove

#关闭防火墙
systemctl stop firewalld && systemctl disable firewalld

#关闭SELinux
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

#关闭swap分区
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

#设置内核
modprobe bridge
modprobe br_netfilter
cat > /etc/sysconfig/modules/neutron.modules <<EOF
#!/bin/bash
modprobe -- bridge
modprobe -- br_netfilter
EOF
chmod 755 /etc/sysconfig/modules/neutron.modules && bash /etc/sysconfig/modules/neutron.modules
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables=1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-ip6tables=1" >> /etc/sysctl.conf
sysctl -p

#设置时间同步
yum install -y chrony && yum -y autoremove
sed -i '/^pool/d' /etc/chrony.conf
sed -i '/^server/d' /etc/chrony.conf
echo "pool ntp.aliyun.com iburst" >> /etc/chrony.conf
systemctl start chronyd.service && systemctl enable chronyd.service

#控制节点 设置hostname
hostnamectl set-hostname controller

#计算节点 设置hostname
hostnamectl set-hostname compute1

#添加host
echo "10.0.0.11 controller" >> /etc/hosts
echo "10.0.0.31 compute1" >> /etc/hosts

#安装基础组件
yum install -y centos-release-openstack-ussuri
yum config-manager --set-enabled PowerTools
yum upgrade -y
yum install -y python3-openstackclient

#控制节点 安装Mariadb
yum install -y mariadb mariadb-server python2-PyMySQL
tee /etc/my.cnf.d/openstack.cnf <<-'EOF'
[mysqld]
bind-address = 10.0.0.11
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
EOF
systemctl enable mariadb.service && systemctl start mariadb.service
echo -e "\nY\n123456\n123456\nY\nn\nY\nY\n" | mysql_secure_installation

#控制节点 安装RabbitMQ
yum install -y rabbitmq-server
systemctl enable rabbitmq-server.service && systemctl start rabbitmq-server.service
rabbitmqctl add_user openstack 123456
rabbitmqctl set_permissions openstack ".*" ".*" ".*"

#控制节点 安装Memcached
yum install -y memcached python3-memcached
sed -i "s/-l 127.0.0.1,::1/-l 127.0.0.1,::1,controller/g" /etc/sysconfig/memcached
systemctl enable memcached.service && systemctl start memcached.service

#控制节点 安装Etcd
yum install -y etcd
rm -f /etc/etcd/etcd.conf
tee /etc/etcd/etcd.conf <<-'EOF'
#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://10.0.0.11:2380"
ETCD_LISTEN_CLIENT_URLS="http://10.0.0.11:2379"
ETCD_NAME="controller"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.0.11:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://10.0.0.11:2379"
ETCD_INITIAL_CLUSTER="controller=http://10.0.0.11:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
EOF
systemctl enable etcd && systemctl start etcd

#控制节点 安装Identity service
mysql -uroot -p123456 -e "CREATE DATABASE keystone"
mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '123456'"
mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '123456'"
yum install -y openstack-keystone httpd python3-mod_wsgi
sed -i "556c connection = mysql+pymysql://keystone:123456@controller/keystone" /etc/keystone/keystone.conf
sed -i "2418c provider = fernet" /etc/keystone/keystone.conf
su -s /bin/sh -c "keystone-manage db_sync" keystone
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
keystone-manage bootstrap --bootstrap-password 123456 \
 --bootstrap-admin-url http://controller:5000/v3/ \
 --bootstrap-internal-url http://controller:5000/v3/ \
 --bootstrap-public-url http://controller:5000/v3/ \
 --bootstrap-region-id RegionOne
echo "ServerName controller" >> /etc/httpd/conf/httpd.conf
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
systemctl enable httpd.service && systemctl start httpd.service
echo "export OS_USERNAME=admin" >> /etc/profile
echo "export OS_PASSWORD=123456" >> /etc/profile
echo "export OS_PROJECT_NAME=admin" >> /etc/profile
echo "export OS_USER_DOMAIN_NAME=Default" >> /etc/profile
echo "export OS_PROJECT_DOMAIN_NAME=Default" >> /etc/profile
echo "export OS_AUTH_URL=http://controller:5000/v3" >> /etc/profile
echo "export OS_IDENTITY_API_VERSION=3" >> /etc/profila
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1060120
帖子:212021
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP