乐趣区

关于openstack:OpenStackStein控制和网络节点合一部署

留神:运行 shell,应用 ”source xx.sh or . xx.sh”,不要应用 ”bash xx.sh”

set environment variables

echo "#Add by Ly">>/etc/profile
echo "export CONTROLLER_IP=172.36.214.11">>/etc/profile
echo "export CTRL_HOST_NAME=stein-ctrl">>/etc/profile
echo "export ALL_PASS=123456">>/etc/profile

source /etc/profile

B_setup_base_env.sh

set -e -x

yum install -y net-tools
yum install -y expect
yum install -y tcpdump
yum install -y python-pip
yum install -y tree

echo "$CONTROLLER_IP  $CTRL_HOST_NAME" >>/etc/hosts

systemctl stop firewalld
systemctl disable firewalld

sleep 2

cp /etc/selinux/config /etc/selinux/config.bak
sed -i "/SELINUX=enforcing/cSELINUX=disabled" /etc/selinux/config
setenforce 0

cp /etc/chrony.conf /etc/chrony.conf.bak
sed -i "/server 0.centos.pool.ntp.org iburst/cserver 10.165.7.181 iburst" /etc/chrony.conf
sed -i "/centos.pool.ntp.org/d" /etc/chrony.conf
systemctl enable chronyd
systemctl restart chronyd
systemctl status chronyd
sleep 2

chronyc sources
timedatectl set-timezone Asia/Shanghai
sleep 5

#by your diy

C_setup_base_soft_about_ctrl_stein.sh

set -e -x

echo "The time now is : $CURDATE"
sleep 3

yum install centos-release-openstack-stein -y
yum install python-openstackclient -y
yum install openstack-selinux -y

yum install -y mariadb
yum install -y mariadb-server
yum install -y python2-PyMySQL

touch /etc/my.cnf.d/openstack.cnf
echo "[mysqld]" >>/etc/my.cnf.d/openstack.cnf
echo "bind-address = $CONTROLLER_IP" >>/etc/my.cnf.d/openstack.cnf
echo "" >>/etc/my.cnf.d/openstack.cnf
echo "default-storage-engine = innodb" >>/etc/my.cnf.d/openstack.cnf
echo "innodb_file_per_table = on" >>/etc/my.cnf.d/openstack.cnf
echo "max_connections = 4096" >>/etc/my.cnf.d/openstack.cnf
echo "collation-server = utf8_general_ci" >>/etc/my.cnf.d/openstack.cnf
echo "character-set-server = utf8" >>/etc/my.cnf.d/openstack.cnf

systemctl enable mariadb.service
systemctl start mariadb.service
systemctl status mariadb.service

sleep 2

mysql_secure_installation <<EOF

y
$ALL_PASS
$ALL_PASS
y
y
y
y
EOF


#Message queue
yum install rabbitmq-server -y
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
systemctl status rabbitmq-server.service
sleep 2

rabbitmqctl add_user openstack $ALL_PASS
rabbitmqctl set_permissions openstack ".*" ".*" ".*"

#Memcached
yum install memcached python-memcached -y
cp /etc/sysconfig/memcached /etc/sysconfig/memcached.bak
sed -i "/OPTIONS=\"-l 127.0.0.1,::1\"/cOPTIONS=\"-l 127.0.0.1,::1,$CONTROLLER_IP\""  /etc/sysconfig/memcached
systemctl enable memcached.service
systemctl start memcached.service
systemctl status memcached.service
sleep 2

