当前位置:   article > 正文

在centos7上安装openstack_centos7搭建 openstack

centos7搭建 openstack

安装环境:

centos7

安装需求:

openstack allinone 安装,因为只有一台服务器192.168.16.13。
只安装openstack必须使用的组件keystone, glacne,nova, neutron,dashboard
参照的链接为:https://www.cnblogs.com/elvi/p/7811528.html

安装步骤:

下载 https://www.cnblogs.com/elvi/p/7811528.html里面的shell 脚本,执行shell 脚本出错,所以采用手动方式安装。
#获取第一块连通的网卡名、ip地址,这个必须注意,如果网卡没接网线,会导致这个openstack组件不能互通。

  1. 192.168.16.13上只有一个网络接口eth2接了网线。
  2. Net="em2" 
  3. IP=`ip add show em2 |grep global|awk -F'[ /]+' '{ print $3 }'|head -n 1`
  4. echo  "网卡名称:$Net"
  5. echo  "IP地址:  $IP"

#参数#

  1. DBPass=elven2017    #SQL root密码
  2. Node=controller     #节点名(controller不要改动)
  3. Netname=$Net        #网卡名称
  4. MyIP=$IP            #IP地址
  5. VncProxy=$IP        #VNC代理外网IP地址
  6. Imgdir=/data/glance #自定义glance镜像目录
  7. VHD=/data/nova      #自定义Nova实例路径
  8. Kvm=qemu            #QEMU或KVM ,KVM需要硬件支持,由于192.168.16.43的bios没有开通kvm,所以只能选择qemu,如果bios开通了kvm支持,填kvm,kvm的性能比qemu全虚拟化好很多

#如果这里填错,创建虚拟机出错。
##########################################
#1、设置

  1. echo  '关闭selinux、防火墙'
  2. systemctl stop firewalld.service
  3. systemctl disable firewalld.service
  4. firewall-cmd --state
  5. sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
  6. sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config
  7. grep --color=auto '^SELINUX' /etc/selinux/config
  8. setenforce 0
  9. echo  '设置hostname'
  10. hostnamectl set-hostname $Node
  11. echo "$MyIP   $Node">>/etc/hosts
  12. #使用阿里源
  13. rm -f /etc/yum.repos.d/*
  14. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  15. curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  16. sed -i '/aliyuncs.com/d' /etc/yum.repos.d/*.repo #删除阿里内网地址#
  17. #'自定义openstack源'
  18. yum install centos-release-openstack-pike -y #安装OpenStack源#
  19. yum clean all && yum makecache #生成缓存
  20. #'时间同步'
  21. [[ -f /usr/sbin/ntpdate ]] || { echo "install ntp";yum install ntp -y &> /dev/null; } #若没NTP则安装
  22. /usr/sbin/ntpdate ntp6.aliyun.com
  23. echo "*/3 * * * * /usr/sbin/ntpdate ntp6.aliyun.com  &> /dev/null" > /tmp/crontab
  24. crontab /tmp/crontab

##########################################
#2 安装

  1. yum install -y ntp wget vim net-tools openssh tree &> /dev/null
  2. echo  'OpenStack tools 安装'
  3. yum install -y python-openstackclient openstack-selinux \
  4.   python2-PyMySQL openstack-utils
  5. echo  'MariaDB安装'
  6. yum install mariadb mariadb-server mariadb-galera-server -y
  7. yum install expect -y
  8. echo  'RabbitMQ安装'
  9. yum install rabbitmq-server erlang socat -y
  10. echo  'Keystone安装'
  11. yum install -y openstack-keystone httpd mod_wsgi memcached python-memcached
  12. yum install apr apr-util -y
  13. echo  '安装Glance'
  14. yum install -y openstack-glance python-glance
  15. echo  '安装nova'
  16. yum install -y openstack-nova-api openstack-nova-conductor \
  17.   openstack-nova-console openstack-nova-novncproxy \
  18.   openstack-nova-scheduler openstack-nova-placement-api \
  19.   openstack-nova-compute
  20. echo  '安装neutron'
  21. yum install -y openstack-neutron openstack-neutron-ml2 \
  22.  openstack-neutron-linuxbridge python-neutronclient ebtables ipset
  23. echo  '安装dashboard'
  24. yum install openstack-dashboard -y

