OpenStack 学习笔记:OpenStack neutron服务搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack 学习笔记:OpenStack neutron服务搭建相关的知识,希望对你有一定的参考价值。


——先决条件


1.)创建数据库

MariaDB [(none)]> CREATE DATABASE neutron;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘localhost‘ IDENTIFIED BY ‘neutron‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘%‘ IDENTIFIED BY ‘neutron‘;
Query OK, 0 rows affected (0.00 sec)

2.)Create the neutron user

[[email protected] ~]# openstack user create --domain default --password neutron_passwd neutron 
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 0b741c2e67ed4d618fa7e963325221ad |
| enabled   | True                             |
| id        | b6865118c01c4c3e8e9958e4ce1500ac |
| name      | neutron                          |
+-----------+----------------------------------+

3.)Add the admin role to the neutron user

[[email protected] ~]# openstack role add --project service --user neutron admin

4.)Create the neutron service entity

[[email protected] ~]# openstack service create --name neutron --description "OpenStack Networking" network
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Networking             |
| enabled     | True                             |
| id          | 2e7acf6189e24db6ba3899ec386f3740 |
| name        | neutron                          |
| type        | network                          |
+-------------+----------------------------------+

5.)Create the Networking service API endpoints

[[email protected] ~]# openstack endpoint create --region RegionOne network public http://192.168.100.120:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | caa517449be64a2fb5d7706484862da0 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2e7acf6189e24db6ba3899ec386f3740 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://192.168.100.120:9696      |
+--------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne network internal http://192.168.100.120:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | dcdcbfa94ddd427ab9e7ade919e0e12a |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2e7acf6189e24db6ba3899ec386f3740 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://192.168.100.120:9696      |
+--------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne network admin http://192.168.100.120:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 75d36bd9c18647a28229ba1e9c78c802 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2e7acf6189e24db6ba3899ec386f3740 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://192.168.100.120:9696      |
+--------------+----------------------------------+


——控制节点neutron服务搭建配置


6.)安装neutron服务

[
[email protected] ~]# yum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables

7.)配置neutron服务

7.1)配置neutron.conf

[[email protected] ~]# cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
[[email protected] ~]# vim /etc/neutron/neutron.conf
   1: [DEFAULT]
  27: auth_strategy = keystone
  30: core_plugin = ml2
  33: service_plugins = router
 121: allow_overlapping_ips = True
 137: notify_nova_on_port_status_changes = true
 141: notify_nova_on_port_data_changes = true
 348: debug = true
 516: rpc_backend = rabbit
 658: [database]
 689: connection = mysql://neutron:[email protected]:3306/neutron
 766: [keystone_authtoken]
 767: auth_uri = http://192.168.100.120:5000
 768: auth_url = http://192.168.100.120:35357
 769: memcached_servers = 192.168.100.120:11211
 770: auth_type = password
 771: project_domain_name = default
 772: user_domain_name = default
 773: project_name = service
 774: username = neutron
 775: password = neutron_passwd
 943: [nova]
 944: auth_url = http://192.168.100.120:35357
 945: auth_type = password
 946: project_domain_name = default
 947: user_domain_name = default
 948: region_name = RegionOne
 949: project_name = service
 950: username = nova
 951: password = nova_passwd
1065: lock_path = $state_path/lock
1161: [oslo_messaging_rabbit]
1216: rabbit_host = 192.168.100.120
1222: rabbit_port = 5672
1234: rabbit_userid = openstack
1238: rabbit_password = 11111111

7.2)配置ML2

[[email protected] ~]# cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
[[email protected] ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
  1: [DEFAULT]
  9: debug = true
127: [linux_bridge]
138: physical_interface_mappings = provider:eth0
144: [securitygroup]
151: firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
156: enable_security_group = true
163: [vxlan]
171: enable_vxlan = true
188: local_ip = 192.168.100.120
192:l2_population = true

7.4)配置Layer-3(L3)agent

[[email protected] ~]# cp /etc/neutron/l3_agent.ini  /etc/neutron/l3_agent.ini.bak
[[email protected] ~]# vim /etc/neutron/l3_agent.ini
  1: [DEFAULT]
 23: interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
