$ mysql -u root -p
建立nova數據庫:
<pre>CREATE DATABASE neutron;
</pre>python
把neutron數據庫的訪問權限賦予名爲neutron,來自任何主機地址的用戶,並設定訪問密碼爲NEUTRON_DBPASS(替換爲合適的密碼):
<pre>GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';
mysql
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';</pre>linux
退出數據庫。sql
$ source admin-openrc.sh
neutron
用戶:$ keystone user-create --name neutron --pass NEUTRON_PASS
Property | Value |
---|---|
enabled | True |
id | 03fdaa93a85b4879a898d031947b81af |
name | neutron |
username | neutron |
+----------+----------------------------------+</pre>
用合適的密碼代替NEUTRON_PASS。數據庫
把admin
角色賦予給neutron
用戶:$ keystone user-role-add --user neutron --tenant service --role admin
這條命令不產生輸出顯示。json
建立neutron
服務實體:
<pre>$ keystone service-create --name neutron --type network \
api
--description "OpenStack Networking" | |
---|---|
Property | Value |
description | OpenStack Networking |
enabled | True |
id | d3cf8211db414c069701f39e778d9765 |
name | neutron |
type | network |
+-------------+----------------------------------+</pre>網絡
$ keystone endpoint-create \
--service-id $(keystone service-list | awk '/ network / {print $2}') \
--publicurl http://controller:9696 \
--adminurl http://controller:9696 \
--internalurl http://controller:9696 \app
--region regionOne | |
---|---|
Property | Value |
adminurl | http://controller:9696 |
id | eb7fd6b67e4d4479886d164486a3fb71 |
internalurl | http://controller:9696 |
publicurl | http://controller:9696 |
region | regionOne |
service_id | d3cf8211db414c069701f39e778d9765 |
+-------------+----------------------------------+</pre>框架
# apt-get install neutron-server neutron-plugin-ml2 python-neutronclient
編輯# vi /etc/neutron/neutron.conf
文件:
在[database]
部分,設定數據庫的訪問選項,需把原始設定註釋掉:
<pre>[database]
</pre>
...
connection = mysql://neutron:NEUTRON_DBPASS@controller/neutron
NEUTRON_DBPASS爲建立neutron數據庫時設立的密碼。
在[DEFAULT]
部分,設定RabbitMQ的訪問選項:
<pre>[DEFAULT]
</pre>
...
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = RABBIT_PASS
RABBIT_PASS爲RabbitMQ guest帳戶的密碼。
在[DEFAULT]
和[keystone_authtoken]
部分,設定認證服務的訪問選項:
<pre>[DEFAULT]
</pre>
...
auth_strategy = keystone
<pre>[keystone_authtoken]
</pre>
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS
NEUTRON_PASS爲建立neutron用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。
在[DEFAULT]
部分,開啓Modular Layer 2(ML2)plug-in選項,設定router service和overlapping IP addresses選項:
<pre>[DEFAULT]
</pre>
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
在[DEFAULT]
部分,設定網絡服務能夠通知計算服務網絡拓撲的變化:
<pre>[DEFAULT]
</pre>
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://controller:8774/v2
nova_admin_auth_url = http://controller:35357/v2.0
nova_region_name = regionOne
nova_admin_username = nova
nova_admin_tenant_id = SERVICE_TENANT_ID
nova_admin_password = NOVA_PASS
NEUTRON_PASS爲建立neutron用戶時使用的密碼。SERVICE_TENANT_ID爲認證服務中service
租戶的ID,能夠經過如下命令取得:
<pre>$ source admin-openrc.sh
$ keystone tenant-get service | |
---|---|
Property | Value |
description | Service Tenant |
enabled | True |
id | 5ab4d5c513f543cfbf8e3be97f5df5fb |
name | service |
+-------------+----------------------------------+</pre>
在[DEFAULT]
部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
</pre>
...
verbose = True
ML2 plug-in使用Open vSwitch(OVS)機制(agent)來建立虛擬網絡框架。因爲controller節點不處理實例之間的網絡通訊,故不須要OVS組件。
編輯# vi /etc/neutron/plugins/ml2/ml2_conf.ini
文件:
在[ml2]
部分,啓用flat和generic routing encapsulation(GRE)網絡類型的驅動( network type drivers),GRE 租戶網絡和OVS機制的驅動:
<pre>[ml2]
</pre>
...
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
在[ml2_type_gre]
部分,配置tunnel ID的範圍:
<pre>[ml2_type_gre]
</pre>
...
tunnel_id_ranges = 1:1000
在[securitygroup]
部分,啓用security groups,ipset, and configure,設定OVS iptables firewall driver:
<pre>[securitygroup]
</pre>
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
編輯# vi /etc/nova/nova.conf
文件:
在[DEFAULT]
部分,設定API和驅動:
<pre>[DEFAULT]
</pre>
...
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
在[neutron]
部分,設定訪問參數:
<pre>[neutron]
</pre>
...
url = http://controller:9696
auth_strategy = keystone
admin_auth_url = http://controller:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = NEUTRON_PASS
NEUTRON_PASS爲建立neutron用戶時使用的密碼。
# neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno
# service nova-api restart
# service nova-scheduler restart
# service nova-conductor restart
# service neutron-server restart
admin
證書:$ source admin-openrc.sh
$ neutron ext-list
alias | name |
---|---|
security-group | security-group |
l3_agent_scheduler | L3 Agent Scheduler |
ext-gw-mode | Neutron L3 Configurable external gateway mode |
binding | Port Binding |
provider | Provider Network |
agent | agent |
quotas | Quota management support |
dhcp_agent_scheduler | DHCP Agent Scheduler |
l3-ha | HA Router extension |
multi-provider | Multi Provider Network |
external-net | Neutron external network |
router | Neutron L3 Router |
allowed-address-pairs | Allowed Address Pairs |
extraroute | Neutron Extra Route |
extra_dhcp_opt | Neutron Extra DHCP opts |
dvr | Distributed Virtual Router |
+-----------------------+-----------------------------------------------+</pre>
輸入neutron ext-list後,出現「Unable to establish connection to http://controller:9696/v2.0/extensions.json」,最後發現是以前某個service在keystone裏創立時設置的密碼與配置neutron時需寫入的沒對上,致使沒法訪問。