How to Install and Configure OpenStack Neutron

In this tutorial, How to Install and Configure OpenStack Neutron. This example chooses the ML2 plugin. In previous, My post has How to install OpenStack all in one Centos 7If you have not yet installed OpenStack Neutron then step install as below

Step 1: Create a User and Database for OpenStack Neutron

First, set up a database in MariaDB for Neutron:

[root@DevopsRoles ~]# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE neutron_ml2;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron_ml2.* TO 'neutron'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron_ml2.* TO 'neutron'@'%' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 2: Add User and Service for Neutron in Keystone

Create a user, assign a role, and configure endpoints for Neutron in Keystone:

# Create the Neutron user
[root@DevopsRoles ~]# openstack user create --domain default --project service --password servicepassword neutron

# Assign the admin role to Neutron
[root@DevopsRoles ~]# openstack role add --project service --user neutron admin

# Register the Neutron service
[root@DevopsRoles ~]# openstack service create --name neutron --description "OpenStack Networking service" network

# Define the Keystone host
[root@DevopsRoles ~]# export controller=10.0.2.15

# Create Neutron endpoints
[root@DevopsRoles ~]# openstack endpoint create --region RegionOne network public http://$controller:9696
[root@DevopsRoles ~]# openstack endpoint create --region RegionOne network internal http://$controller:9696
[root@DevopsRoles ~]# openstack endpoint create --region RegionOne network admin http://$controller:9696

Step 3: Install Neutron Services

Install the necessary Neutron components from the Stein repository:

[root@DevopsRoles ~]# yum --enablerepo=centos-openstack-stein,epel -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch

Step 4: Configure Neutron

Edit the Neutron configuration file to set up database and authentication details:

[root@DevopsRoles ~]# mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf_BK
[root@DevopsRoles ~]# vi /etc/neutron/neutron.conf

Add the following:

iniCopy code[DEFAULT]
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
transport_url = rabbit://openstack:password@10.0.2.15

[keystone_authtoken]
www_authenticate_uri = http://10.0.2.15:5000
auth_url = http://10.0.2.15:5000
memcached_servers = 10.0.2.15:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = servicepassword

[database]
connection = mysql+pymysql://neutron:password@10.0.2.15/neutron_ml2

[nova]
auth_url = http://10.0.2.15:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = servicepassword

[oslo_concurrency]
lock_path = $state_path/tmp

Apply permissions:

[root@DevopsRoles ~]# chmod 640 /etc/neutron/neutron.conf
[root@DevopsRoles ~]# chgrp neutron /etc/neutron/neutron.conf

Step 5: Configure Neutron Agents

Update the following files:

    L3 Agent Configuration:

    [DEFAULT]
    interface_driver = openvswitch
    

    DHCP Agent Configuration:

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

    Metadata Agent Configuration:

    [DEFAULT]
    nova_metadata_host = 10.0.2.15
    metadata_proxy_shared_secret = metadata_secret
    memcache_servers = 10.0.2.15:11211
    

    ML2 Plugin Configuration:

    [ml2]
    type_drivers = flat,vlan,gre,vxlan
    tenant_network_types =
    mechanism_drivers = openvswitch
    extension_drivers = port_security

    Step 6: Configure Open vSwitch

    Start and configure Open vSwitch:

    [root@DevopsRoles ~]# systemctl start openvswitch
    [root@DevopsRoles ~]# systemctl enable openvswitch
    [root@DevopsRoles ~]# ovs-vsctl add-br br-int
    [root@DevopsRoles ~]# ovs-vsctl add-br br-ex
    [root@DevopsRoles ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
    

    Step 7: Populate the Neutron Database

    Run the database migration command:

    [root@DevopsRoles ~]# su -s /bin/bash neutron -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head"
    

    Step 8: Start Neutron Services

    Start all required Neutron services:

    [root@DevopsRoles ~]# systemctl start neutron-server neutron-dhcp-agent neutron-l3-agent neutron-metadata-agent neutron-openvswitch-agent
    [root@DevopsRoles ~]# systemctl enable neutron-server neutron-dhcp-agent neutron-l3-agent neutron-metadata-agent neutron-openvswitch-agent
    

    Step 9: Verify Installation

    Check the status of the Neutron agents:

    [root@DevopsRoles ~]# openstack network agent list
    
    How to Install and Configure OpenStack Neutron

    Conclusion

    You have successfully installed and configured OpenStack Neutron. This setup enables robust networking capabilities, allowing your OpenStack environment to support complex networking scenarios.

    About HuuPV

    My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
    View all posts by HuuPV →

    2 thoughts on “How to Install and Configure OpenStack Neutron

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.