107: external_network_bridge = 
159: debug = true

7.5)配置dhcp agent

[[email protected] ~]# cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
[[email protected] ~]# vim /etc/neutron/dhcp_agent.ini
  1: [DEFAULT]
 23: interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
 39: dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
 48: enable_isolated_metadata = true
111: debug = true

7.6)配置metadata agent

[[email protected] ~]# cp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
[[email protected] ~]# vim /etc/neutron/metadata_agent.ini
 1: [DEFAULT]
22: nova_metadata_ip = 192.168.100.120
34: metadata_proxy_shared_secret = metadata_select
76: debug = true

7.7)配置nova

[[email protected] ~]# vim /etc/nova/nova.conf 
4136: [neutron]
4137: url = http://192.168.100.120:9696
4138: auth_url = http://192.168.100.120:35357
4139: auth_type = password
4140: project_domain_name = default
4141: user_domain_name = default
4142: region_name = RegionOne
4143: project_name = service
4144: username = neutron
4145: password = neutron_passwd
4153: service_metadata_proxy=true
4156: metadata_proxy_shared_secret = metadata_select

8.)Finalize installation

[[email protected] ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
[[email protected] ~]# neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head

9.) Restart the Compute API service

[[email protected] ~]# systemctl restart openstack-nova-api.service
[[email protected] ~]# systemctl status openstack-nova-api.service

10.) Start the Networking services

[[email protected] ~]# systemctl enable neutron-server.service  neutron-linuxbridge-agent.service neutron-dhcp-agent.service  neutron-metadata-agent.service
[[email protected] ~]# systemctl start neutron-server.service   neutron-linuxbridge-agent.service neutron-dhcp-agent.service  neutron-metadata-agent.service
[[email protected] ~]# systemctl status neutron-server.service  neutron-linuxbridge-agent.service neutron-dhcp-agent.service  neutron-metadata-agent.service

10.1) Start the layer-3 service

[[email protected] ~]# systemctl enable neutron-l3-agent.service
[[email protected] ~]# systemctl start  neutron-l3-agent.service
[[email protected] ~]# systemctl status neutron-l3-agent.service


——计算节点neutron服务搭建配置


1.) 安装neutron服务

[[email protected] ~]# yum -y install openstack-neutron-linuxbridge ebtables ipset

2.) 配置neutron服务

2.1)配置neutron

[[email protected] ~]# cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
[[email protected] ~]# vim /etc/neutron/neutron.conf
   1: [DEFAULT]
   9: state_path = /var/lib/neutron
  27: auth_strategy = keystone
 348: debug = true
 516: rpc_backend = rabbit
 766: [keystone_authtoken]
 767: auth_uri = http://192.168.100.120:5000
 768: auth_url = http://192.168.100.120:35357
 769: memcached_servers = 192.168.100.120:11211
 770: auth_type = password
 771: project_domain_name = default
 772: user_domain_name = default
 773: project_name = service
 774: username = neutron
 775: password = neutron_passwd
1057: lock_path = $state_path/lock
1153: [oslo_messaging_rabbit]
1208: rabbit_host = 192.168.100.120
1214: rabbit_port = 5672
1226: rabbit_userid = openstack
1230: rabbit_password = 11111111

2.2)配置bridge agent

[[email protected] ~]# cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
[[email protected] ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
  1: [DEFAULT]
  9: debug = true
127: [linux_bridge]
138: physical_interface_mappings = provider:eth0
144: [securitygroup]
151: firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
156: enable_security_group = true
163: [vxlan]
171: enable_vxlan = true
188: local_ip = 192.168.100.121
192: l2_population = true

2.3)配置nova

[[email protected] ~]# vim /etc/nova/nova.conf
4136: [neutron]
4137: url = http://192.168.100.120:9696
4138: auth_url = http://192.168.100.120:35357
4139: auth_type = password
4140: project_domain_name = default
4141: user_domain_name = default
4142: region_name = RegionOne
4143: project_name = service
4144: username = neutron
4145: password = neutron_passwd