#ETCD
yum install etcd -y
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
sed -i '/ETCD_DATA_DIR/cETCD_DATA_DIR="/var/lib/etcd/default.etcd"' /etc/etcd/etcd.conf
sed -i "/ETCD_LISTEN_PEER_URLS/cETCD_LISTEN_PEER_URLS=\"http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.conf
sed -i "/ETCD_LISTEN_CLIENT_URLS/cETCD_LISTEN_CLIENT_URLS=\"http://$CONTROLLER_IP:2379\"" /etc/etcd/etcd.conf
sed -i "/ETCD_NAME/cETCD_NAME=\"$CON_HOST_NAME\"" /etc/etcd/etcd.conf
sed -i "/ETCD_INITIAL_ADVERTISE_PEER_URLS/cETCD_INITIAL_ADVERTISE_PEER_URLS=\"http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.conf
sed -i "/ETCD_ADVERTISE_CLIENT_URLS/cETCD_ADVERTISE_CLIENT_URLS=\"http://$CONTROLLER_IP:2379\"" /etc/etcd/etcd.conf
sed -i "/ETCD_INITIAL_CLUSTER=/cETCD_INITIAL_CLUSTER=\"$CON_HOST_NAME=http://$CONTROLLER_IP:2380\"" /etc/etcd/etcd.conf
sed -i '/ETCD_INITIAL_CLUSTER_TOKEN/cETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"' /etc/etcd/etcd.conf
sed -i '/ETCD_INITIAL_CLUSTER_STATE/cETCD_INITIAL_CLUSTER_STATE="new"' /etc/etcd/etcd.conf
systemctl enable etcd
systemctl start etcd
systemctl status etcd
sleep 2

D_setup_keystone_about_ctrl_stein.sh

set -e -x
yum install openstack-keystone -y
yum install httpd -y
yum install mod_wsgi -y

mysql -N -uroot -p$ALL_PASS<<EOF
DROP DATABASE if exists keystone;
CREATE DATABASE if not exists keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '$ALL_PASS';
EOF

#yum install openstack-keystone -y
#yum install httpd -y
#yum install mod_wsgi -y

cp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak
#[database]
sed -i "/#connection = <None>/aconnection = mysql+pymysql://keystone:$ALL_PASS@$CONTROLLER_IP/keystone" /etc/keystone/keystone.conf
#[token]
sed -i '/provider =/aprovider = fernet' /etc/keystone/keystone.conf

#Populate the Identity service database
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 $ALL_PASS \
  --bootstrap-admin-url http://$CONTROLLER_IP:5000/v3/ \
  --bootstrap-internal-url http://$CONTROLLER_IP:5000/v3/ \
  --bootstrap-public-url http://$CONTROLLER_IP:5000/v3/ \
  --bootstrap-region-id RegionOne

#ServerName
sed -i "/#ServerName/aServerName $CONTROLLER_IP" /etc/httpd/conf/httpd.conf

#Creating a soft link
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

systemctl enable httpd.service
systemctl start httpd.service
systemctl status httpd.service

#Configure the administrative account
export OS_USERNAME=admin
export OS_PASSWORD=$ALL_PASS
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3
export OS_IDENTITY_API_VERSION=3

#Create a domain, projects, users, and roles
openstack domain create --description "An Example Domain" example
openstack project create --domain default --description "Service Project" service
openstack project create --domain default --description "Demo Project" myproject

/usr/bin/expect << EOF
set timeout 15
spawn openstack user create --domain default --password-prompt myuser
expect "User*"
send "$ALL_PASS\r"
expect "Repeat *"
send "$ALL_PASS\r"
expect eof
EOF

openstack role create myrole
openstack role add --project myproject --user myuser myrole

unset OS_AUTH_URL OS_PASSWORD
/usr/bin/expect << EOF
set timeout 15
spawn openstack --os-auth-url http://$CONTROLLER_IP:5000/v3 \
  --os-project-domain-name Default --os-user-domain-name Default \
  --os-project-name admin --os-username admin token issue
expect "*Password*"
send "$ALL_PASS\r"
expect eof
EOF

/usr/bin/expect << EOF
set timeout 15
spawn openstack --os-auth-url http://controller:5000/v3 \
  --os-project-domain-name Default --os-user-domain-name Default \
  --os-project-name myproject --os-username myuser token issue
expect "*Password*"
send "$ALL_PASS\r"
expect eof
EOF

#Creating admin-openrc
touch /root/admin-openrc
echo "export OS_PROJECT_DOMAIN_NAME=Default" >/root/admin-openrc
echo "export OS_USER_DOMAIN_NAME=Default" >>/root/admin-openrc
echo "export OS_PROJECT_NAME=admin" >>/root/admin-openrc
echo "export OS_USERNAME=admin" >>/root/admin-openrc
echo "export OS_PASSWORD=$ALL_PASS" >>/root/admin-openrc
echo "export OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3" >>/root/admin-openrc
echo "export OS_IDENTITY_API_VERSION=3" >>/root/admin-openrc
echo "export OS_IMAGE_API_VERSION=2" >>/root/admin-openrc

