安装ntp:
# timedatectl set-timezone Asia/Shanghai
安装时钟同步:
 # yum -y install chrony编辑配置文件指向自己的ntp服务器:
 # vim /etc/chrony.conf
 server keystone iburst启动服务并让服务自启动:
 # systemctl enable chronyd.service
 # systemctl start chronyd.service验证时间同步情况:
 # chronyc sources
 210 Number of sources = 4
 MS Name/IP address Stratum Poll Reach LastRx Last sample
 ===============================================================================
 ^- 119.79-161-57.customer.l> 2 8 377 337 +33ms[ +33ms] +/- 300ms
 ^* time4.aliyun.com 2 9 377 89 +1918us[+1920us] +/- 24ms
 ^+ 120.25.115.19 2 8 377 213 -2585us[-2580us] +/- 28ms
 ^- static-5-103-139-163.ip.> 1 9 377 10 +72ms[ +72ms] +/- 209ms安装openstack客户端:
当使用epel源时最好禁用掉epel更新,避免影响到以后openstack的更新
 # yum -y install yum-versionlock安装Queens release源:
 # yum -y install centos-release-openstack-queens下载并安装RDO存储库RPM以启用OpenStack存储库。
 # yum -y install https://rdoproject.org/repos/rdo-release.rpm在所有节点上更新包:
 # yum -y upgrade安装openstack客户端
 # yum -y install python-openstackclient安装自动管理selinux组件:
 # yum -y install openstack-selinux导入openstack环境变量:
 # vim ~/.admin_openrcexport OS_PROJECT_DOMAIN_NAME=Default
 export OS_USER_DOMAIN_NAME=Default
 export OS_PROJECT_NAME=admin
 export OS_USERNAME=admin
 export OS_PASSWORD=openpasswd
 export OS_AUTH_URL=http://keystone:5000/v3
 export OS_IDENTITY_API_VERSION=3
 export OS_IMAGE_API_VERSION=2# . ~/.admin_openrc
测试环境变量:
 # openstack token issue
 +————+—————————————————————————————————————————————————————————————–+
 | Field | Value |
 +————+—————————————————————————————————————————————————————————————–+
 | expires | 2018-04-07T03:01:58+0000 |
 | id | gAAAAABayCaWFULjyMxhTU_4EY-yeZ-32luR8yJ4z0lz95F7Macs5XQVP9QdAc0-5aOZaPxjMaN6EjeIAvMsugxIz1kVMoD8R0aHWq7b9YtozfC-ICzcWFF39ZxssTf4Mkc6Rmwm1Q2Z9h6jd-CpaKVgLr0bea7yUFEjU00aolO1Be-mmS53Qbo |
 | project_id | 8f7fa8dca6f4422f80fe7e3391204051 |
 | user_id | 55d3ae5d88d7450fbd4ae36e7823dee9 |
 +————+—————————————————————————————————————————————————————————————–+先决条件
 在配置OpenStack Networking(neutron)服务之前,您必须创建数据库,服务凭据和API端点。
 1、创建数据库
 MariaDB [(none)]> CREATE DATABASE neutron;MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron’@’localhost’ \
 IDENTIFIED BY ‘openpasswd’;
 MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron’@’%’ \
 IDENTIFIED BY ‘openpasswd’;2、创建管理员访问命令行凭据
 导入openstack环境变量:
 # vim ~/.admin_openrcexport OS_PROJECT_DOMAIN_NAME=Default
 export OS_USER_DOMAIN_NAME=Default
 export OS_PROJECT_NAME=admin
 export OS_USERNAME=admin
 export OS_PASSWORD=openpasswd
 export OS_AUTH_URL=http://keystone:5000/v3
 export OS_IDENTITY_API_VERSION=3
 export OS_IMAGE_API_VERSION=2# . ~/.admin_openrc