##########################################
#3、配置

  1. # #------------------#####################
  2. echo 'SQL数据库配置'
  3. echo "#
  4. [mysqld]
  5. bind-address = 0.0.0.0
  6. default-storage-engine = innodb
  7. innodb_file_per_table
  8. max_connections = 4096
  9. collation-server = utf8_general_ci
  10. character-set-server = utf8
  11. #">/etc/my.cnf.d/openstack.cnf
  12. echo '启动数据库服务'
  13. systemctl enable mariadb.service
  14. systemctl start mariadb.service
  15. sleep 5
  16. netstat -antp|grep mysqld
  17. #mysql_secure_installation #初始化设置密码,自动交互
  18. [[ -f /usr/bin/expect ]] || { yum install expect -y; } #若没expect则安装
  19. /usr/bin/expect << EOF
  20. set timeout 30
  21. spawn mysql_secure_installation
  22. expect {
  23.     "enter for none" { send "\r"; exp_continue}
  24.     "Y/n" { send "Y\r" ; exp_continue}
  25.     "password:" { send "$DBPass\r"; exp_continue}
  26.     "new password:" { send "$DBPass\r"; exp_continue}
  27.     "Y/n" { send "Y\r" ; exp_continue}
  28.     eof { exit }
  29. }
  30. EOF

#测试

  1. mysql -u root -p$DBPass -e "show databases;"
  2. [ $? = 0 ] || { echo "mariadb初始化失败";exit; }
  3. echo '创建数据库、用户授权'
  4. mysql -u root -p$DBPass -e "
  5. create database keystone;
  6. grant all privileges on keystone.* to 'keystone'@'localhost' identified by 'keystone';
  7. grant all privileges on keystone.* to 'keystone'@'%' identified by 'keystone';
  8. create database glance;
  9. grant all privileges on glance.* to 'glance'@'localhost' identified by 'glance';
  10. grant all privileges on glance.* to 'glance'@'%' identified by 'glance';
  11. create database nova;
  12. grant all privileges on nova.* to 'nova'@'localhost' identified by 'nova';
  13. grant all privileges on nova.* to 'nova'@'%' identified by 'nova';
  14. create database nova_api;
  15. grant all privileges on nova_api.* to 'nova'@'localhost' identified by 'nova';
  16. grant all privileges on nova_api.* to 'nova'@'%' identified by 'nova';
  17. create database nova_cell0;
  18. grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by 'nova';
  19. grant all privileges on nova_cell0.* to 'nova'@'%' identified by 'nova';
  20. create database neutron;
  21. grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'neutron';
  22. grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron';
  23. flush privileges;
  24. select user,host from mysql.user;
  25. show databases;
  26. "
  27. #
  28. # #------------------#####################
  29. echo 'RabbitMQ配置'
  30. echo 'NODENAME=rabbit@controller'>/etc/rabbitmq/rabbitmq-env.conf
  31. systemctl enable rabbitmq-server.service
  32. systemctl start rabbitmq-server.service
  33. sleep 3
  34. rabbitmq-plugins enable rabbitmq_management  #启动web插件端口15672
  35. sleep 6