#Creating demo-openrc
touch /root/demo-openrc
echo "export OS_PROJECT_DOMAIN_NAME=Default" >/root/demo-openrc
echo "export OS_USER_DOMAIN_NAME=Default" >>/root/demo-openrc
echo "export OS_PROJECT_NAME=myproject" >>/root/demo-openrc
echo "export OS_USERNAME=myuser" >>/root/demo-openrc
echo "export OS_PASSWORD=$ALL_PASS" >>/root/demo-openrc
echo "export OS_AUTH_URL=http://$CONTROLLER_IP:5000/v3" >>/root/demo-openrc
echo "export OS_IDENTITY_API_VERSION=3" >>/root/demo-openrc
echo "export OS_IMAGE_API_VERSION=2" >>/root/demo-openrc

source  /root/admin-openrc
openstack token issue
sleep 2

E_setup_image_about_ctrl_stein.sh

set -e -x

#Database operations: glance
mysql -N -uroot -p$ALL_PASS<<EOF
DROP DATABASE if exists glance;
CREATE DATABASE if not exists glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '$ALL_PASS';
EOF

source /root/admin-openrc

/usr/bin/expect << EOF
set timeout 15
spawn openstack user create --domain default --password-prompt glance
expect "User*"
send "$ALL_PASS\r"
expect "Repeat*"
send "$ALL_PASS\r"
expect eof
EOF

openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image" image

openstack endpoint create --region RegionOne image public http://$CONTROLLER_IP:9292
openstack endpoint create --region RegionOne image internal http://$CONTROLLER_IP:9292
openstack endpoint create --region RegionOne image admin http://$CONTROLLER_IP:9292

yum install openstack-glance -y

cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
#[database]
sed -i "/#connection =/aconnection = mysql+pymysql://glance:$ALL_PASS@$CONTROLLER_IP/glance" /etc/glance/glance-api.conf
#[keystone_authtoken]
sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/ausername = glance" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/glance/glance-api.conf
sed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/glance/glance-api.conf
#[paste_deploy]
sed -i "/flavor = keystone/cflavor = keystone" /etc/glance/glance-api.conf
#[glance_store]
sed -i "/\[glance_store]$/afilesystem_store_datadir = /var/lib/glance/images/" /etc/glance/glance-api.conf
sed -i "/\[glance_store]$/adefault_store = file" /etc/glance/glance-api.conf
sed -i "/\[glance_store]$/astores = file,http" /etc/glance/glance-api.conf
#备份 glance-registry.conf
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
#[database]
sed -i "/#connection = <None>/aconnection = mysql+pymysql://glance:$ALL_PASS@$CONTROLLER_IP/glance" /etc/glance/glance-registry.conf
#[keystone_authtoken]
sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/ausername = glance" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/glance/glance-registry.conf
sed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/glance/glance-registry.conf
#[paste_deploy]
sed -i "/flavor = keystone/cflavor = keystone" /etc/glance/glance-registry.conf
#Populate the Image service database
su -s /bin/sh -c "glance-manage db_sync" glance
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

F_setup_placement_about_ctrl_stein.sh

set -x -e
#
mysql -N -uroot -p$ALL_PASS<<EOF
CREATE DATABASE placement;
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY '$ALL_PASS';
EOF

source /root/admin-openrc
/usr/bin/expect << EOF
set timeout 15
spawn openstack user create --domain default --password-prompt placement
expect "User*"
send "$ALL_PASS\r"
expect "Repeat*"
send "$ALL_PASS\r"
expect eof
EOF

openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement

openstack endpoint create --region RegionOne placement public http://$CONTROLLER_IP:8778
openstack endpoint create --region RegionOne placement internal http://$CONTROLLER_IP:8778
openstack endpoint create --region RegionOne placement admin http://$CONTROLLER_IP:8778

yum install openstack-placement-api -y
#
cp /etc/placement/placement.conf /etc/placement/placement.conf.bak
#[placement_database]
sed -i "/\[placement_database]$/aconnection = mysql+pymysql://placement:$ALL_PASS@$CONTROLLER_IP/placement" /etc/placement/placement.conf
#[api]
sed -i "/\[api]$/aauth_strategy = keystone" /etc/placement/placement.conf
#[keystone_authtoken]
sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/ausername = placement" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/placement/placement.conf
sed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000/v3" /etc/placement/placement.conf

