OpenStack学习笔记07-网络服务Neutron

OpenStack学习笔记07-网络服务Neutron

根据《云操作系统(OpenStack)》第七章来做的。

一、基本概念

Neutron需要至少配置一个外部网络,可以配置一个或多个内部网络

二、安装并配置控制节点

1. 数据库配置

1-1. 登录MySQL数据库

mysql -uroot -p000000

1-2. 创建neutron数据库

CREATE DATABASE neutron;

1-3. 设置授权用户和密码

GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron123';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'neutron123';
exit

enter description here
enter description here

2. 创建服务凭证和API端点

2-1. 生效admin用户变量

cd /root/
source admin-openrc.sh

2-2. 创建服务凭证

2-2-1. 创建名为neutron的user

设置的密码是neutron123

openstack user create --domain default --password-prompt neutron

enter description here
enter description here

2-2-2. 进行关联

openstack role add --project service --user neutron admin

2-2-3. 创建Neutron服务实体认证

openstack service create --name neutron --description "OpenStack networking" network

enter description here
enter description here

2-3. 创建API端点

创建公共、外部、管理端点

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

enter description here
enter description here

3. 安装并配置Neutron组件

3-1. 安装Neutron组件所需软件包

yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y

enter description here
enter description here

3-2. 配置/etc/neutron/neutron.conf文件

3-2-1. 配置[database]部分,配置数据库连接

[database]
connection=mysql+pymysql://neutron:neutron123@controller/neutron

3-2-2. 编辑[DEFAULT]部分配置模块化ML2插件

[DEFAULT]
core_plugin=ml2
service_plugins=router
allow_overlapping_ips=True

3-2-3. 编辑[DEFAULT]和[keystone_authtoken]部分,配置Keystone身份认证

[DEFAULT]
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=neutron123

3-2-4. 编辑[DEFAULT]和[nova]部分,配置网络来通知网络拓扑结构的变化

[nova]这一部分是没有的,都要新加进去。

[DEFAULT]
notify_nova_on_port_status_changes=True
notify_nova_on_port_data_changes=True


[nova]
auth_url=http://controller:5000
auth_type=password
project_domain_name=default
user_domain_name=default
region_name=ReginOne
project_name=service
username=nova
password=nova123

3-2-5. 编辑[oslo_concurrency]部分,配置lock_path

[oslo_concurrency]
lock_path=/var/lib/neutron/tmp

3-3. 配置ML2插件

编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件
文件本身并没有什么[ml2]部分,以下的各个部分要自己创建

3-3-1. 编辑[ml2]部分,配置Flat、VLAN、VxLAN网络

[ml2]
type_drivers=flat,vlan,vxlan

3-3-2. 编辑[ml2]部分,使用VxLAN网络

[ml2]
tenant_network_types=vxlan

3-3-3. 编辑[ml2]部分,启用网桥和ML2入口机制

[ml2]
mechanism_drivers=linuxbridge,l2population

3-3-4. 编辑[ml2]部分,启用端口安全扩展驱动程序

[ml2]
extension_drivers=port_security

3-3-5. 编辑[ml2_type_flat]部分,配置虚拟网络为Flat网络

[ml2_type_flat]
flat_networks=provider

3-3-6. 编辑[ml2_type_vxlan]部分,配置VxLAN网络标识符范围

[ml2_type_vxlan]
vni_ranges=1:1000

3-3-7. 编辑[securitygroup]部分,配置ipset安全组规则

[securitygroup]
enable_ipset=True

3-4. 配置Linux Bridge插件

3-4-1. 编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件

3-4-1-1. 编辑[linux_bridge]部分,配置虚拟网络映射到物理网络的接口
[linux_bridge]
physical_interface_mappings=provider:ens33
3-4-1-2. 编辑[vxlan]部分,使VxLAN覆盖网络,并配置物理网络的IP地址
[vxlan]
enable_vxlan=True
local_ip=192.168.58.134
l2_population=True
3-4-1-3. 编辑[securitygroup]部分,配置安全组和网桥,配置防火墙驱动
[securitygroup]
enable_security_group=True
firewall_driver=neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

