作者:【吴业亮】
博客:https://wuyeliang.blog.csdn.net/
创建用户
# openstack user create --domain default --project service --password Changeme_123 neutron
赋予neutron用户admin权限
# openstack role add --project service --user neutron admin
创建服务
# openstack service create --name neutron --description "OpenStack Networking service" network
定义controller的管理网IP
# export controller=172.16.8.50
创建endpoint
# openstack endpoint create --region RegionOne network public http://$controller:9696
# openstack endpoint create --region RegionOne network internal http://$controller:9696
# openstack endpoint create --region RegionOne network admin http://$controller:9696
创建数据库和用户
# mysql -u root -pChangeme_123
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 'Changeme_123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on neutron.* to neutron@'%' identified by 'Changeme_123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
安装rpm包
# yum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch
修改配置文件
# mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf.org
# vi /etc/neutron/neutron.conf
[DEFAULT]
bind_host = 172.16.8.60
bind_port = 9696
l3_ha = True
max_l3_agents_per_router = 0
min_l3_agents_per_router = 2
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
dhcp_agent_notification = True
allow_overlapping_ips = True
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
# RabbitMQ connection info
transport_url = rabbit://openstack:Changeme_123@172.16.8.50
# Keystone auth info
[keystone_authtoken]
auth_uri = http://172.16.8.50:5000
auth_url = http://172.16.8.50:35357
memcached_servers = node1:11211,node2:11211,node3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = Changeme_123
# MariaDB connection info
[database]
connection = mysql+pymysql://neutron:Changeme_123@172.16.8.50/neutron
# Nova connection info
[nova]
auth_url = http://172.16.8.50:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = Changeme_123
[oslo_concurrency]
lock_path = $state_path/tmp
赋予权限
# chmod 640 /etc/neutron/neutron.conf
# chgrp neutron /etc/neutron/neutron.conf
修改配置文件
# cp -a /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini_bak
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_host 172.16.8.60
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret Changeme_123
openstack-config --set /etc/neutron/metadata_agent.ini cache memcache_servers node1:11211,node2:11211,node3:11211
注意:修改节点的IP
修改配置文件
# cp -a /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini_bak
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,gre,vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers openvswitch,l2population
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_security_group True
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset True
修改配置文件/etc/nova/nova.conf
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT linuxnet_interface_driver nova.network.linux_net.LinuxOVSInterfaceDriver
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf neutron url http://172.16.8.50:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://172.16.8.50:35357
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password Changeme_123
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy True
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret Changeme_123
创建软连接
# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
同步数据库
# su -s /bin/bash neutron -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head"
启动neutron服务
# systemctl start neutron-server neutron-metadata-agent
# systemctl enable neutron-server neutron-metadata-agent
重启openstack-nova-api
# systemctl restart openstack-nova-api
修改配置文件/etc/neutron/l3_agent.ini
# cp -a /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini_bak
# openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
修改配置文件/etc/neutron/dhcp_agent.ini
# cp -a /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini_bak
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata True
启动服务
# systemctl start openvswitch
# systemctl enable openvswitch
创建网桥
# ovs-vsctl add-br br-int
启动服务并设置开机启动
# for service in dhcp-agent l3-agent metadata-agent openvswitch-agent; do
systemctl restart neutron-$service
systemctl enable neutron-$service
done