OpenStack Neutron部署(7)

目录

一、创建数据库

二、网络配置

三、配置元数据代理

四、配置计算服务的网络

五、完成配置

六、计算节点配置

七、计算节点配置提供商网络

八、配置计算服务的网络

九、完成安装

十、验证


一、创建数据库

以下操作在控制节点实施

1.创建数据库

①.创建数据库并授予访问权限

②.刷新数据库

[root@controller ~]# mysql -u root -p

MariaDB [(none)]> create database neutron;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
IDENTIFIED BY '123456';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
IDENTIFIED BY '123456';

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> quit
Bye

2.获取admin访问权限以访问OpenStack cli

[root@controller ~]# . admin-openrc.sh

3.创建服务凭据:neutron:密码"123456"

[root@controller ~]# openstack user create --domain default --password-prompt neutron
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 1ad084c66775459bb5239eeaaa0f4615 |
| name                | neutron                          |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

4.将角色neutron添加到admin

[root@controller ~]# openstack role add --project service --user neutron admin

5.创建服务实体

[root@controller ~]# openstack service create --name neutron \
--description "OpenStack Networking" network
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Networking             |
| enabled     | True                             |
| id          | 7dc79be397d24ccab524773edf2eb1aa |
| name        | neutron                          |
| type        | network                          |
+-------------+----------------------------------+

6.创建网络服务API终结点

[root@controller ~]# openstack endpoint create --region RegionOne \
network public http://controller:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 5e611a7e7cde4b7c9648387331a493b0 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 7dc79be397d24ccab524773edf2eb1aa |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://controller:9696           |
+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \
network internal http://controller:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 87fd6923471043588622ea76d43abb9d |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 7dc79be397d24ccab524773edf2eb1aa |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://controller:9696           |
+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \
network admin http://controller:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 86f5a68e5ada4ef8bb088df041464399 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 7dc79be397d24ccab524773edf2eb1aa |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://controller:9696           |
+--------------+----------------------------------+

二、网络配置

我这里选择的是提供商网络

1.安装组件

[root@controller ~]# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y

2.编辑配置文件

①./etc/neutron/neutron.conf

#切换到/etc/neutron/目录,备份配置文件,清除配置文件内的空白和注释符
[root@controller ~]# cd /etc/neutron/ && cp neutron.conf neutron.conf.source && cat neutron.conf.source | grep -Ev "^#|^$" > neutron.conf

[root@controller neutron]# vim neutron.conf

#配置数据库访问
[database]
connection = mysql+pymysql://neutron:123456@controller/neutron


#启用模块化插件、禁用其它插件、配置标识服务访问、配置网络
[DEFAULT]
core_plugin = ml2
service_plugins =
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true


#配置标识服务访问
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = 123456

#配置nova网络的访问
[nova]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = 123456

#配置锁定路径
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp

3.配置模块化2层插件

①.编辑配置文件/etc/neutron/plugins/ml2/ml2_conf.ini

#切换到/etc/neutron/plugins/ml2/目录,备份配置文件,清除配置文件内的空白和注释符
[root@controller ~]# cd /etc/neutron/plugins/ml2/ && cp ml2_conf.ini ml2_conf.ini.source && cat ml2_conf.ini.source | grep -Ev "^#|^$" > ml2_conf.ini

[root@controller ml2]# vim ml2_conf.ini

#启用平面和 VLAN 网络、禁用自助服务网络、禁用自助服务网络、禁用自助服务网络
[ml2]
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security


#将提供者虚拟网络配置为平面网络
[ml2_type_flat]
flat_networks = provider


#启用 ipset 以提高安全组规则的效率
[securitygroup]
enable_ipset = true

4.配置Linux桥代理

