openStack部署mitaka版本
//
# shell脚本安装openStack zed
- 下载openstack zed 版本部署脚本 ,按说明配置脚本
# shell脚本安装openStack train
- 下载openstack train 版本部署脚本 ,按说明配置脚本
# shell脚本安装openStack mitaka
MiTaka 官方文档 (opens new window)
1:提前关闭防火墙,2:配置网卡 eth0(公有网络) ,eth1(内部网络),3:提前下载好离线yum源,到 /opt/repo目录下
- 网卡示例
[root@compute2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.108.106
PREFIX=24
GATEWAY=192.168.108.2
DNS1=114.114.114.114
[root@compute2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.0.16
PREFIX=24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
- centos7 shell脚本
#!/bin/bash
#注意!!! 先提前修改好主机名!!!!!!!!!!!
#默认出口网卡 eth0
#glance 镜像存储路径:/data/glance/images/
#时间主服务部署在 keystone ip上
#服务之间的账号密码默认,如果修改,全局修改
#mariadb ,memcached ,rabbitmq
DB_IP=192.168.108.100
MYSQL_PASS=yfk123456
#keystone IP
KEYSTONE_IP=192.168.108.101
#glance镜像IP
GLANCE_IP=192.168.108.102
#nova-api,nova-scheduler,nova-conductor,nova-novncproxy
NOVA_IP=192.168.108.102
#neutron 服务网络IP地址
NEUTRON_IP=192.168.108.104
#cinder 块存储IP
CINDER_SERVICE_IP=192.168.108.102
#cinder nfs 块存储位置
nfs_host=192.168.108.102
cinder_data=/data/cinder_data
Date=$(date +%F-%H-%M)
test -d /opt/repo || echo 没有挂载 yum源目录
test -d /opt/repo || exit 1
if ! $(grep openstack /etc/yum.repos.d/openstack-local.repo >/dev/null);then
echo '[openstack]
name=openstack
baseurl=file:///opt/repo
gpgcheck=0' >> /etc/yum.repos.d/openstack-local.repo
fi
yum repolist openstack
#######################################################------时间主服务器----------##
chrony () {
yum install -y chrony
host_field=$(ifconfig eth0 |grep inet|awk '{print $2}' |sed -r 's#(.*)(\.)(.*)#\1\20/24#g')
if ! $(grep $host_field /etc/chrony.conf >/dev/null );then
echo "allow $host_field" >> /etc/chrony.conf
fi
systemctl restart chronyd.service
}
guest_chrony () {
if ! $(grep $KEYSTONE_IP /etc/chrony.conf >/dev/null );then
sed -i "s#0.centos.pool.ntp.org#$KEYSTONE_IP#g" /etc/chrony.conf
systemctl restart chronyd.service
fi
}
######################################################------basci_Service----------##
basci_Service () {
echo -e "\n 开始安装基础服务 ... \n"
yum install python-openstackclient openstack-selinux openstack-utils.noarch mariadb python-memcached mariadb python2-PyMySQL -y
echo "export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://${KEYSTONE_IP}:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2" > .admin-openrc
chmod 400 .admin-openrc
}
######################################################-------db_mariadb_rabbitmq_memcached---------##
db_mariadb_rabbitmq_memcached () {
echo -e "\n 安装memcached, mariadb数据库,rabbitmq 消息队列服务 ... \n"
#配置时间同步服务
guest_chrony
yum install rabbitmq-server memcached python-memcached mariadb mariadb-server python2-PyMySQL -y
#安装基础服务
basci_Service
if [ -z ${db_pass} ];then
echo "默认使用eth0 网卡"
mem_ip=$(ifconfig eth0 |grep inet|awk '{print $2}')
DB_IP=$(ifconfig eth0 |grep inet|awk '{print $2}')
echo "你的数据库 ip : ${mem_ip}"
else
mem_ip=$DB_IP
DB_IP=$DB_IP
echo "你的数据库 ip : ${mem_IP}"
fi
set_db_pass (){
read -p "如果你设置了mariadb数据库密码,请再次输入密码,如果为空,按回车 ...: " db_pass
if [ -z ${db_pass} ];then
echo "注意----------未设置mariadb 数据库密码"
else
echo "你的mariadb root密码: ${db_pass}"
mysql -uroot -p -e "grant all on *.* to root@'%' identified by ${db_pass} WITH GRANT OPTION;"
fi
}
sed -ri "s#(OPTIONS=\"-l )(.*)(\")#\1$mem_ip\3#" /etc/sysconfig/memcached
cat >stack.cnf<<EOF
[mysqld]
bind-address = $DB_IP
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
EOF
systemctl enable memcached.service rabbitmq-server.service mariadb.service
systemctl start memcached.service rabbitmq-server.service mariadb.service
#创建rabbitmq 用户
rabbitmqctl add_user openstack RABBIT_PASS
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
echo -e "\n mariadb数据库初始化 ... \n"
mysql_secure_installation
confirm=true
while $confirm
do
set_db_pass
read -p "密码确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
confirm=false
else
echo -e "\n 咋了?输错了?再来一次。\n"
fi
done
}
######################################################-------keystone---------##
keystone (){
echo -e "\n 开始安装keystone ... \n"
echo -e "\n 配置时间主服务 chrony ... \n"
sleep 3
chrony
#安装基础服务
basci_Service
yum install mariadb openstack-keystone httpd mod_wsgi -y
mysql -uroot -p${MYSQL_PASS} -h $DB_IP -e "CREATE DATABASE keystone; GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';"
cp /etc/keystone/keystone.conf{,.bak$Date}
grep -Ev '^$|#' /etc/keystone/keystone.conf.bak$Date >/etc/keystone/keystone.conf
openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token ADMIN_TOKEN
openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:KEYSTONE_DBPASS@$DB_IP/keystone
openstack-config --set /etc/keystone/keystone.conf token provider fernet
su -s /bin/sh -c "keystone-manage db_sync" keystone
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
echo "ServerName controller" >>/etc/httpd/conf/httpd.conf
echo 'Listen 5000
Listen 35357
<VirtualHost *:5000>
WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-public
WSGIScriptAlias / /usr/bin/keystone-wsgi-public
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:35357>
WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-admin
WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</Directory>
</VirtualHost>' > /etc/httpd/conf.d/wsgi-keystone.conf
systemctl enable httpd.service
systemctl restart httpd.service
export OS_TOKEN=ADMIN_TOKEN
export OS_URL=http://${KEYSTONE_IP}:35357/v3
export OS_IDENTITY_API_VERSION=3
openstack service create --name keystone --description "OpenStack Identity" identity
openstack endpoint create --region RegionOne identity public http://${KEYSTONE_IP}:5000/v3
openstack endpoint create --region RegionOne identity internal http://${KEYSTONE_IP}:5000/v3
openstack endpoint create --region RegionOne identity admin http://${KEYSTONE_IP}:35357/v3
openstack domain create --description "Default Domain" default
openstack project create --domain default --description "Admin Project" admin
openstack user create --domain default --password ADMIN_PASS admin
openstack role create admin
#关联项目,用户,角色
openstack role add --project admin --user admin admin
openstack project create --domain default --description "Service Project" service
unset OS_TOKEN OS_URL
#加载openstack keystone参数变量
source .admin-openrc
openstack --os-auth-url http://${KEYSTONE_IP}:35357/v3 \
--os-project-domain-name default --os-user-domain-name default \
--os-project-name admin --os-username admin token issue
}
######################################################-------glance---------##
glance() {
echo -e "\n 开始安装glance ... \n"
#如果有问题检查数据库数据是否唯一,select * from keystone.service;
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
mysql -uroot -p${MYSQL_PASS} -h $DB_IP -e "CREATE DATABASE glance;GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';GRANT ALL PRIVILEGES ONglance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';"
openstack user create --domain default --password GLANCE_PASS glance
openstack role add --project service --user glance admin
openstack catalog list |grep glance || openstack service create --name glance --description "OpenStack Image" image
openstack catalog list |grep 9292 |grep public || openstack endpoint create --region RegionOne image public http://${GLANCE_IP}:9292
openstack catalog list |grep 9292 |grep internal || openstack endpoint create --region RegionOne image internal http://${GLANCE_IP}:9292
openstack catalog list |grep 9292 |grep admin || openstack endpoint create --region RegionOne image admin http://${GLANCE_IP}:9292
yum install openstack-glance -y
test -d /data/glance/images || mkdir -p /data/glance/images
chown -R glance.glance /data/glance
#注意修改镜像存储路径
test -f /etc/glance/glance-api.conf.bak || \cp -a /etc/glance/glance-api.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/glance/glance-api.conf.bak$Date >/etc/glance/glance-api.conf
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@${DB_IP}/glance
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /data/glance/images/
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://${KEYSTONE_IP}:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://${KEYSTONE_IP}:35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ${DB_IP}:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
#####
test -f /etc/glance/glance-registry.conf.bak || \cp -a /etc/glance/glance-registry.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/glance/glance-registry.conf.bak$Date > /etc/glance/glance-registry.conf
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@${DB_IP}/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://${KEYSTONE_IP}:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://${KEYSTONE_IP}:35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ${DB_IP}:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
#同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance #忽略警告信息
echo -e "\n 忽略警告信息 \n "
mysql -uroot -B glance -p${MYSQL_PASS} -h $DB_IP -e "show tables;"
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl restart openstack-glance-api.service openstack-glance-registry.service
sleep 5
source .admin-openrc
openstack image list
}
######################################################-------nova---------##
nova_service () {
echo -e "\n 开始安装nova-api,nova-scheduler,nova-conductor,nova-novncproxy ... \n"
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#创建数据库授权
mysql -uroot -p${MYSQL_PASS} -h $DB_IP -e "CREATE DATABASE nova_api;CREATE DATABASE nova;GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';GRANT ALL PRIVILEGESON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';"
#在keystone创建系统用户(glance,nova,neutron)关联角色
openstack user create --domain default --password NOVA_PASS nova
openstack role add --project service --user nova admin
openstack catalog list |grep nova || openstack service create --name nova --description "OpenStack Compute" compute
openstack catalog list |grep 8774 |grep public || openstack endpoint create --region RegionOne compute public http://$NOVA_IP:8774/v2.1/%\(tenant_id\)s
openstack catalog list |grep 8774 |grep internal || openstack endpoint create --region RegionOne compute internal http://$NOVA_IP:8774/v2.1/%\(tenant_id\)s
openstack catalog list |grep 8774 |grep admin || openstack endpoint create --region RegionOne compute admin http://$NOVA_IP:8774/v2.1/%\(tenant_id\)s
yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler -y
test -f /etc/nova/nova.conf.bak || \cp -a /etc/nova/nova.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/nova/nova.conf.bak$Date >/etc/nova/nova.conf
openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip $NOVA_IP
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:NOVA_DBPASS@$DB_IP/nova_api
openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:NOVA_DBPASS@$DB_IP/nova
openstack-config --set /etc/nova/nova.conf glance api_servers http://$GLANCE_IP:9292
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
openstack-config --set /etc/nova/nova.conf vnc vncserver_listen '$my_ip'
openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address '$my_ip'
openstack-config --set /etc/nova/nova.conf memcache_servers $DB_IP:11211
openstack-config --set /etc/nova/nova.conf backend oslo_cache.memcache_pool
openstack-config --set /etc/nova/nova.conf enabled True
openstack-config --set /etc/nova/nova.conf debug_cache_backend True
openstack-config --set /etc/nova/nova.conf neutron url http://$NEUTRON_IP:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password NEUTRON_PASS
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy True
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret METADATA_SECRET
#同步数据库
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage db sync" nova
systemctl enable openstack-nova-api.service \
openstack-nova-consoleauth.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
sleep 5
openstack compute service list
}
######################################################-------compute-vxlan 计算节点---------##
compute_vxlan () {
#配置Linuxbridge代理,注意修改 eth1 IP,主控节点都执行,使用vxlan
#compute_vxlan
#配置时间同步服务
guest_chrony
confirm=true
while $confirm
do
read -p "请输入计算节点的IP(如:1.1.1.1),注意是内网 eth1的IP: " compute_inside_IP
read -p "IP确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
confirm=false
else
echo -e "\n 咋了?输错了?再来一次。\n"
fi
done
#安装vxlan网络插件,配置
yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables ipset -y
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip $compute_inside_IP
}
######################################################-------compute- 计算节点---------##
compute_nova () {
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#安装服务
yum install openstack-nova-compute openstack-utils.noarch lvm2 python-keystone -y
confirm=true
while $confirm
do
read -p "请输入计算节点的IP(如:1.1.1.1),注意是可上外网 eth0 的IP: " compute_IP
read -p "IP确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
confirm=false
else
echo -e "\n 咋了?输错了?再来一次。\n"
fi
done
#配置
test -f /etc/nova/nova.conf.bak || cp /etc/nova/nova.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/nova/nova.conf.bak$Date >/etc/nova/nova.conf
#openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip $compute_IP
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf glance api_servers http://$GLANCE_IP:9292
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/nova/nova.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
openstack-config --set /etc/nova/nova.conf vnc enabled True
openstack-config --set /etc/nova/nova.conf vnc vncserver_listen 0.0.0.0
openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address '$my_ip'
openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://$NOVA_IP:6080/vnc_auto.html
openstack-config --set /etc/nova/nova.conf libvirt cpu_mode none
openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu
#查看是否开启虚拟化的值
if [ $(egrep -c '(vmx|svm)' /proc/cpuinfo |awk '{print $1}') == 0 ] ;then openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu ;fi
#启动
systemctl enable libvirtd.service openstack-nova-compute.service
#systemctl restart libvirtd.service openstack-nova-compute.service
#配置网络
yum install openstack-neutron-linuxbridge ebtables ipset -y
test -f /etc/neutron/neutron.conf.bak || cp /etc/neutron/neutron.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/neutron/neutron.conf.bak$Date >/etc/neutron/neutron.conf
openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password NEUTRON_PASS
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
####linuxbridge_agent
#vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
test -f /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak || cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak$Date}
grep '^[a-Z\[]' /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak$Date >/etc/neutron/plugins/ml2/linuxbridge_agent.ini
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth0
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan False
##### neutron
openstack-config --set /etc/nova/nova.conf neutron url http://$NEUTRON_IP:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password NEUTRON_PASS
#安装vxlan网络插件
#compute_vxlan
#启动
systemctl enable neutron-linuxbridge-agent.service
systemctl stop neutron-linuxbridge-agent.service libvirtd.service openstack-nova-compute.service
systemctl start neutron-linuxbridge-agent.service libvirtd.service openstack-nova-compute.service
sleep 5
neutron agent-list
}
######################################################-------neutron 服务------#####
neutron_service () {
echo -e "\n 开始安装neutron 服务 ... \n"
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#创建数据库授权
mysql -uroot -p${MYSQL_PASS} -h $DB_IP -e "CREATE DATABASE neutron;GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';"
#在keystone创建系统用户(glance,nova,neutron)关联角色
openstack user create --domain default --password NEUTRON_PASS neutron
openstack role add --project service --user neutron admin
#在keystone上创建服务和注册api
openstack catalog list |grep neutron || openstack service create --name neutron --description "OpenStack Networking" network
openstack catalog list |grep 9696 |grep public || openstack endpoint create --region RegionOne network public http://$NEUTRON_IP:9696
openstack catalog list |grep 9696 |grep internal || openstack endpoint create --region RegionOne network internal http://$NEUTRON_IP:9696
openstack catalog list |grep 9696 |grep admin || openstack endpoint create --region RegionOne network admin http://$NEUTRON_IP:9696
yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y
test -f /etc/neutron/neutron.conf.bak || cp /etc/neutron/neutron.conf{,.bak$Date}
grep '^[a-Z\[]' /etc/neutron/neutron.conf.bak$Date >/etc/neutron/neutron.conf
openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins
openstack-config --set /etc/neutron/neutron.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes True
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes True
openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:NEUTRON_DBPASS@$DB_IP/neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password NEUTRON_PASS
openstack-config --set /etc/neutron/neutron.conf nova auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/neutron/neutron.conf nova auth_type password
openstack-config --set /etc/neutron/neutron.conf nova project_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova user_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova region_name RegionOne
openstack-config --set /etc/neutron/neutron.conf nova project_name service
openstack-config --set /etc/neutron/neutron.conf nova username nova
openstack-config --set /etc/neutron/neutron.conf nova password NOVA_PASS
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/neutron/neutron.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
#### /etc/neutron/plugins/ml2/ml2_conf.ini
test -f /etc/neutron/plugins/ml2/ml2_conf.ini.bak || cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak$Date}
grep '^[a-Z\[]' /etc/neutron/plugins/ml2/ml2_conf.ini.bak$Date >/etc/neutron/plugins/ml2/ml2_conf.ini
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset True
#### /etc/neutron/plugins/ml2/linuxbridge_agent.ini
test -f /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak || cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak$Date}
grep '^[a-Z\[]' /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak$Date >/etc/neutron/plugins/ml2/linuxbridge_agent.ini
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth0
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan False
#### /etc/neutron/dhcp_agent.ini
test -f /etc/neutron/dhcp_agent.ini-bak || cp /etc/neutron/dhcp_agent.ini{,.bak$Date}
grep -Ev "^$|#" /etc/neutron/dhcp_agent.ini.bak$Date > /etc/neutron/dhcp_agent.ini
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata True
##/etc/neutron/metadata_agent.ini
test -f /etc/neutron/metadata_agent.ini-bak || cp /etc/neutron/metadata_agent.ini{,.bak$Date}
grep -Ev "^$|#" /etc/neutron/metadata_agent.ini.bak$Date > /etc/neutron/metadata_agent.ini
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_ip $NOVA_IP
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret METADATA_SECRET
#同步数据库
ln -sf /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
systemctl restart neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
#控制节点查看是否正常起来三个服务
sleep 5
neutron agent-list
}
####################################################----- dashboard 管理界面------####
dashboard_horizon () {
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#安装
yum install openstack-dashboard -y
#配置
echo "$KEYSTONE_IP keystone_ip ">> /etc/hosts
echo "$DB_IP db_ip ">> /etc/hosts
test -f /etc/openstack-dashboard/local_settings.bak || cp /etc/openstack-dashboard/local_settings{,.bak}
grep -Ev "^$|#" /etc/openstack-dashboard/local_settings.bak > /etc/openstack-dashboard/local_settings
if ! $(grep 'coding: utf-8' /etc/openstack-dashboard/local_settings >/dev/null );then
sed -i '1i# -*- coding: utf-8 -*-' /etc/openstack-dashboard/local_settings ;fi
sed -ri 's#(OPENSTACK_HOST = )(.*)#\1"keystone_ip"#g' /etc/openstack-dashboard/local_settings
sed -ri "s#(ALLOWED_HOSTS = )(.*)#\1['*', ]#g" /etc/openstack-dashboard/local_settings
sed -i 's#django.core.cache.backends.locmem.LocMemCache#django.core.cache.backends.memcached.MemcachedCache#g' /etc/openstack-dashboard/local_settings
if ! $(grep db_ip:11211 /etc/openstack-dashboard/local_settings >/dev/null );then
local_addr_num=$(grep -wn BACKEND /etc/openstack-dashboard/local_settings |awk -F":" '{print $1}')
sed -i "${local_addr_num}a\ 'LOCATION': 'db_ip:11211'," /etc/openstack-dashboard/local_settings
fi
sed -ri 's#(OPENSTACK_KEYSTONE_DEFAULT_ROLE = )(.*)#\1"user"#g' /etc/openstack-dashboard/local_settings
sed -ri 's#(TIME_ZONE = )(.*)#\1"Asia/Shanghai"#g' /etc/openstack-dashboard/local_settings
#如果您选择网络参数1(公共网络),禁用支持3层网络服务
sed -ri "s#(.*)(enable_router)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_quotas)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_distributed_router)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_ha_router)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_lb)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_firewall)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_vpn)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
sed -ri "s#(.*)(enable_fip_topology_check)(': )(True)(.*)#\1\2\3False\5#g" /etc/openstack-dashboard/local_settings
#开启第三层,vxlan
sed -ri "s#(.*)(enable_router)(': )(False)(.*)#\1\2\3True\5#g" /etc/openstack-dashboard/local_settings
#启用第三版认证api
sed -i 's#:5000/v2.0#:5000/v3#g' /etc/openstack-dashboard/local_settings
#启用对域的支持
if ! $(grep OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT /etc/openstack-dashboard/local_settings >/dev/null);then
echo 'OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True' >> /etc/openstack-dashboard/local_settings
fi
#配置api版本
if ! $(grep OPENSTACK_API_VERSIONS /etc/openstack-dashboard/local_settings >/dev/null);then
cat >>/etc/openstack-dashboard/local_settings<<EOF
OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 2,
}
EOF
fi
#配置python的wsgi
if ! $(grep WSGIApplicationGroup /etc/httpd/conf.d/openstack-dashboard.conf >/dev/null);then
sed -i '3aWSGIApplicationGroup %{GLOBAL}' /etc/httpd/conf.d/openstack-dashboard.conf; fi
#启动
systemctl enable httpd
systemctl restart httpd
#select * from compute_nodes;
nova hypervisor-list
#配置虚拟机密钥,做备用
ssh-keygen -q -N "" -f ~/.ssh/id_rsa
openstack keypair create --public-key ~/.ssh/id_rsa.pub host_dashboard
echo -e "\n 登录地址:http://xxx/dashboard/,域:default ,用户:admin ,密码:ADMIN_PASS"
}
####################################################-----测试创建虚拟机-----#######
test_instance () {
#加载openstack keystone参数变量
source .admin-openrc
#测试启动一个实例
#创建网络(网络名+子网)
neutron net-create --shared --provider:physical_network provider --provider:network_type flat yfk
neutron subnet-create --name sub_test --allocation-pool start=192.168.108.30,end=192.168.108.250 \
--dns-nameserver 223.5.5.5 --gateway 192.168.108.2 \
yfk 192.168.108.0/24
#当ip写错了,删除子网:neutron subnet-delete --name sub_test
#创建云主机的硬件配置方案
openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
openstack flavor list
#创建安全组规则
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22 default
sub_net_id=$(neutron subnet-list |grep sub_test |awk '{print $2}')
#openstack keypair create --public-key ~/.ssh/id_rsa.pub host_dashboard
#创建虚拟机 t1
openstack server create --flavor m1.nano --image cirros \
--nic net-id=$sub_net_id --security-group default \
--key-name host_dashboard t1
#笔记查看虚拟机dashboard url:openstack server list ,openstack console url show t1
}
###################################################----安装cinder块存储 --#####
nfs () {
#配置nfs
nfs_host_field=$(echo $nfs_host |sed -r 's#(.*)(\.)(.*)#\1\20/24#g')
if ! $(grep $nfs_host_field /etc/exports >/dev/null );then
echo "$cinder_data $nfs_host_field(rw,async,no_root_squash,no_all_squash)" >> /etc/exports
fi
systemctl restart rpcbind && sleep 1 && systemctl restart nfs
}
###################################################----配置cinder 块存储 --#####
cinder_service () {
echo -e "\n 开始安装cinder 块存储 ... \n"
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#创建数据库授权
mysql -uroot -p${MYSQL_PASS} -h $DB_IP -e "CREATE DATABASE cinder;GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';GRANT ALL PRIVILEGES ONcinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';"
openstack user create --domain default --password CINDER_PASS cinder
openstack role add --project service --user cinder admin
#在keystone上创建服务和注册api
openstack service create --name cinder --description "OpenStack Block Storage" volume
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack endpoint create --region RegionOne volume public http://$CINDER_SERVICE_IP:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume internal http://$CINDER_SERVICE_IP:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volume admin http://$CINDER_SERVICE_IP:8776/v1/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 public http://$CINDER_SERVICE_IP:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://$CINDER_SERVICE_IP:8776/v2/%\(tenant_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://$CINDER_SERVICE_IP:8776/v2/%\(tenant_id\)s
#安装服务相应软件包
yum install openstack-cinder -y
#修改相应服务的配置文件
test -f /etc/cinder/cinder.conf.bak || cp /etc/cinder/cinder.conf{,.bak$Date}
grep -Ev '^$|#' /etc/cinder/cinder.conf.bak$Date >/etc/cinder/cinder.conf
openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip $CINDER_SERVICE_IP
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@$DB_IP/cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password CINDER_PASS
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
#同步数据库
su -s /bin/sh -c "cinder-manage db sync" cinder
ps -ef|egrep [n]ova-api || echo -e "\n 请 手动在安装nova-api 服务器执行命令 \n "
ps -ef|egrep [n]ova-api || echo 'openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne'
ps -ef|egrep [n]ova-api || echo -e "systemctl restart openstack-nova-api.service \n"
ps -ef|egrep [n]ova-api && openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
ps -ef|egrep [n]ova-api && systemctl restart openstack-nova-api.service
#启动服务
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
}
cinder_service_volume () {
#配置时间同步服务
guest_chrony
#安装基础服务
basci_Service
#加载openstack keystone参数变量
source .admin-openrc
#安装服务
yum install openstack-cinder targetcli python-keystone nfs-utils -y
confirm=true
while $confirm
do
read -p "请输入计算节点的IP(如:1.1.1.1),注意是可上外网 eth0 的IP: " compute_IP
read -p "IP确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
confirm=false
else
echo -e "\n 咋了?输错了?再来一次。\n"
fi
done
#修改相应服务的配置文件
test -f /etc/cinder/cinder.conf.bak || cp /etc/cinder/cinder.conf{,.bak$Date}
grep -Ev '^$|#' /etc/cinder/cinder.conf.bak$Date >/etc/cinder/cinder.conf
openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip $compute_IP
openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers = http://$GLANCE_IP:9292
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@$DB_IP/cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://$KEYSTONE_IP:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://$KEYSTONE_IP:35357
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers $DB_IP:11211
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password CINDER_PASS
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_host $DB_IP
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password RABBIT_PASS
if ! $(grep $cinder_data /etc/cinder/nfs_path_info >/dev/null);then
echo "$nfs_host:$cinder_data" >> /etc/cinder/nfs_path_info
fi
#配置nfs 卷存储
openstack-config --set /etc/cinder/cinder.conf nfs volume_driver cinder.volume.drivers.nfs.NfsDriver
openstack-config --set /etc/cinder/cinder.conf nfs nfs_shares_config /etc/cinder/nfs_path_info
openstack-config --set /etc/cinder/cinder.conf nfs volume_backend_name nfs
if ! $(openstack-config --get /etc/cinder/cinder.conf DEFAULT enabled_backends >/dev/null);then
openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends nfs
else
old_arg=$(grep enabled_backends /etc/cinder/cinder.conf)
grep enabled_backends /etc/cinder/cinder.conf |grep nfs || sed -i "s#$old_arg#$old_arg,nfs#g" /etc/cinder/cinder.conf
fi
systemctl restart openstack-cinder-volume.service
}
###################################################----配置neutron-vxlan网络 --#####
neutron_vxlan () {
echo '#网卡模板,网卡设备 eth1
TYPE=Ethernet
BOOTPROTO=none
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.0.11
PREFIX=24'
#配置时间同步服务
guest_chrony
echo -e "\n 手动起网卡命令: ifconfig eth1 172.16.0.11/24 up"
echo -e "\n 千万不要重启网卡,否则 reboot 吧!!! \n "
read -p "IP确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
else
echo -e "\n 咋了?不确定?\n"
exit 1
fi
confirm=true
while $confirm
do
read -p "请输入 neutron 安装节点的IP(如:1.1.1.1),注意是内网 eth1 的IP: " neutron_IP
read -p "IP确认,继续只能按 y 确认..." confir
if [ x"$confir" == x'y' ];then
echo '请继续。。。'
confirm=false
else
echo -e "\n 咋了?输错了?再来一次。\n"
fi
done
#ml2插件
cp -a /etc/neutron/neutron.conf{,.bak$(date +%F-%H-%M)}
openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:NEUTRON_DBPASS@$DB_IP/neutron
openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips True
cp -a /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak$(date +%F-%H-%M)}
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:10000
#file:///E:/%E4%BA%91%E8%AE%A1%E7%AE%97/openstack%E8%B5%84%E6%96%99%E5%8C%85/openstack-manuals_html/html/neutron-controller-install-option2.html
cp -a /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak$(date +%F-%H-%M)}
#配置Linuxbridge代理,主控节点都执行,宿主机同外网网卡eth0
#openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth0
#配置Linuxbridge代理,注意修改 eth1 IP,主控节点都执行
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population True
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip $neutron_IP
#Layer-3代理
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.BridgeInterfaceDriver
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge
systemctl restart neutron-l3-agent.service
systemctl enable neutron-l3-agent.service
systemctl restart neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
echo '请去计算节点执行函数: compute_vxlan'
}
#basci_Service
#----组件服务
#db_mariadb_rabbitmq_memcached
#keystone
#glance
#nova_service
#neutron_service
######-----计算服务
#compute_nova
######-----dashboard页面
#dashboard_horizon
#####----vxlan网络插件
#neutron_vxlan
#compute_vxlan
#####-----cinder 块存储
#cinder_service
#cinder_service_volume
#test_instance
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
# 创建指定类型的卷(nfs)
可以在创建卷的时候,指定数据在什么卷里,如stat 盘,ssd盘
- 创建卷类型
- 添加卷键值对
- 创建指定类型的卷
# vxlan 网络
- 示例图
# 创建网络
创建两个网络,其中一个为外网IP,另一个为内网IP ,以下示例为内网IP
- 创建网络
- 创建子网,这个是内网IP
- 配置子网分配IP
# 配置路由器
创建前先修改能上外网的网络为 外部网络
- 添加路由器
- 添加路由接口
- 网络拓扑图
# 启动实例
- 选择刚刚创建的内网段
- 关联浮动IP
添加浮动IP
分配浮动IP
关联浮动IP
查看
网络拓扑图
# 个人存储下载地址。。。
openstack train 版本部署脚本
openstack zed 版本部署脚本
1
2
2
//
如果此文章对您有帮助,点击 -->> 请博主喝咖啡 (opens new window)
上次更新: 2024/06/18, 14:42:35