Openstack-T 之Neutron

官方文档:OpenStack Docs:安装和配置Red Hat Enterprise Linux和CentOS

视频讲解:openstack-T版搭建运维全套视频_哔哩哔哩_bilibili

 PS:请注意!!!在安装以下服务时,如果碰到配置文件有大量缺省,先将原来的全部删除,再去其他版本的文档复制完整内容(这里我复制的是o版的配置文件)

如果只是小量的,在配置文件的最后加入即可!


在控制节点:

1、创建相关数据库并授权

使用mysql -u root -p进入数据库中

#创建数据库
MariaDB [(none)] CREATE DATABASE neutron;

#授权
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'neutron123';

这里密码我设置neutron123

2、创建服务相关凭证

创建用户

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

密码我设置:neutron123

将角色添加到用户:adminneutron

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

 创建服务实体:neutron

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

创建网络服务 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

 配置服务代理(三层代理服务)

原文可参考官方文档:

OpenStack 文档:网络选项 2:自助服务网络

1、安装组件

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

2、配置服务器组件

如果有文本缺省,先删除原先所有的,再复制以下文档:

OpenStack Docs: neutron.confhttps://docs.openstack.org/ocata/config-reference/networking/samples/neutron.conf.html

编辑文件并完成以下操作:/etc/neutron/neutron.conf

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

[DEFAULT]
# ...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true

[DEFAULT]
# ...
transport_url = rabbit://openstack:openstack123@controller

