个人-005-OpenStack-网络服务

2019-07-25  本文已影响0人  MineG

OpenStack-网络服务

【基于此文章的环境】点我快速打开文章

1、控制节点(controller)

1.1 创库授权 neutron

mysql

CREATE DATABASE neutron;

GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
  IDENTIFIED BY 'NEUTRON_DBPASS';

GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
  IDENTIFIED BY 'NEUTRON_DBPASS';
image image

1.2 创建服务证书

1. 创建 neutron 用户

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

用合适的密码代替 NEUTRON_PASS

image image

2. 给 neutron 用户添加 admin 角色

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

3. 创建 neutron 服务实体

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

4. 创建 Compute 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
image image

1.3 配置网络选项

1. 安装其软件包

yum install openstack-neutron openstack-neutron-ml2 \
  openstack-neutron-linuxbridge ebtables -y &>/dev/null
  
echo $?
image image

2. 修改配置文件

1. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/neutron.conf{,.bak}

egrep -v '^$|#' /etc/neutron/neutron.conf.bak >/etc/neutron/neutron.conf
image image
2. 编辑文件 /etc/neutron/neutron.conf 并完成如下动作:
vim /etc/neutron/neutron.conf
  • [database] 部分,配置数据库访问
[database]
# ...
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron

用你设置的数据库密码替换 NEUTRON_DBPASS

  • DEFAULT] 部分,启用 ML2 插件并禁用其他插件
[DEFAULT]
# ...
core_plugin = ml2
service_plugins =
  • [DEFAULT] 部分,配置 RabbitMQ 消息队列访问权限
[DEFAULT]
# ...
transport_url = rabbit://openstack:RABBIT_PASS@controller

用你在 RabbitMQ 中为 openstack 选择的密码替换 RABBIT_PASS

  • [DEFAULT][keystone_authtoken] 部分中,配置身份服务访问
[DEFAULT]
# ...
auth_strategy = keystone

[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS

NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

  • [DEFAULT][nova] 部分,配置网络服务来通知计算节点的网络拓扑变化:
[DEFAULT]
# ...
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true

[nova]
# ...
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS

使用你在身份认证服务中设置的 nova 用户的密码替换 NOVA_PASS

  • [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
# ...
lock_path = /var/lib/neutron/tmp
image image
3. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak}

egrep -v '^$|#' /etc/neutron/plugins/ml2/ml2_conf.ini.bak >/etc/neutron/plugins/ml2/ml2_conf.ini
image image
4. 编辑文件 /etc/neutron/plugins/ml2/ml2_conf.ini 并完成如下动作:
vim /etc/neutron/plugins/ml2/ml2_conf.ini
  • [ml2] 部分,启用 flatVLAN 网络:
[ml2]
# ...
type_drivers = flat,vlan
  • [ml2] 部分,禁用私有网络:
[ml2]
# ...
tenant_network_types =
  • [ml2] 部分,启用 Linuxbridge 机制:
[ml2]
# ...
mechanism_drivers = linuxbridge
  • [ml2] 部分,启用端口安全扩展驱动:
[ml2]
# ...
extension_drivers = port_security
  • [ml2_type_flat] 部分,配置公共虚拟网络为 flat 网络:
[ml2_type_flat]
# ...
flat_networks = provider
  • [securitygroup] 部分,启用 ipset 增加安全组的方便性:
[securitygroup]
# ...
enable_ipset = true
image image
5. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak}

egrep -v '^$|#' /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak >/etc/neutron/plugins/ml2/linuxbridge_agent.ini
image image
6. 编辑文件 /etc/neutron/plugins/ml2/linuxbridge_agent.ini 并完成如下动作:
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
  • [linux_bridge] 部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = provider:eth0
  • [vxlan] 部分,禁止 VXLAN 覆盖网络:
[vxlan]
enable_vxlan = false

