OpenStack 安装:neutron服务

Stella981
• 阅读 692

在上一篇中介绍了Nova的安装配置,这一篇介绍neutron

  • 首先,创建neutron用户并设置密码为neutron

    [root@linux-node1 ~]# openstack user create --domain default --password-prompt neutron User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 0e2ce721eca14c688627df21da78cc4e | | name | neutron | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+

  • 给neutron用户授予admin角色

    [root@linux-node1 ~]# openstack role add --project service --user neutron admin

  • 创建neutron服务实例

    openstack service create --name neutron
    --description "OpenStack Networking" network +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Networking | | enabled | True | | id | 98cc414411714278a541de8653eefcb0 | | name | neutron | | type | network | +-------------+----------------------------------+

  • 创建neutron服务API端点

    openstack endpoint create --region RegionOne
    network public http://192.168.56.11:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | fc0ce5260d50460399bd160db2034569 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 98cc414411714278a541de8653eefcb0 | | service_name | neutron | | service_type | network | | url | http://192.168.56.11:9696 | +--------------+----------------------------------+openstack endpoint create --region RegionOne
    network internal http://192.168.56.11:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | a1107a5752f149a0988ee2d63c3fce8e | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 98cc414411714278a541de8653eefcb0 | | service_name | neutron | | service_type | network | | url | http://192.168.56.11:9696 | +--------------+----------------------------------+openstack endpoint create --region RegionOne
    network admin http://192.168.56.11:9696 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 1e3729ff74bd4f59b6aa5f7c170e21d2 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 98cc414411714278a541de8653eefcb0 | | service_name | neutron | | service_type | network | | url | http://192.168.56.11:9696 | +--------------+----------------------------------+

  • 验证用户和服务

    [root@linux-node1 ~]# openstack user list +----------------------------------+-----------+ | ID | Name | +----------------------------------+-----------+ | 0e2ce721eca14c688627df21da78cc4e | neutron | | 27080769990347169fdc6bf81fe9ebd1 | placement | | 291f02337e514343a09a92932a86fd22 | demo | | 31a0d9b7dd5f47b4b30ed4a77500a307 | glance | | 34c7be4d612a45b4830304af29eb010e | nova | | d010fba89633421a800698b0e5300d50 | admin | +----------------------------------+-----------+ [root@linux-node1 ~]# openstack service list +----------------------------------+-----------+-----------+ | ID | Name | Type | +----------------------------------+-----------+-----------+ | 325ab5f400f14fc485eb4231dab6d74d | keystone | identity | | 344d25c79f1b412cb0c5958bd8242b2c | placement | placement | | 4c4dd5eb35324b568cd9722f174a632b | glance | image | | 98cc414411714278a541de8653eefcb0 | neutron | network | | bf254b3182e04256897e925632f171d0 | nova | compute | +----------------------------------+-----------+-----------+

在本示例中,我们选择网络为provider networks

  • 编辑/etc/neutron/neutron.conf,并修改如下配置:

    [DEFAULT]

    auth_strategy = keystone core_plugin = ml2 service_plugins = notify_nova_on_port_status_changes = true notify_nova_on_port_data_changes = true transport_url = rabbit://openstack:openstack@192.168.56.11

    [database]

    connection = mysql+pymysql://neutron:neutron@192.168.56.11/neutron

    [keystone_authtoken]

    auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = neutron

    [nova]

    auth_url = http://192.168.56.11:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = nova password = nova

    [oslo_concurrency]

    lock_path = /var/lib/neutron/tmp

配置Linux桥接代理

  • 编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini,并作出如下修改:

    [linux_bridge]

    physical_interface_mappings = provider:eth0

    [securitygroup]

    firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver enable_security_group = true

    [vxlan]

    enable_vxlan = false

  • 编辑/etc/neutron/plugins/ml2/ml2_conf.ini并作出如下修改:

    [ml2]

    type_drivers = local,flat,vlan,gre,vxlan,geneve tenant_network_types = mechanism_drivers = linuxbridge extension_drivers = port_security

    [ml2_type_flat]

    flat_networks = provider

    [securitygroup]

    enable_ipset = true

  • 编辑/etc/neutron/dhcp_agent.ini ,并作出如下修改:

    [DEFAULT]interface_driver = linuxbridge

    dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq enable_isolated_metadata = true