##########
#rabbit创建用户及密码

  1. rabbitmqctl  add_user admin admin
  2. rabbitmqctl  set_user_tags admin administrator
  3. rabbitmqctl add_user openstack openstack
  4. rabbitmqctl set_permissions openstack ".*" ".*" ".*"
  5. rabbitmqctl  set_user_tags openstack administrator
  6.  >/etc/rabbitmq/rabbitmq-env.conf
  7. systemctl restart rabbitmq-server.service
  8. sleep 3
  9. netstat -antp|grep '5672'
  10. [[ `rabbitmqctl list_users|grep openstack|wc -l` = 1 ]] || {
  11.     echo 'rabbit创建用户失败';
  12.     echo 'rabbit创建用户失败,请手动执行命令创建用户'>>./error.install.log; }

# #------------------#####################
#Keystone
#memcached启动

  1. cp /etc/sysconfig/memcached{,.bak}
  2. systemctl enable memcached.service
  3. systemctl start memcached.service
  4. netstat -antp|grep 11211
  5. echo  'Keystone 配置'
  6. cp /etc/keystone/keystone.conf{,.bak}  #备份默认配置
  7. Keys=$(openssl rand -hex 10)  #生成随机密码
  8. echo $Keys
  9. echo "kestone  $Keys">/root/openstack.log
  10. echo "
  11. [DEFAULT]
  12. admin_token = $Keys
  13. verbose = true
  14. [database]
  15. connection = mysql+pymysql://keystone:keystone@controller/keystone
  16. [token]
  17. provider = fernet
  18. driver = memcache
  19. [memcache]
  20. servers = controller:11211
  21. ">/etc/keystone/keystone.conf

#初始化身份认证服务的数据库

su -s /bin/sh -c "keystone-manage db_sync" keystone

#检查表是否创建成功

mysql -h controller -ukeystone -pkeystone -e "use keystone;show tables;"

#初始化密钥存储库

  1. keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
  2. keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

#设置admin用户(管理用户)和密码

  1. keystone-manage bootstrap --bootstrap-password admin \
  2.   --bootstrap-admin-url http://controller:35357/v3/ \
  3.   --bootstrap-internal-url http://controller:5000/v3/ \
  4.   --bootstrap-public-url http://controller:5000/v3/ \
  5.   --bootstrap-region-id RegionOne

#apache配置

  1. cp /etc/httpd/conf/httpd.conf{,.bak}
  2. echo "ServerName controller">>/etc/httpd/conf/httpd.conf
  3. ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

#Apache HTTP 启动并设置开机自启动

  1. systemctl enable httpd.service
  2. systemctl restart httpd.service
  3. sleep 3
  4. netstat -antp|egrep ':5000|:35357|:80'

#创建 OpenStack 客户端环境脚本
#admin环境脚本

  1. echo "
  2. export OS_PROJECT_DOMAIN_NAME=default
  3. export OS_USER_DOMAIN_NAME=default
  4. export OS_PROJECT_NAME=admin
  5. export OS_USERNAME=admin
  6. export OS_PASSWORD=admin
  7. export OS_AUTH_URL=http://controller:35357/v3
  8. export OS_IDENTITY_API_VERSION=3
  9. export OS_IMAGE_API_VERSION=2
  10. ">./admin-openstack.sh

#测试脚本是否生效

  1. source ./admin-openstack.sh
  2. openstack token issue

#创建service项目,创建glance,nova,neutron用户,并授权

  1. openstack project create --domain default --description "Service Project" service
  2. openstack user create --domain default --password=glance glance
  3. openstack role add --project service --user glance admin
  4. openstack user create --domain default --password=nova nova
  5. openstack role add --project service --user nova admin
  6. openstack user create --domain default --password=neutron neutron
  7. openstack role add --project service --user neutron admin

#创建demo项目(普通用户密码及角色)

  1. openstack project create --domain default --description "Demo Project" demo
  2. openstack user create --domain default --password=demo demo
  3. openstack role create user
  4. openstack role add --project demo --user demo user