3、创建服务凭据
 创建 neutron 用户密码为cisco:
 # openstack user create –domain default –password-prompt neutron
 User Password:
 Repeat User Password:
 +———————+———————————-+
 | Field | Value |
 +———————+———————————-+
 | domain_id | default |
 | enabled | True |
 | id | 4ad259435d964d68bec13c7da83897ab |
 | name | neutron |
 | options | {} |
 | password_expires_at | None |
 +———————+———————————-+给neutron用户赋予管理权限:
 # openstack role add –project service –user neutron admin创建neutron服务条目:
 # openstack service create –name neutron \
 –description “OpenStack Networking” network
 +————-+———————————-+
 | Field | Value |
 +————-+———————————-+
 | description | OpenStack Networking |
 | enabled | True |
 | id | e2dfc8ab78b2476c98b38b6b5e4881a1 |
 | name | neutron |
 | type | network |
 +————-+———————————-+
 4、创建网络服务访问点
 # openstack endpoint create –region RegionOne \
 network public http://neutron:9696
 +————–+———————————-+
 | Field | Value |
 +————–+———————————-+
 | enabled | True |
 | id | a4270cf69b68459b9d55b2befef48252 |
 | interface | public |
 | region | RegionOne |
 | region_id | RegionOne |
 | service_id | e2dfc8ab78b2476c98b38b6b5e4881a1 |
 | service_name | neutron |
 | service_type | network |
 | url | http://neutron:9696 |
 +————–+———————————-+# openstack endpoint create –region RegionOne \
 network internal http://neutron:9696
 +————–+———————————-+
 | Field | Value |
 +————–+———————————-+
 | enabled | True |
 | id | 8039d4c6778243d6a468e8848eb605a4 |
 | interface | internal |
 | region | RegionOne |
 | region_id | RegionOne |
 | service_id | e2dfc8ab78b2476c98b38b6b5e4881a1 |
 | service_name | neutron |
 | service_type | network |
 | url | http://neutron:9696 |
 +————–+———————————-+
 # openstack endpoint create –region RegionOne \
 network admin http://neutron:9696
 +————–+———————————-+
 | Field | Value |
 +————–+———————————-+
 | enabled | True |
 | id | 71357e1e4af6405d98f749166035054d |
 | interface | admin |
 | region | RegionOne |
 | region_id | RegionOne |
 | service_id | e2dfc8ab78b2476c98b38b6b5e4881a1 |
 | service_name | neutron |
 | service_type | network |
 | url | http://nova:9696 |
 +————–+———————————-+
 配置自助服务网络:
 在控制器节点上安装并配置网络组件。安装组件
 # yum install openstack-neutron openstack-neutron-ml2 \
 openstack-neutron-linuxbridge ebtables编辑nova配置文件:
 # vim /etc/neutron/neutron.conf
 1、In the [database] section, configure database access:
 [database]
 # …
 connection = mysql+pymysql://neutron:openpasswd@mariadb/neutron
 用您为数据库选择的密码替换NEUTRON_DBPASS。2、在[DEFAULT]部分中,启用Modular Layer 2(ML2)插件,路由器服务和overlapping IP addresses:
 [DEFAULT]
 # …
 core_plugin = ml2
 service_plugins = router
 allow_overlapping_ips = true3、在[DEFAULT]部分,配置RabbitMQ消息队列访问:
 [DEFAULT]
 # …
 transport_url = rabbit://openstack:RABBIT_PASS@controller
 transport_url = rabbit://openstack:openpasswd@nova
 4、在[DEFAULT]和[keystone_authtoken]部分中,配置Identity service 访问:
 [DEFAULT]
 # …
 auth_strategy = keystone[keystone_authtoken]
 # …
 auth_uri = http://keystone:5000
 auth_url = http://keystone:35357
 auth_type = password
 project_domain_name = default
 user_domain_name = default
 project_name = service
 username = neutron
 password = cisco5、在[DEFAULT]和[nova]部分中,配置网络以通知计算网络拓扑更改:
 [DEFAULT]
 # …
 notify_nova_on_port_status_changes = true
 notify_nova_on_port_data_changes = true[nova]
 # …
 auth_url = http://keystone:35357
 auth_type = password
 project_domain_name = default
 user_domain_name = default
 region_name = RegionOne
 project_name = service
 username = nova
 password = cisco6、在[oslo_concurrency]部分中,配置应用锁路径:
 [oslo_concurrency]
 # …
 lock_path = /var/lib/nova/tmp
 配置模块 Layer 2 (ML2) plug-in
 1、编辑 the /etc/neutron/plugins/ml2/ml2_conf.ini 文件(1)在[ml2]部分中,启用flat,VLAN和VXLAN网络:
 [ml2]
 # …
 type_drivers = flat,vlan,vxlan
 (2)在[ml2] 部分, 启用 VXLAN self-service networks:[ml2]
 # …
 tenant_network_types = vxlan
 (3)在 [ml2] 部分中, 启用 the Linux bridge 与 layer-2 population mechanisms:[ml2]
 # …
 mechanism_drivers = linuxbridge,l2population配置ML2插件后,删除type_drivers选项中的值可能会导致数据库不一致