配置metadata代理

  • 编辑/etc/neutron/metadata_agent.ini并作出如下修改:

    [DEFAULT]

    nova_metadata_host = 192.168.56.11 metadata_proxy_shared_secret = openstack

为neutron配置Nova服务

  • 编辑/etc/nova/nova.conf,并作出如下修改:

    [neutron] url = http://192.168.56.11:9696 auth_url = http://192.168.56.11:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = neutron service_metadata_proxy = true metadata_proxy_shared_secret = openstack

  • 网络服务初始化脚本需要一个链接由/etc/neutron/plugin.ini指向ML2插件配置文件/etc/neutron/plugins/ml2/ml2_conf.ini

    [root@linux-node1 ~]# 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 INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. .....

  • 因为修改过Nova文件,现在需要重启Nova服务

    [root@linux-node1 ~]# systemctl restart openstack-nova-api.service [root@linux-node1 ~]#

  • 启动neutron并设置为开机启动

    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

  • 验证配置是否正确

    [root@linux-node1 ~]# openstack network agent list +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+ | ID | Agent Type | Host | Availability Zone | Alive | State | Binary | +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+ | 22e10474-f526-4b7c-bd41-2345e69255ee | DHCP agent | linux-node1.example.com | nova | :-) | UP | neutron-dhcp-agent | | 796a0e3b-baa5-4ef5-b155-495f48857b43 | Linux bridge agent | linux-node1.example.com | None | :-) | UP | neutron-linuxbridge-agent | | fb02118a-d96c-43e6-994a-971f0682ef3f | Metadata agent | linux-node1.example.com | None | :-) | UP | neutron-metadata-agent | +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+

计算节点

  • 在node2上编辑/etc/neutron/neutron.conf并作出如下修改

    [DEFAULT]

    auth_strategy = keystone transport_url = rabbit://openstack:openstack@192.168.56.11

    [keystone_authtoken]

    auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = neutron

    [oslo_concurrency]

    lock_path = /var/lib/neutron/tmp

配置Linux桥接代理

  • 编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini并作出如下修改

    [linux_bridge]

    physical_interface_mappings = provider:eth0

    [securitygroup]

    firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver enable_security_group = true

    [vxlan]

    enable_vxlan = false