su -s /bin/sh -c "placement-manage db sync" placement

systemctl restart httpd

#verify installation
source /root/admin-openrc
placement-status upgrade check
#install osc-placement
mkdir /root/.pip
touch /root/.pip/pip.conf
echo "[global]" >/root/.pip/pip.conf
echo "index-url=http://10.153.3.130/pypi/web/simple" >>/root/.pip/pip.conf
echo "" >>/root/.pip/pip.conf
echo "[install]" >>/root/.pip/pip.conf
echo "trusted-host=10.153.3.130" >>/root/.pip/pip.conf
pip install osc-placement

sed -i "/<\/VirtualHost>/i\ \ <Directory \/usr\/bin>" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ <IfVersion >= 2.4>" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Require all granted" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ <\/IfVersion>" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ <IfVersion < 2.4>" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Order allow,deny" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ \ \ \ \ Allow from all" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ \ \ <\/IfVersion>" /etc/httpd/conf.d/00-placement-api.conf
sed -i "/<\/VirtualHost>/i\ \ <\/Directory>" /etc/httpd/conf.d/00-placement-api.conf

systemctl restart httpd
systemctl status httpd

openstack --os-placement-api-version 1.2 resource class list --sort-column name
openstack --os-placement-api-version 1.6 trait list --sort-column name

G_setup_nova_about_ctrl_stein.sh

set -x -e
#
mysql -N -uroot -p$ALL_PASS<<EOF
DROP DATABASE if exists nova_api;
CREATE DATABASE if not exists nova_api;
DROP DATABASE if exists nova;
CREATE DATABASE if not exists nova;
DROP DATABASE if exists nova_cell0;
CREATE DATABASE if not exists nova_cell0;
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY '$ALL_PASS';
EOF

source /root/admin-openrc
/usr/bin/expect << EOF
set timeout 15
spawn openstack user create --domain default --password-prompt nova
expect "User*"
send "$ALL_PASS\r"
expect "Repeat*"
send "$ALL_PASS\r"
expect eof
EOF

openstack role add --project service --user nova admin
openstack service create --name nova --description "OpenStack Compute" compute

openstack endpoint create --region RegionOne compute public http://$CONTROLLER_IP:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://$CONTROLLER_IP:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://$CONTROLLER_IP:8774/v2.1

yum install -y openstack-nova-api
yum install -y openstack-nova-conductor
yum install -y openstack-nova-novncproxy
yum install -y openstack-nova-scheduler

cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
#[DEFAULT]
sed -i "/\[DEFAULT]$/afirewall_driver = nova.virt.firewall.NoopFirewallDriver" /etc/nova/nova.conf
sed -i "/\[DEFAULT]$/ause_neutron = True" /etc/nova/nova.conf
sed -i "/\[DEFAULT]$/amy_ip = $CONTROLLER_IP" /etc/nova/nova.conf
sed -i "/\[DEFAULT]$/atransport_url = rabbit://openstack:$ALL_PASS@$CONTROLLER_IP" /etc/nova/nova.conf
sed -i "/\[DEFAULT]$/aenabled_apis = osapi_compute,metadata" /etc/nova/nova.conf
#[api_database]
sed -i "/\[api_database]$/aconnection = mysql+pymysql://nova:$ALL_PASS@$CONTROLLER_IP/nova_api" /etc/nova/nova.conf
#[database]
sed -i "/\[database]$/aconnection = mysql+pymysql://nova:$ALL_PASS@$CONTROLLER_IP/nova" /etc/nova/nova.conf
#[api]
sed -i "/\[api]$/aauth_strategy = keystone" /etc/nova/nova.conf
#[keystone_authtoken]
sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/ausername = nova" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/nova/nova.conf
sed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/nova/nova.conf
#[vnc]
sed -i "/\[vnc]$/aserver_proxyclient_address = \$my_ip" /etc/nova/nova.conf
sed -i "/\[vnc]$/aserver_listen = \$my_ip" /etc/nova/nova.conf
sed -i "/\[vnc]$/aenabled = true" /etc/nova/nova.conf
#[glance]
sed -i "/\[glance]$/aapi_servers = http://$CONTROLLER_IP:9292" /etc/nova/nova.conf
#[oslo_concurrency]
sed -i "/\[oslo_concurrency]$/alock_path = /var/lib/nova/tmp" /etc/nova/nova.conf
#[placement]
sed -i "/\[placement]$/apassword = $ALL_PASS" /etc/nova/nova.conf
sed -i "/\[placement]$/ausername = placement" /etc/nova/nova.conf
sed -i "/\[placement]$/aauth_url = http://$CONTROLLER_IP:5000/v3" /etc/nova/nova.conf
sed -i "/\[placement]$/auser_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[placement]$/aauth_type = password" /etc/nova/nova.conf
sed -i "/\[placement]$/aproject_name = service" /etc/nova/nova.conf
sed -i "/\[placement]$/aproject_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[placement]$/aos_region_name = RegionOne" /etc/nova/nova.conf