3-4-2. 编辑/etc/sysctl.conf文件,添加如下两行内容

net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1

3-4-3. 加载br_netfilter模块

modprobe br_netfilter

3-4-4. 测试配置是否成功

sysctl -p

enter description here
enter description here

3-5. 配置L3插件

编辑/etc/neutron/l3_agent.ini文件
编辑[DEFAULT]部分,配置网桥接口驱动和外部网络连接

[DEFAULT]
interface_driver=linuxbridge

3-6. 配置DHCP插件

编辑/etc/neutron/dhcp_agent.ini文件
编辑[DEFAULT]部分,配置网桥接口驱动、Dnsmasq DHCP的驱动,并启用Metadata

[DEFAULT]
interface_driver=neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver=neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata=True

3-7. 配置Metadata插件

编辑/etc/neutron/metadata_agent.ini文件
编辑[DEFAULT]部分,配置元数据主机和共享密钥

nova_metadata_host=controller
metadata_proxy_shared_secret=secret123

3-8. 配置Nova服务使用网络

编辑/etc/nova/nova.conf文件
编辑[neutron]部分,配置访问参数,并启用和配置代理

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

3-9. 创建软链接

ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

3-10. 同步数据库

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

enter description here
enter description here

进入neutron数据库查看是否有数据表,验证是否同步成功

mysql -uneutron -pneutron123
use neutron;
show tables;
exit

enter description here
enter description here

3-11. 启动Neutron服务并设置开机自启动

systemctl restart openstack-nova-api
systemctl enable neutron-server neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent
systemctl start neutron-server neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent
systemctl enable neutron-l3-agent
systemctl start neutron-l3-agent

三、安装并配置计算节点

1. 安装Neutron组件所需软件包

yum install openstack-neutron-linuxbridge ebtables ipset -y

enter description here
enter description here

2. 配置Neutron所需组件

编辑/etc/neutron/neutron.conf文件

2-1. 编辑[DEFAULT]部分,配置RabbitMQ消息服务器链接

[DEFAULT]
transport_url=rabbit://openstack:000000@controller

2-2. 编辑[DEFAULT]和[keystone_authtoken]部分,配置Keystone身份认证

[DEFAULT]
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=neutron123

2-3. 编辑[oslo_concurrency]部分,配置lock_path

[oslo_concurrency]
lock_path=/var/lib/neutron/tmp

3. 配置Linux Bridge插件

编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件

3-1. 编辑[linux_bridge]部分,配置虚拟网络映射到物理网络的IP地址

[linux_bridge]
physical_interface_mappings=provider:ens33

3-2. 编辑[vxlan]部分,使VxLAN覆盖网络,并配置物理网络的IP地址

[vxlan]
enable_vxlan=True
local_ip=192.168.58.135
l2_population=True

3-3. 编辑[securitygroup]部分,配置安全组和网桥,配置防火墙驱动

[securitygroup]
enable_security_group=True
firewall_driver=neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

4. 配置Nova服务使用网络

编辑/etc/nova/nova.conf文件
编辑[neutron]部分,配置访问参数

[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=neutron123

5. 启动neutron服务并设置开机自启动

systemctl restart openstack-nova-compute
systemctl enable neutron-linuxbridge-agent
systemctl start neutron-linuxbridge-agent

四、验证neutron服务

1. 控制节点生效admin环境变量

cd /root/
source admin-openrc.sh

2. 查看neutron服务

openstack network agent list

enter description here
enter description here

总共列出了5个服务,其中,控制节点有Linux bridge agentDHCP agentMetadata agentL3 agent四个,计算节点有Linux bridge agent一个。

第七章做完了。

posted @ 2024-04-08 22:53  南宫二狗  阅读(36)  评论(0编辑  收藏  举报