[root@controller ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini 

#将提供者虚拟网络映射到提供者物理网络接口
[linux_bridge]
physical_interface_mappings = provider:ens33


#禁用 VXLAN 覆盖网络
[vxlan]
enable_vxlan = false


#启用安全组并配置 Linux 网桥 iptables 防火墙驱动程序
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

5.配置DHCP代理

[root@controller ~]# vim /etc/neutron/dhcp_agent.ini 

[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true

三、配置元数据代理

1.编辑配置文件

/etc/neutron/metadata_agent.ini

[root@controller ~]# vim /etc/neutron/metadata_agent.ini 

#替换为合适的密钥
[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = 123456

四、配置计算服务的网络

1.编辑配置文件

/etc/nova/nova.conf

[root@controller ~]# vim /etc/nova/nova.conf

[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = 123456
service_metadata_proxy = true
metadata_proxy_shared_secret = 123456

五、完成配置

1.配置软链接

2.填充数据库

[root@controller ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
[root@controller ~]# 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

3.重新启动API服务

4.启动网络服务并设置开机自启动

[root@controller ~]# systemctl restart openstack-nova-api.service
[root@controller ~]# systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service

[root@controller ~]# systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-server.service to /usr/lib/systemd/system/neutron-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-linuxbridge-agent.service to /usr/lib/systemd/system/neutron-linuxbridge-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-dhcp-agent.service to /usr/lib/systemd/system/neutron-dhcp-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-metadata-agent.service to /usr/lib/systemd/system/neutron-metadata-agent.service.

六、计算节点配置

以下操作在计算节点实施

1、安装组件

[root@computer ~]# yum install openstack-neutron-linuxbridge ebtables ipset -y

2.配置公共组件

①.备份配置文件,清除配置文件空余部分和注释符部分

②.修改配置文件/etc/neutron/neutron.conf

[root@computer ~]# cd /etc/neutron/ && cp neutron.conf neutron.conf.source && cat neutron.conf.source | grep -Ev "^#|^$" > neutron.conf
[root@computer neutron]# vim neutron.conf

#配置消息队列访问、配置标识符访问
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone


#配置标识符访问
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = 123456


#锁定路径
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp

七、计算节点配置提供商网络

1.配置Linux桥代理

①.备份配置文件,清除配置文件空余部分和注释符部分

②.修改配置文件

[root@computer ~]# cd /etc/neutron/plugins/ml2/ && cp linuxbridge_agent.ini linuxbridge_agent.ini.source && cat linuxbridge_agent.ini.source | grep -Ev "^#|^$" > linuxbridge_agent.ini
[root@computer ml2]# vim linuxbridge_agent.ini

#将提供者虚拟网络映射到提供者物理网络接口
[linux_bridge]
physical_interface_mappings = provider:ens33

#禁用vxlan覆盖网络
[vxlan]
enable_vxlan = false

#启用安全组并配置 Linux 网桥 iptables 防火墙驱动程序
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

八、配置计算服务的网络

1.修改配置文件

/etc/nova/nova.conf

[root@computer ~]# vim /etc/nova/nova.conf

#配置访问参数
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = 123456

九、完成安装

1.重启各项服务

①.重启计算服务

②.启动Linux桥代理服务,并设置开机自启动

[root@computer ~]# systemctl restart openstack-nova-compute.service
[root@computer ~]# systemctl enable neutron-linuxbridge-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-linuxbridge-agent.service to /usr/lib/systemd/system/neutron-linuxbridge-agent.service.

十、验证

1.在控制节点上验证

[root@controller ~]# openstack network agent list
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type         | Host       | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 0325d2ca-98e3-4dc1-a602-deed834e1fdb | Linux bridge agent | controller | None              | :-)   | UP    | neutron-linuxbridge-agent |
| 68ce7f22-ea29-4673-b133-6f764f6904e4 | Linux bridge agent | computer   | None              | :-)   | UP    | neutron-linuxbridge-agent |
| 7d29a137-b6b0-4ca9-a380-1e1849b26471 | DHCP agent         | controller | nova              | :-)   | UP    | neutron-dhcp-agent        |
| 9f6bb7d6-fe73-4fe3-9302-1748ab54f92f | Metadata agent     | controller | None              | :-)   | UP    | neutron-metadata-agent    |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

你可能感兴趣的:(openstack,云计算,运维,linux,数据库)