#demo环境脚本

  1. echo "
  2. export OS_PROJECT_DOMAIN_NAME=default
  3. export OS_USER_DOMAIN_NAME=default
  4. export OS_PROJECT_NAME=demo
  5. export OS_USERNAME=demo
  6. export OS_PASSWORD=demo
  7. export OS_AUTH_URL=http://controller:5000/v3
  8. export OS_IDENTITY_API_VERSION=3
  9. export OS_IMAGE_API_VERSION=2
  10. ">./demo-openstack.sh

#测试脚本是否生效

  1. source ./demo-openstack.sh
  2. openstack token issue
  3. # #------------------#####################
  4. echo 'Glance镜像服务'

# keystone上服务注册 ,创建glance服务实体,API端点(公有、私有、admin)

  1. source ./admin-openstack.sh || { echo "加载前面设置的admin-openstack.sh环境变量脚本";exit; }
  2. openstack service create --name glance --description "OpenStack Image" image
  3. openstack endpoint create --region RegionOne image public http://controller:9292
  4. openstack endpoint create --region RegionOne image internal http://controller:9292
  5. openstack endpoint create --region RegionOne image admin http://controller:9292
  6. cp /etc/glance/glance-api.conf{,.bak}
  7. cp /etc/glance/glance-registry.conf{,.bak}

# images默认/var/lib/glance/images/
#Imgdir=/data/glance

  1. mkdir -p $Imgdir
  2. chown glance:nobody $Imgdir
  3. echo "镜像目录: $Imgdir"
  4. echo "#
  5. [database]
  6. connection = mysql+pymysql://glance:glance@controller/glance
  7. [keystone_authtoken]
  8. auth_uri = http://controller:5000/v3
  9. auth_url = http://controller:35357/v3
  10. memcached_servers = controller:11211
  11. auth_type = password
  12. project_domain_name = default
  13. user_domain_name = default
  14. project_name = service
  15. username = glance
  16. password = glance
  17. [paste_deploy]
  18. flavor = keystone
  19. [glance_store]
  20. stores = file,http
  21. default_store = file
  22. filesystem_store_datadir = $Imgdir
  23. #">/etc/glance/glance-api.conf
  24. #
  25. echo "#
  26. [database]
  27. connection = mysql+pymysql://glance:glance@controller/glance
  28. [keystone_authtoken]
  29. auth_uri = http://controller:5000/v3
  30. auth_url = http://controller:35357/v3
  31. memcached_servers = controller:11211
  32. auth_type = password
  33. project_domain_name = default
  34. user_domain_name = default
  35. project_name = service
  36. username = glance
  37. password = glance
  38. [paste_deploy]
  39. flavor = keystone
  40. #">/etc/glance/glance-registry.conf

#同步数据库,检查数据库

  1. su -s /bin/sh -c "glance-manage db_sync" glance
  2. mysql -h controller -u glance -pglance -e "use glance;show tables;"

#启动服务并设置开机自启动

  1. systemctl enable openstack-glance-api openstack-glance-registry
  2. systemctl start openstack-glance-api openstack-glance-registry
  3. netstat -antp|egrep '9292|9191' #检测服务端口

# #------------------#####################
#创建Nova数据库、用户、认证,前面已设置

source ./admin-openstack.sh

# keystone上服务注册 ,创建nova用户、服务、API
# nova用户前面已建

  1. openstack service create --name nova --description "OpenStack Compute" compute
  2. openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
  3. openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
  4. openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