su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
su -s /bin/sh -c "nova-manage db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova

systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
sleep 3

#Verify operation
source /root/admin-openrc
openstack compute service list
sleep 1
openstack catalog list
sleep 1
openstack image list
sleep 1
nova-status upgrade check
sleep 4

H_setup_neutron_about_ctrl_stein.sh

set -e -x
#
mysql -N -uroot -p$ALL_PASS<<EOF
DROP DATABASE if exists neutron;
CREATE DATABASE if not exists neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY '$ALL_PASS';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY '$ALL_PASS';
EOF

source /root/admin-openrc

/usr/bin/expect << EOF
spawn openstack user create --domain default --password-prompt neutron
expect "User*"
send "$ALL_PASS\r"
expect "Repeat*"
send "$ALL_PASS\r"
expect eof
EOF

openstack role add --project service --user neutron admin
openstack service create --name neutron --description "OpenStack Networking" network

openstack endpoint create --region RegionOne network public http://$CONTROLLER_IP:9696
openstack endpoint create --region RegionOne network internal http://$CONTROLLER_IP:9696
openstack endpoint create --region RegionOne network admin http://$CONTROLLER_IP:9696

yum install -y openstack-neutron
yum install -y openstack-neutron-ml2
yum install -y openstack-neutron-openvswitch
yum install -y ebtables

#/etc/neutron/neutron.conf
cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
#[database]
sed -i "/\[database]$/aconnection = mysql+pymysql://neutron:$ALL_PASS@$CONTROLLER_IP/neutron" /etc/neutron/neutron.conf
#[DEFAULT]
sed -i "/\[DEFAULT]$/anotify_nova_on_port_data_changes = true" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/anotify_nova_on_port_status_changes = true" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/aauth_strategy = keystone" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/atransport_url = rabbit://openstack:$ALL_PASS@$CONTROLLER_IP" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/aallow_overlapping_ips = true" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/aservice_plugins = router" /etc/neutron/neutron.conf
sed -i "/\[DEFAULT]$/acore_plugin = ml2" /etc/neutron/neutron.conf
#[keystone_authtoken]
sed -i "/\[keystone_authtoken]$/apassword = $ALL_PASS" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/ausername = neutron" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/aproject_name = service" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/auser_domain_name = Default" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/aproject_domain_name = Default" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/aauth_type = password" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/amemcached_servers = $CONTROLLER_IP:11211" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.conf
sed -i "/\[keystone_authtoken]$/awww_authenticate_uri = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.conf
#[nova]
sed -i "/\[nova]$/apassword = $ALL_PASS" /etc/neutron/neutron.conf
sed -i "/\[nova]$/ausername = nova" /etc/neutron/neutron.conf
sed -i "/\[nova]$/aproject_name = service" /etc/neutron/neutron.conf
sed -i "/\[nova]$/aregion_name = RegionOne" /etc/neutron/neutron.conf
sed -i "/\[nova]$/auser_domain_name = Default" /etc/neutron/neutron.conf
sed -i "/\[nova]$/aproject_domain_name = Default" /etc/neutron/neutron.conf
sed -i "/\[nova]$/aauth_type = password" /etc/neutron/neutron.conf
sed -i "/\[nova]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/neutron/neutron.conf
#[oslo_concurrency]
sed -i "/\[oslo_concurrency]$/alock_path = /var/lib/neutron/tmp" /etc/neutron/neutron.conf
cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak
#[ml2]
sed -i "/\[ml2]$/aextension_drivers = port_security" /etc/neutron/plugins/ml2/ml2_conf.ini
sed -i "/\[ml2]$/amechanism_drivers = openvswitch,l2population" /etc/neutron/plugins/ml2/ml2_conf.ini
sed -i "/\[ml2]$/atenant_network_types = vxlan,vlan" /etc/neutron/plugins/ml2/ml2_conf.ini
sed -i "/\[ml2]$/atype_drivers = flat,vlan,vxlan" /etc/neutron/plugins/ml2/ml2_conf.ini
#[ml2_type_flat]
sed -i "/\[ml2_type_flat]$/aflat_networks = provider" /etc/neutron/plugins/ml2/ml2_conf.ini
#[ml2_type_vlan]
sed -i "/\[ml2_type_vlan]$/anetwork_vlan_ranges = physicnet:1000:2000" /etc/neutron/plugins/ml2/ml2_conf.ini
#[ml2_type_vxlan]
sed -i "/\[ml2_type_vxlan]$/avni_ranges = 30000:31000" /etc/neutron/plugins/ml2/ml2_conf.ini
#[securitygroup]
sed -i "/\[securitygroup]$/aenable_ipset = true" /etc/neutron/plugins/ml2/ml2_conf.ini