[securitygroup] 部分,启用安全组并配置 Linux 桥接 iptables 防火墙驱动:

[securitygroup]
# ...
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
image image
9. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/dhcp_agent.ini{,.bak}

egrep -v '^$|#' /etc/neutron/dhcp_agent.ini.bak >/etc/neutron/dhcp_agent.ini
image image
10. 编辑文件 /etc/neutron/dhcp_agent.ini 并完成如下动作:
vim /etc/neutron/dhcp_agent.ini
  • [DEFAULT] 部分,配置 Linuxbridge 驱动接口,DHCP 驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络来访问元数据
[DEFAULT]
# ...
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
image image

1.4 配置元数据代理

1. 修改配置文件

1. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/metadata_agent.ini{,.bak}

egrep -v '^$|#' /etc/neutron/metadata_agent.ini.bak >/etc/neutron/metadata_agent.ini
image image
2. 编辑文件 /etc/neutron/metadata_agent.ini 并完成如下动作:
vim /etc/neutron/metadata_agent.ini
  • [DEFAULT] 部分,配置元数据主机以及共享密码:
[DEFAULT]
# ...
nova_metadata_ip = controller
metadata_proxy_shared_secret = METADATA_SECRET

用你为元数据代理设置的密码替换 METADATA_SECRET。

image image
3. 编辑文件 /etc/nova/nova.conf 并完成如下动作:
vim /etc/nova/nova.conf
  • [neutron] 部分,配置访问参数,启用元数据代理并设置密码:
[neutron]
# ...
url = http://controller:9696
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
service_metadata_proxy = true
metadata_proxy_shared_secret = METADATA_SECRET

NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

使用你为元数据代理设置的密码替换 METADATA_SECRET

image image

1.5 同步数据库(创表)

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

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
image image

1.6 启动和自启动

systemctl restart openstack-nova-api.service

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

systemctl start neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
image image

1.7 验证操作

openstack network agent list
image image

2、计算节点(compute1)

2.1 安装组件

1. 安装其软件包

yum install openstack-neutron-linuxbridge ebtables ipset -y &>/dev/null

echo $?
image image

2. 修改配置文件

1. 备份初始配置文件,然后重定向写入配置文件
cp /etc/neutron/neutron.conf{,.bak}

egrep -v '^$|#' /etc/neutron/neutron.conf.bak >/etc/neutron/neutron.conf
image image
2. 编辑文件 /etc/neutron/neutron.conf 并完成如下动作:
vim /etc/neutron/neutron.conf
  • [DEFAULT] 部分,配置 RabbitMQ 消息队列访问权限
[DEFAULT]
# ...
transport_url = rabbit://openstack:RABBIT_PASS@controller

用你在 RabbitMQ 中为 openstack 选择的密码替换 RABBIT_PASS

  • [DEFAULT][keystone_authtoken] 部分中,配置身份服务访问
[DEFAULT]
# ...
auth_strategy = keystone

[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS

NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

  • [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
# ...
lock_path = /var/lib/neutron/tmp
image image

2.2 配置网络选项

1. 复制配置文件

scp -rp 10.0.0.11:/etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini
image image

2. 修改配置文件

1. 编辑文件 /etc/nova/nova.conf 并完成如下动作:
vim /etc/nova/nova.conf
  • [neutron] 部分,配置访问参数:
[neutron]
# ...
url = http://controller:9696
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS

NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

image image

2.3 启动和自启动

systemctl restart openstack-nova-compute.service

systemctl enable neutron-linuxbridge-agent.service

systemctl start neutron-linuxbridge-agent.service
image image

【后续文章】点我快速打开文章

【本文图片下载地址】【002-OpenStack】点我快速打开分享(若异常,请私信,万分感谢) 【提取码:kse1 】

今天你学习了吗?若有疑问,请留言、私信或加QQ群:647033350,大家一起进步吧!

上一篇下一篇

猜你喜欢

热点阅读