#创建placement用户、服务、API

  1. openstack user create --domain default --password=placement placement
  2. openstack role add --project service --user placement admin
  3. openstack service create --name placement --description "Placement API" placement
  4. openstack endpoint create --region RegionOne placement public http://controller:8778
  5. openstack endpoint create --region RegionOne placement internal http://controller:8778
  6. openstack endpoint create --region RegionOne placement admin http://controller:8778
  7. mkdir -p $VHD
  8. chown -R nova:nova $VHD
  9. cp /etc/nova/nova.conf{,.bak}
  10. echo 'nova配置'
  11. echo '#
  12. [DEFAULT]
  13. instances_path='$VHD'
  14. enabled_apis = osapi_compute,metadata
  15. transport_url = rabbit://openstack:openstack@controller
  16. my_ip = '$MyIP'
  17. use_neutron = True
  18. firewall_driver = nova.virt.firewall.NoopFirewallDriver
  19. osapi_compute_listen_port=8774
  20. [api_database]
  21. connection = mysql+pymysql://nova:nova@controller/nova_api
  22. [database]
  23. connection = mysql+pymysql://nova:nova@controller/nova
  24. [api]
  25. auth_strategy = keystone
  26. [keystone_authtoken]
  27. auth_uri = http://controller:5000
  28. auth_url = http://controller:35357
  29. memcached_servers = controller:11211
  30. auth_type = password
  31. project_domain_name = default
  32. user_domain_name = default
  33. project_name = service
  34. username = nova
  35. password = nova
  36. [vnc]
  37. enabled = true
  38. vncserver_listen = $my_ip
  39. vncserver_proxyclient_address = $my_ip
  40. novncproxy_base_url = http://'$VncProxy':6080/vnc_auto.html
  41. [glance]
  42. api_servers = http://controller:9292
  43. [oslo_concurrency]
  44. lock_path = /var/lib/nova/tmp
  45. [placement]
  46. os_region_name = RegionOne
  47. project_domain_name = Default
  48. project_name = service
  49. auth_type = password
  50. user_domain_name = Default
  51. auth_url = http://controller:35357/v3
  52. username = placement
  53. password = placement
  54. [scheduler]
  55. discover_hosts_in_cells_interval = 300
  56. [libvirt]
  57. virt_type = '$Kvm'
  58. #'>/etc/nova/nova.conf
  59. echo "
  60. #Placement API
  61. <Directory /usr/bin>
  62.    <IfVersion >= 2.4>
  63.       Require all granted
  64.    </IfVersion>
  65.    <IfVersion < 2.4>
  66.       Order allow,deny
  67.       Allow from all
  68.    </IfVersion>
  69. </Directory>
  70. ">>/etc/httpd/conf.d/00-nova-placement-api.conf
  71. systemctl restart httpd
  72. sleep 5

#同步数据库

  1. su -s /bin/sh -c "nova-manage api_db sync" nova
  2. su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
  3. su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
  4. su -s /bin/sh -c "nova-manage db sync" nova

#检测数据

  1. nova-manage cell_v2 list_cells
  2. mysql -h controller -u nova -pnova -e "use nova_api;show tables;"
  3. mysql -h controller -u nova -pnova -e "use nova;show tables;"
  4. mysql -h controller -u nova -pnova -e "use nova_cell0;show tables;"
  5. # #------------------#####################
  6. echo 'Neutron服务'
  7. source ./admin-openstack.sh

# 创建Neutron服务实体,API端点

  1. openstack service create --name neutron --description "OpenStack Networking" network
  2. openstack endpoint create --region RegionOne network public http://controller:9696
  3. openstack endpoint create --region RegionOne network internal http://controller:9696
  4. openstack endpoint create --region RegionOne network admin http://controller:9696

#Neutron 备份配置

  1. cp /etc/neutron/neutron.conf{,.bak2}
  2. cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak}
  3. ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
  4. cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak}
  5. cp /etc/neutron/dhcp_agent.ini{,.bak}
  6. cp /etc/neutron/metadata_agent.ini{,.bak}
  7. cp /etc/neutron/l3_agent.ini{,.bak}