#/etc/neutron/plugins/ml2/openvswitch_agent.ini
cp /etc/neutron/plugins/ml2/openvswitch_agent.ini /etc/neutron/plugins/ml2/openvswitch_agent.ini.bak
#[agent]
#sed -i "/tunnel_types = /atunnel_types = vxlan" /etc/neutron/plugins/ml2/openvswitch_agent.ini
#[ovs]
#sed -i "/\[ovs]$/alocal_ip = 10.214.1.2" /etc/neutron/plugins/ml2/openvswitch_agent.ini
#sed -i "/\[ovs]$/atun_peer_patch_port = patch-int" /etc/neutron/plugins/ml2/openvswitch_agent.ini
#sed -i "/\[ovs]$/aint_peer_patch_port = patch-tun" /etc/neutron/plugins/ml2/openvswitch_agent.ini
#sed -i "/\[ovs]$/atunnel_bridge = br-tun" /etc/neutron/plugins/ml2/openvswitch_agent.ini
#[securitygroup]
sed -i "/\[securitygroup]$/aenable_security_group = true" /etc/neutron/plugins/ml2/openvswitch_agent.ini
sed -i "/\[securitygroup]$/afirewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver" /etc/neutron/plugins/ml2/openvswitch_agent.ini

cp /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.bak
sed -i "/\[DEFAULT]$/ainterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver" /etc/neutron/l3_agent.ini

cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
sed -i "/\[DEFAULT]$/aenable_isolated_metadata = true" /etc/neutron/l3_agent.ini
sed -i "/\[DEFAULT]$/adhcp_driver = neutron.agent.linux.dhcp.Dnsmasq" /etc/neutron/dhcp_agent.ini
sed -i "/\[DEFAULT]$/ainterface_driver = neutron.agent.linux.interface.OVSInterfaceDriver" /etc/neutron/dhcp_agent.ini
sed -i "/force_metadata = /aforce_metadata = true" /etc/neutron/dhcp_agent.ini

cp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
sed -i "/\[DEFAULT]$/ametadata_proxy_shared_secret = $ALL_PASS" /etc/neutron/metadata_agent.ini
sed -i "/\[DEFAULT]$/anova_metadata_host = $CONTROLLER_IP" /etc/neutron/metadata_agent.ini
#Edit /etc/nova/nova.conf file and perform the fllowing actions
sed -i "/\[neutron]$/ametadata_proxy_shared_secret = $ALL_PASS" /etc/nova/nova.conf
sed -i "/\[neutron]$/aservice_metadata_proxy = true" /etc/nova/nova.conf
sed -i "/\[neutron]$/apassword = $ALL_PASS" /etc/nova/nova.conf
sed -i "/\[neutron]$/ausername = neutron" /etc/nova/nova.conf
sed -i "/\[neutron]$/aproject_name = service" /etc/nova/nova.conf
sed -i "/\[neutron]$/aregion_name = RegionOne" /etc/nova/nova.conf
sed -i "/\[neutron]$/auser_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[neutron]$/aproject_domain_name = Default" /etc/nova/nova.conf
sed -i "/\[neutron]$/aauth_type = password" /etc/nova/nova.conf
sed -i "/\[neutron]$/aauth_url = http://$CONTROLLER_IP:5000" /etc/nova/nova.conf
sed -i "/\[neutron]$/aurl = http://$CONTROLLER_IP:9696" /etc/nova/nova.conf