3.)restart nova-compute service

[[email protected] ~]# systemctl restart openstack-nova-compute.service
[[email protected] ~]# systemctl status  openstack-nova-compute.service

4.)start bridge agent service

[[email protected] ~]# systemctl enable neutron-linuxbridge-agent.service
[[email protected] ~]# systemctl start neutron-linuxbridge-agent.service
[[email protected] ~]# systemctl status neutron-linuxbridge-agent.service

5.)在控制节点校验操作

[[email protected] ~]# . admin-openrc
[[email protected] ~]# neutron ext-list
+---------------------------+-----------------------------------------------+
| alias                     | name                                          |
+---------------------------+-----------------------------------------------+
| default-subnetpools       | Default Subnetpools                           |
| network-ip-availability   | Network IP Availability                       |
| network_availability_zone | Network Availability Zone                     |
| auto-allocated-topology   | Auto Allocated Topology Services              |
| ext-gw-mode               | Neutron L3 Configurable external gateway mode |
| binding                   | Port Binding                                  |
| agent                     | agent                                         |
| subnet_allocation         | Subnet Allocation                             |
| l3_agent_scheduler        | L3 Agent Scheduler                            |
| tag                       | Tag support                                   |
| external-net              | Neutron external network                      |
| net-mtu                   | Network MTU                                   |
| availability_zone         | Availability Zone                             |
| quotas                    | Quota management support                      |
| l3-ha                     | HA Router extension                           |
| provider                  | Provider Network                              |
| multi-provider            | Multi Provider Network                        |
| address-scope             | Address scope                                 |
| extraroute                | Neutron Extra Route                           |
| timestamp_core            | Time Stamp Fields addition for core resources |
| router                    | Neutron L3 Router                             |
| extra_dhcp_opt            | Neutron Extra DHCP opts                       |
| dns-integration           | DNS Integration                               |
| security-group            | security-group                                |
| dhcp_agent_scheduler      | DHCP Agent Scheduler                          |
| router_availability_zone  | Router Availability Zone                      |
| rbac-policies             | RBAC Policies                                 |
| standard-attr-description | standard-attr-description                     |
| port-security             | Port Security                                 |
| allowed-address-pairs     | Allowed Address Pairs                         |
| dvr                       | Distributed Virtual Router                    |
+---------------------------+-----------------------------------------------+
[[email protected] ~]# neutron agent-list
+--------------------------------------+--------------------+--------------------+-------------------+-------+----------------+---------------------------+
| id                                   | agent_type         | host               | availability_zone | alive | admin_state_up | binary                    |
+--------------------------------------+--------------------+--------------------+-------------------+-------+----------------+---------------------------+
| 0ab75503-266e-41e6-938f-8660c1c581c8 | L3 agent           | openstack          | nova              | :-)   | True           | neutron-l3-agent          |
| 13ff8a61-1f8b-4bd7-b560-54f9011f0660 | DHCP agent         | openstack          | nova              | :-)   | True           | neutron-dhcp-agent        |
| 5eba5556-f85a-4e55-9166-0fd90d43e571 | Metadata agent     | openstack          |                   | :-)   | True           | neutron-metadata-agent    |
| 7b0e1dd7-79d2-415a-a09a-c50f5f9adb72 | Linux bridge agent | openstack          |                   | :-)   | True           | neutron-linuxbridge-agent |
| c014cb9e-de89-4b74-910a-7eba75a57507 | Linux bridge agent | OpenStack-Computee |                   | :-)   | True           | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+--------------------+-------------------+-------+----------------+---------------------------+

本文出自 “命运.” 博客,请务必保留此出处http://hypocritical.blog.51cto.com/3388028/1789264

以上是关于OpenStack 学习笔记:OpenStack neutron服务搭建的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack开发学习笔记03————创建一个openstack

openstack学习笔记一 虚拟机启动过程代码跟踪

OpenStack 学习笔记:OpenStack neutron服务搭建

OpenStack 学习笔记:OpenStack nova服务搭建

学习OpenStack Mitaka单节点部署笔记

OpenStack学习笔记----安装虚拟化工具