#配置

  1. echo '
  2. #
  3. [neutron]
  4. url = http://controller:9696
  5. auth_url = http://controller:35357
  6. auth_type = password
  7. project_domain_name = default
  8. user_domain_name = default
  9. region_name = RegionOne
  10. project_name = service
  11. username = neutron
  12. password = neutron
  13. service_metadata_proxy = true
  14. metadata_proxy_shared_secret = metadata
  15. #'>>/etc/nova/nova.conf
  16. #
  17. echo '
  18. [DEFAULT]
  19. nova_metadata_ip = controller
  20. metadata_proxy_shared_secret = metadata
  21. #'>/etc/neutron/metadata_agent.ini
  22. #
  23. echo '#
  24. [ml2]
  25. tenant_network_types =
  26. type_drivers = vlan,flat
  27. mechanism_drivers = linuxbridge
  28. extension_drivers = port_security
  29. [ml2_type_flat]
  30. flat_networks = provider
  31. [ml2_type_vlan]
  32. network_vlan_ranges = provider:1001:2000
  33. [securitygroup]
  34. enable_ipset = True
  35. #'>/etc/neutron/plugins/ml2/ml2_conf.ini
  36. echo '#
  37. [linux_bridge]
  38. physical_interface_mappings = provider:'$Netname'
  39. [vxlan]
  40. enable_vxlan = false
  41. [securitygroup]
  42. firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
  43. enable_security_group = True
  44. #'>/etc/neutron/plugins/ml2/linuxbridge_agent.ini
  45. #
  46. echo '#
  47. [DEFAULT]
  48. interface_driver = linuxbridge
  49. dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
  50. enable_isolated_metadata = true
  51. #'>/etc/neutron/dhcp_agent.ini
  52. #
  53. echo '
  54. [DEFAULT]
  55. core_plugin = ml2
  56. service_plugins = router
  57. allow_overlapping_ips = true
  58. transport_url = rabbit://openstack:openstack@controller
  59. auth_strategy = keystone
  60. notify_nova_on_port_status_changes = true
  61. notify_nova_on_port_data_changes = true
  62. [keystone_authtoken]
  63. auth_uri = http://controller:5000
  64. auth_url = http://controller:35357
  65. memcached_servers = controller:11211
  66. auth_type = password
  67. project_domain_name = default
  68. user_domain_name = default
  69. project_name = service
  70. username = neutron
  71. password = neutron
  72. [nova]
  73. auth_url = http://controller:35357
  74. auth_type = password
  75. project_domain_id = default
  76. user_domain_id = default
  77. region_name = RegionOne
  78. project_name = service
  79. username = nova
  80. password = nova
  81. [database]
  82. connection = mysql://neutron:neutron@controller:3306/neutron
  83. [oslo_concurrency]
  84. lock_path = /var/lib/neutron/tmp
  85. #'>/etc/neutron/neutron.conf
  86. #
  87. echo '
  88. [DEFAULT]
  89. interface_driver = linuxbridge
  90. #'>/etc/neutron/l3_agent.ini
  91. #

#同步数据库

  1. su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
  2.   --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

#检测数据

  1. mysql -h controller -u neutron -pneutron -e "use neutron;show tables;"
  2. # #------------------#####################
  3. #dashboard
  4. echo '配置openstack Web'
  5. cp /etc/openstack-dashboard/local_settings{,.bak}
  6. Setfiles=/etc/openstack-dashboard/local_settings
  7. sed -i 's#_member_#user#g' $Setfiles
  8. sed -i 's#OPENSTACK_HOST = "127.0.0.1"#OPENSTACK_HOST = "controller"#' $Setfiles

##允许所有主机访问#

sed -i "/ALLOWED_HOSTS/cALLOWED_HOSTS = ['*', ]" $Setfiles

#去掉memcached注释#

  1. sed -in '153,158s/#//' $Setfiles
  2. sed -in '160,164s/.*/#&/' $Setfiles
  3. sed -i 's#UTC#Asia/Shanghai#g' $Setfiles
  4. sed -i 's#%s:5000/v2.0#%s:5000/v3#' $Setfiles
  5. sed -i '/ULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True' $Setfiles
  6. sed -i '/MULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = False' $Setfiles
  7. sed -i "s@^#OPENSTACK_KEYSTONE_DEFAULT@OPENSTACK_KEYSTONE_DEFAULT@" $Setfiles
  8. echo '
  9. #set
  10. OPENSTACK_API_VERSIONS = {
  11.     "identity": 3,
  12.     "image": 2,
  13.     "volume": 2,
  14. }
  15. #'>>$Setfiles