ln -s /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 restart openstack-nova-api.service

systemctl enable neutron-server.service \
  neutron-openvswitch-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service neutron-l3-agent.service
systemctl start neutron-server.service \
  neutron-openvswitch-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service neutron-l3-agent.service

sleep 4

I_setup_dashboard_about_ctrl_stein.sh

set -x -e

yum install openstack-dashboard -y
#
#/etc/openstack-dashboard/local_settings
cp /etc/openstack-dashboard/local_settings /etc/openstack-dashboard/local_settings.bak

sed -i "/OPENSTACK_HOST = /cOPENSTACK_HOST = \"$CONTROLLER_IP\"" /etc/openstack-dashboard/local_settings

sed -i "/ALLOWED_HOSTS = /cALLOWED_HOSTS = ['*']" /etc/openstack-dashboard/local_settings
#SESSION_ENGINE = 'django.contrib.sessions.backends.cache' 
#CACHES
sed -i "/^CACHES =/iSESSION_ENGINE ='django.contrib.sessions.backends.cache'" /etc/openstack-dashboard/local_settings
sed -i "/^[\t]*'BACKEND'/a\\ \t'LOCATION':'$CONTROLLER_IP:11211'," /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
#
sed -i "/OPENSTACK_KEYSTONE_URL/cOPENSTACK_KEYSTONE_URL = \"http://%s:5000/v3\"% OPENSTACK_HOST" /etc/openstack-dashboard/local_settings
#
sed -i "/OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True" /etc/openstack-dashboard/local_settings
#OPENSTACK_API_VERSIONS = {
#    "identity": 3,
#    "image": 2,
#    "volume": 2,
#}
sed -i "s/#OPENSTACK_API_VERSIONS/OPENSTACK_API_VERSIONS/g" /etc/openstack-dashboard/local_settings
sed -i "/#    \"identity\": 3,/c\\    \"identity\": 3," /etc/openstack-dashboard/local_settings
sed -i "/#    \"image\": 2,/c\\    \"image\": 2," /etc/openstack-dashboard/local_settings
sed -i "/#    \"volume\": 2,/c\\    \"volume\": 2," /etc/openstack-dashboard/local_settings
sed -i "/#    \"compute\": 2,/a}" /etc/openstack-dashboard/local_settings
#
sed -i "/#OPENSTACK_KEYSTONE_DEFAULT_DOMAIN/cOPENSTACK_KEYSTONE_DEFAULT_DOMAIN = \"Default\"" /etc/openstack-dashboard/local_settings
sed -i "/OPENSTACK_KEYSTONE_DEFAULT_ROLE/cOPENSTACK_KEYSTONE_DEFAULT_ROLE = \"user\"" /etc/openstack-dashboard/local_settings
#OPENSTACK_NEUTRON_NETWORK = {
#    ...
#    'enable_router': False,
#    'enable_quotas': False,
#    'enable_distributed_router': False,
#    'enable_ha_router': False,
#    'enable_lb': False,
#    'enable_firewall': False,
#    'enable_vpn': False,
#    'enable_fip_topology_check': False,
#}
#
#/etc/httpd/conf.d/openstack-dashboard.conf
#cp /etc/httpd/conf.d/openstack-dashboard.conf /etc/httpd/conf.d/openstack-dashboard.conf.bak
sed -i "/WSGIScriptAlias/iWSGIApplicationGroup %{GLOBAL}" /etc/httpd/conf.d/openstack-dashboard.conf
#
systemctl restart httpd.service memcached.service
systemctl status httpd memcached
sleep 3

#Fwaas
yum install openstack-neutron-fwaas -y
neutron-db-manage --subproject neutron-fwaas upgrade head
#lbaasv2
yum install openstack-neutron-lbaas -y
neutron-db-manage --subproject neutron-lbaas upgrade head
#vpnaas
yum install openstack-neutron-vpnaas -y
neutron-db-manage --subproject neutron-vpnaas upgrade head
退出移动版