为neutron服务配置Nova服务

  • 编辑/etc/nova/nova.conf并作出如下修改:

    [neutron] url = http://192.168.56.11:9696 auth_url = http://192.168.56.11:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = neutron

  • 重启Nova服务

    [root@linux-node2 nova]# systemctl restart openstack-nova-compute.service

  • 启动neutron服务并设置为开机启动

    [root@linux-node2 nova]# systemctl enable neutron-linuxbridge-agent.service Created symlink from /etc/systemd/system/multi- user.target.wants/neutron-linuxbridge-agent.service to /usr/lib/systemd/system/neutron-linuxbridge-agent.service. [root@linux-node2 nova]# systemctl start neutron-linuxbridge-agent.service

  • 验证配置是否正确

    [root@linux-node1 ~]# openstack network agent list +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+ | ID | Agent Type | Host | Availability Zone | Alive | State | Binary | +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+ | 22e10474-f526-4b7c-bd41-2345e69255ee | DHCP agent | linux-node1.example.com | nova | :-) | UP | neutron-dhcp-agent | | 796a0e3b-baa5-4ef5-b155-495f48857b43 | Linux bridge agent | linux-node1.example.com | None | :-) | UP | neutron-linuxbridge-agent | | b0207456-29b8-4ff1-a9e9-4d4aa22e42fe | Linux bridge agent | linux-node2.example.com | None | :-) | UP | neutron-linuxbridge-agent | | fb02118a-d96c-43e6-994a-971f0682ef3f | Metadata agent | linux-node1.example.com | None | :-) | UP | neutron-metadata-agent | +--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+ [root@linux-node1 ~]# openstack compute service list +----+------------------+-------------------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+-------------------------+----------+---------+-------+----------------------------+ | 1 | nova-consoleauth | linux-node1.example.com | internal | enabled | up | 2018-01-12T08:15:33.000000 | | 2 | nova-scheduler | linux-node1.example.com | internal | enabled | up | 2018-01-12T08:15:31.000000 | | 3 | nova-conductor | linux-node1.example.com | internal | enabled | up | 2018-01-12T08:15:40.000000 | | 6 | nova-compute | linux-node2.example.com | nova | enabled | up | 2018-01-12T08:15:36.000000 | +----+------------------+-------------------------+----------+---------+-------+----------------------------+

  • 创建网络

    openstack network create --share --external
    --provider-physical-network provider
    --provider-network-type flat provider +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2018-01-12T08:26:03Z | | description | | | dns_domain | None | | id | 59cd11d3-3d7b-4da3-8cbf-a5fece6be63b | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | None | | is_vlan_transparent | None | | mtu | 1500 | | name | provider | | port_security_enabled | True | | project_id | fb6761ab3d3d43569d5fdfafcdfa5e28 | | provider:network_type | flat | | provider:physical_network | provider | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 3 | | router:external | External | | segments | None | | shared | True | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2018-01-12T08:26:03Z | +---------------------------+--------------------------------------+

  • 验证网络是否创建

    [root@linux-node1 ~]# openstack network list +--------------------------------------+----------+---------+ | ID | Name | Subnets | +--------------------------------------+----------+---------+ | 59cd11d3-3d7b-4da3-8cbf-a5fece6be63b | provider | | +--------------------------------------+----------+---------+

  • 创建子网

    openstack subnet create --network provider
    --allocation-pool start=192.168.56.100,end=192.168.56.200
    --dns-nameserver 223.5.5.5 --gateway 192.168.56.2
    --subnet-range 192.168.56.0/24 provider +-------------------------+--------------------------------------+ | Field | Value | +-------------------------+--------------------------------------+ | allocation_pools | 192.168.56.100-192.168.56.200 | | cidr | 192.168.56.0/24 | | created_at | 2018-01-12T08:30:11Z | | description | | | dns_nameservers | 223.5.5.5 | | enable_dhcp | True | | gateway_ip | 192.168.56.2 | | host_routes | | | id | 50340b32-3f7f-4e8f-be72-673b9f701e4d | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | provider | | network_id | 59cd11d3-3d7b-4da3-8cbf-a5fece6be63b | | project_id | fb6761ab3d3d43569d5fdfafcdfa5e28 | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2018-01-12T08:30:11Z | | use_default_subnet_pool | None | +-------------------------+--------------------------------------+

  • 验证子网是否创建

    [root@linux-node1 ~]# openstack subnet list +--------------------------------------+----------+--------------------------------------+-----------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------+--------------------------------------+-----------------+ | 50340b32-3f7f-4e8f-be72-673b9f701e4d | provider | 59cd11d3-3d7b-4da3-8cbf-a5fece6be63b | 192.168.56.0/24 | +--------------------------------------+----------+--------------------------------------+-----------------+

  • 创建虚拟机

    [root@linux-node1 ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano +----------------------------+---------+ | Field | Value | +----------------------------+---------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 1 | | id | 0 | | name | m1.nano | | os-flavor-access:is_public | True | | properties | | | ram | 64 | | rxtx_factor | 1.0 | | swap | | | vcpus | 1 | +----------------------------+---------+

  • 使用demo环境变量并创建key

    [root@linux-node1 ~]# source demo-openstack.sh [root@linux-node1 ~]# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa):

  • 创建keypair

    [root@linux-node1 ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | 82:98:44:bc:5e:dd:dc:66:48:c7:61:9f:6a:27:78:cd | | name | mykey | | user_id | 291f02337e514343a09a92932a86fd22 | +-------------+-------------------------------------------------+

  • 验证keypair是否创建成功

    [root@linux-node1 ~]# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 82:98:44:bc:5e:dd:dc:66:48:c7:61:9f:6a:27:78:cd | +-------+-------------------------------------------------+

  • 添加安全组规则并运行SSH接入

    [root@linux-node1 ~]# openstack security group rule create --proto icmp default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2018-01-12T08:41:51Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 245c084a-c503-4f23-a875-7a33c1eb442d | | name | None | | port_range_max | None | | port_range_min | None | | project_id | 1d5b969df6da43e69e4a956297404f5c | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | e46d2903-e800-4464-a788-1923523ba4de | | updated_at | 2018-01-12T08:41:51Z | +-------------------+--------------------------------------+ [root@linux-node1 ~]# openstack security group rule create --proto tcp --dst-port 22 default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2018-01-12T08:42:32Z | | description | | | direction | ingress | | ether_type | IPv4 | | id | 38f48887-e107-4811-8138-787a68191748 | | name | None | | port_range_max | 22 | | port_range_min | 22 | | project_id | 1d5b969df6da43e69e4a956297404f5c | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 0 | | security_group_id | e46d2903-e800-4464-a788-1923523ba4de | | updated_at | 2018-01-12T08:42:32Z | +-------------------+--------------------------------------+

  • 创建实例,使用openstack network list中的ID创建实例

    [root@linux-node1 ~]# openstack network list +--------------------------------------+----------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+----------+--------------------------------------+ | 59cd11d3-3d7b-4da3-8cbf-a5fece6be63b | provider | 50340b32-3f7f-4e8f-be72-673b9f701e4d | +--------------------------------------+----------+--------------------------------------+openstack server create --flavor m1.nano --image cirros
    --nic net-id=59cd11d3-3d7b-4da3-8cbf-a5fece6be63b --security-group default
    --key-name mykey provider-instance +-----------------------------+-----------------------------------------------+ | Field | Value | +-----------------------------+-----------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-STS:power_state | NOSTATE | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | None | | OS-SRV-USG:terminated_at | None | | accessIPv4 | | | accessIPv6 | | | addresses | | | adminPass | v7pgeGj7b5zC | | config_drive | | | created | 2018-01-12T08:46:04Z | | flavor | m1.nano (0) | | hostId | | | id | 46cc7aad-6353-4399-b067-919e736e07ac | | image | cirros (24a1486b-d1b5-4564-b2cc-3397fdf295cf) | | key_name | mykey | | name | provider-instance | | progress | 0 | | project_id | 1d5b969df6da43e69e4a956297404f5c | | properties | | | security_groups | name='e46d2903-e800-4464-a788-1923523ba4de' | | status | BUILD | | updated | 2018-01-12T08:46:04Z | | user_id | 291f02337e514343a09a92932a86fd22 | | volumes_attached | | +-----------------------------+-----------------------------------------------+

  • 查看是否创建成功

    [root@linux-node1 ~]# openstack server list +--------------------------------------+-------------------+--------+-------------------------+--------+---------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+-------------------+--------+-------------------------+--------+---------+ |46cc7aad-6353-4399-b067-919e736e07ac | provider-instance | ACTIVE | provider=192.168.56.105 | cirros | m1.nano | +--------------------------------------+-------------------+--------+-------------------------+--------+---------+

  • 查看console端口

    [root@linux-node1 ~]# openstack console url show provider-instance +-------+------------------------------------------------------------------------------------+ | Field | Value | +-------+------------------------------------------------------------------------------------+ | type | novnc | | url | http://192.168.56.11:6080/vnc_auto.html?token=e000ab58-4080-4adf-b588-59b6b86bcfa8 | +-------+------------------------------------------------------------------------------------+

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这