(4) [ml2] 部分中, 启用端口安全扩展驱动程序:
[ml2]
 # …
 extension_drivers = port_security
 (5)[ml2_type_flat] 部分,将提供者虚拟网络配置为扁平网络:[ml2_type_flat]
 # …
 flat_networks = provider(6)[ml2_type_vxlan] 部分,为自助服务网络配置VXLAN网络标识符范围:
[ml2_type_vxlan]
 # …
 vni_ranges = 1:1000(7)[securitygroup] 部分,启用ipset提高安全组规则的效率:
[securitygroup]
 # …
 enable_ipset = true
 Configure the Linux bridge agent
 Linux网桥代理为实例构建第2层(桥接和交换)虚拟网络基础结构并处理安全组。编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件并完成以下操作:
(1)在[linux_bridge]部分中,将提供者虚拟网络映射到提供者物理网络接口:
 [linux_bridge]
 physical_interface_mappings = provider:ens34provider不属于 某个tenant,为各tenant提供通信承载服务的
(2)在[vxlan]部分中,启用VXLAN覆盖网络,配置处理覆盖网络的物理网络接口的IP地址,并启用第2层填充:
 [vxlan]
 enable_vxlan = true
 local_ip = 172.16.1.7
 l2_population = true将OVERLAY_INTERFACE_IP_ADDRESS替换为处理覆盖网络的底层物理网络接口的IP地址。 示例体系结构使用管理接口将流量发送到其他节点。 因此,将OVERLAY_INTERFACE_IP_ADDRESS替换为控制器节点的管理IP地址
(3)在[securitygroup]部分中,启用安全组并配置Linux网桥iptables防火墙驱动程序:
 [securitygroup]
 # …
 enable_security_group = true
 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
 Configure the layer-3 agent
 编辑 the /etc/neutron/l3_agent.ini[DEFAULT]
 # …
 interface_driver = linuxbridgeConfigure the DHCP agent
 DHCP代理为虚拟网络提供DHCP服务。
 编辑/etc/neutron/dhcp_agent.ini文件并完成以下操作:
 在[DEFAULT]部分中,配置Linux网桥接口驱动程序,Dnsmasq DHCP驱动程序,并启用隔离的元数据,以便提供商网络上的实例可以通过网络访问元数据:[DEFAULT]
 # …
 interface_driver = linuxbridge
 dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
 enable_isolated_metadata = trueConfigure the metadata agent
 元数据代理为实例提供配置信息,例如凭据。
 编辑/etc/neutron/metadata_agent.ini文件并完成以下操作:
 在[DEFAULT]部分中,配置元数据主机和共享密钥:
 [DEFAULT]
 # …
 nova_metadata_ip = nova
 metadata_proxy_shared_secret = METADATA_SECRET在nova节点上配置:
 配置Compute服务以使用网络服务
 编辑/etc/nova/nova.conf文件并执行以下操作:在[neutron]部分中,配置访问参数,启用元数据代理并配置密钥:
 [neutron]
 # …
 url = http://neutron:9696
 auth_url = http://keystone:35357
 auth_type = password
 project_domain_name = default
 user_domain_name = default
 region_name = RegionOne
 project_name = service
 username = neutron
 password = cisco
 service_metadata_proxy = true
 metadata_proxy_shared_secret = METADATA_SECRET
 完成安装
 网络服务初始化脚本需要一个指向ML2插件配置文件/etc/neutron/plugins/ml2/ml2_conf.ini的符号链接/etc/neutron/plugin.ini。 如果此符号链接不存在,请使用以下命令创建它:# ln -sv /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” neutronRestart the Compute API service:
# systemctl restart openstack-nova-api.service
 Start the Networking services and configure them to start when the system boots.For both networking options:
# systemctl enable neutron-server.service \
 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
 neutron-metadata-agent.service
 # systemctl start neutron-server.service \
 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
 neutron-metadata-agent.service
 For networking option 2, also enable and start the layer-3 service:# systemctl enable neutron-l3-agent.service
 # systemctl start neutron-l3-agent.service