[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

[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 = RegionOne
project_name = service
username = nova
password = 123

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

配置模块化第 2 层 (ML2) 插件

如果有文本缺省,先删除原先所有的,再复制以下文档:

OpenStack Docs: ml2_conf.ini

编辑文件并完成以下操作:/etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
type_drivers = flat,vlan,vxlan

[ml2]
tenant_network_types = vxlan

[ml2]
mechanism_drivers = linuxbridge,l2population

[ml2]
extension_drivers = port_security

[ml2_type_flat]
flat_networks = extnet  #指定公共虚拟网络为flat,网络名称为extent,用于下面的配置绑定

[ml2_type_vxlan]
vni_ranges = 1:1000

[securitygroup]
enable_ipset = true

配置 Linux 桥代理

如果有文本缺省,先删除原先所有的,再复制以下文档:

OpenStack Docs: linuxbridge_agent.ini

编辑:/etc/neutron/plugins/ml2/linuxbridge_agent.ini

[linux_bridge]
physical_interface_mappings = extent:ens33  #名称:绑定网卡

[vxlan]
enable_vxlan = true
local_ip = 192.168.134.134   #根据实际,设置自己的控制节点IP
l2_population = true

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

配置内核:编辑vim /etc/sysctl.conf 

在最后添加

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

 启动br_netfilter模块

 # modprobe br_netfilter

 再去查询

[root@controller ~]# sysctl -p
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1

配置第 3 层代理

编辑文件并完成以下操作:/etc/neutron/l3_agent.ini

#配置 Linux 桥接接口驱动程序:[DEFAULT]

[DEFAULT]
interface_driver = linuxbridge

 配置 DHCP 代理

编辑文件并完成以下操作:/etc/neutron/dhcp_agent.ini

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

配置元数据代理,用于配置桥接与自服务网络的通用配置

编辑文件并完成以下操作:/etc/neutron/metadata_agent.ini

[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = 123 

#将原本的METADATA_SECRET替换为密码,注意之后要用的
#替换为元数据代理的合适机密。METADATA_SECRET

将计算服务配置为使用网络服务,用于neutron交互

在控制节点

编辑文件并执行以下操作:/etc/nova/nova.conf

[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
service_metadata_proxy = true
metadata_proxy_shared_secret = 123

创建软连接

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

 同步数据库

[root@controller ~]# 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

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
/usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name 'alembic_version_pkc' ignored for PRIMARY key.")
  result = self._query(query)
  正在对 neutron 运行 upgrade...
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assum
.......

验证

进入数据库,使用use neutron

MariaDB [(none)]> use neutron
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

再查看neutron的服务表

MariaDB [neutron]> show tables;
+-----------------------------------------+
| Tables_in_neutron                       |
+-----------------------------------------+
| address_scopes                          |
| agents                                  |
| alembic_version                         |
| allowedaddresspairs                     |
| arista_provisioned_nets                 |
| arista_provisioned_tenants              |
| arista_provisioned_vms                  |
| auto_allocated_topologies               |
| bgp_peers                               |
| bgp_speaker_dragent_bindings            |
| bgp_speaker_network_bindings            |
| bgp_speaker_peer_bindings               |
| bgp_speakers                            |
| brocadenetworks                         |
| brocadeports                            |
| cisco_csr_identifier_map     
...........

有数据则代表之前的配置成功!

启动网络服务并将其配置为在系统启动时启动

# systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-server.service to /usr/lib/systemd/system/neutron-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-linuxbridge-agent.service to /usr/lib/systemd/system/neutron-linuxbridge-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-dhcp-agent.service to /usr/lib/systemd/system/neutron-dhcp-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-metadata-agent.service to /usr/lib/systemd/system/neutron-metadata-agent.service.


# systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

#因为我这配置的是三层网络,所以还要执行以下操作
# systemctl enable neutron-l3-agent.service;systemctl start neutron-l3-agent.service

Neutron之计算节点

以下操作均在计算节点

PS:有缺失的文档,要去其他版本复制

1、安装组件

yum install openstack-neutron-linuxbridge ebtables ipset -y

2、配置通用组件

编辑文件并完成以下操作:/etc/neutron/neutron.conf

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

[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

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

配置自助服务

编辑文件并完成以下操作:/etc/neutron/plugins/ml2/linuxbridge_agent.ini

# 在最后面加入以下内容

[linux_bridge]
physical_interface_mappings = extent:ens33    #之前的名称:绑定网卡

[vxlan]
enable_vxlan = true
local_ip = 192.168.134.135          #配置自己的计算节点IP
l2_population = true

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

验证

编辑/etc/sysctl.conf文件,在后面添加:

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

将计算服务配置为使用网络服务

编辑文件并完成以下操作:/etc/nova/nova.conf

[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

完成安装

重新启动计算服务,启动 Linux 桥接代理并将其配置为在系统引导时启动

# systemctl restart openstack-nova-compute.service
# systemctl enable neutron-linuxbridge-agent.service;systemctl start neutron-linuxbridge-agent.service

如果restart时报错类似以下:

[root@compute1 ~]# systemctl restart openstack-nova-compute.service
Job for openstack-nova-compute.service failed because the control process 
exited with error code. See "systemctl status openstack-nova-compute.service" and "journalctl -xe" for details.

先使用tail -f /var/log/nova/*.log查看日志,如果时如下错误:

 ERROR nova   File "/usr/lib/python2.7/site-packages/amqp/connection.py", line 313, in connect

则需要去controller,使用rabbitmqctl list_users查看之前的openstack用户还在不在(不清楚的可以看我之安装rabbitmq的)安装T版openstack(一)_学无止境xs的博客-CSDN博客_openstack t版安装https://blog.csdn.net/m0_61777116/article/details/123702147解决方法:ERROR oslo_service.service AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN - chili7 - 博客园 (cnblogs.com)https://www.cnblogs.com/omgasw/p/12097639.html

[root@controller ~]# rabbitmqctl list_users
Listing users
openstack       []
guest   [administrator]

再使用tail -f /var/log/neutron/linuxbridge-agent.log 查看日志,如无error则继续,有则先解决

验证

[root@controller ~]# openstack network agent list
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type         | Host       | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 2d398171-8f44-470c-8de9-f5bfcd1c54b4 | Metadata agent     | controller | None              | :-)   | UP    | neutron-metadata-agent    |
| 44313bde-1b97-423d-bf45-30717aab9cf0 | DHCP agent         | controller | nova              | :-)   | UP    | neutron-dhcp-agent        |
| 922ca769-e30f-4c33-bade-3760d714699d | Linux bridge agent | controller | None              | :-)   | UP    | neutron-linuxbridge-agent |
| 95746d5c-0a73-428b-9571-11e23c7acca3 | L3 agent           | controller | nova              | :-)   | UP    | neutron-l3-agent          |
| fc3f7940-c85a-473a-aff0-ce88ef99f961 | Linux bridge agent | compute1   | None              | :-)   | UP    | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

PS:重点输出应指示控制器节点上的四个代理和每个计算节点上的一个代理(如果是三层的话,缺一不可)

若出现 :

[root@controller ~]# openstack network agent list
Missing value auth-url required for auth plugin password

则是你环境变量没生效,请使用source /etc/keystone/admin-openrc.sh (文件名可能不一样,根据实际为准)

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值