#http配置#

  1. echo '#openstack
  2. <VirtualHost *:80>
  3. #url
  4. RedirectMatch permanent  ^/$ /dashboard
  5. #log
  6. ErrorLog "/var/log/httpd/horizon_error.log"
  7. ServerSignature Off
  8. CustomLog "/var/log/httpd/horizon_access.log" combined
  9. </VirtualHost>
  10. '>/etc/httpd/conf.d/openstack-domain.conf
  11. systemctl restart httpd
  12. sleep 5
  13. ##########################################
  14. echo '启动服务'
  15. #Apache
  16. systemctl enable httpd.service
  17. #netstat -antp|egrep 'httpd'

#glance服务

  1. systemctl enable openstack-glance-api openstack-glance-registry
  2. systemctl restart openstack-glance-api openstack-glance-registry

#nova服务

  1. systemctl enable openstack-nova-api.service \
  2.   openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  3.   openstack-nova-conductor.service openstack-nova-novncproxy.service \
  4.   libvirtd.service openstack-nova-compute.service

#启动

  1. systemctl start openstack-nova-api.service \
  2.   openstack-nova-consoleauth.service openstack-nova-scheduler.service \
  3.   openstack-nova-conductor.service openstack-nova-novncproxy.service \
  4.   libvirtd.service openstack-nova-compute.service

#neutron服务

  1. systemctl enable neutron-server.service \
  2.   neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  3.   neutron-metadata-agent.service neutron-l3-agent.service
  4. systemctl start neutron-server.service \
  5.   neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  6.   neutron-metadata-agent.service neutron-l3-agent.service

##########################################
#登录界面域#

  1. sed -i '/MULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = False' $Setfiles
  2. #cheack
  3. sleep 3
  4. echo "查看节点"
  5. source ./admin-openstack.sh
  6. openstack compute service list
  7. #openstack network agent list

##########################################
##########################################
#可选,创建虚机

  1. source ./admin-openstack.sh
  2. echo ' 创建秘钥'
  3. ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
  4. nova keypair-add --pub-key ~/.ssh/id_dsa.pub mykey
  5. echo ' 创建云主机类型'
  6. openstack flavor create --id 1 --vcpus 1 --ram 512 --disk 5  m1.nano
  7. echo '安全规则'
  8. openstack security group rule create --proto icmp default
  9. openstack security group rule create --proto tcp --dst-port 22 'default'

#本机网段

  1. IPS=`echo $IP|awk -F\. '{ print $1"."$2"."$3 }'`
  2. echo '创建网络'
  3. openstack network create --share --external --provider-physical-network provider --provider-network-type flat lan_$IPS

#创建子网

  1. openstack subnet create --network lan_$IPS --allocation-pool start=$IPS.70,end=$IPS.100 \
  2.  --dns-nameserver 119.29.29.29 --gateway $IPS.1 --subnet-range $IPS.0/24 net_$IPS
  3. echo '下载测试镜像'
  4. echo ''
  5. wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
  6. echo '上传镜像到镜像服务'
  7. openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img \
  8.   --disk-format qcow2 --container-format bare --public
  9. echo '创建虚拟机 VM01'
  10. nova boot --flavor m1.nano --image cirros \
  11.   --nic net-name=lan_$IPS --security-group default --key-name mykey \
  12.   VM06
openstack server list

 

注意:

打开openstack的dashboard出错,显示内部错误。
修改dashboard.conf
在 WSGISocketPrefix run/wsgi后面添加一行

WSGIApplicationGroup %{GLOBAL}

然后dashboard正常。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/983416
推荐阅读
相关标签
  

闽ICP备14008679号