“OpenStack:Neutron组件的运维(图形界面版)”的版本间的差异

来自CloudWiki
跳转至: 导航搜索
创建子网
 
第19行: 第19行:
  
 
[[文件:openstack6-5.png|700px]]
 
[[文件:openstack6-5.png|700px]]
 
 
[[文件:openstack6-6.png|700px]]
 
  
  
第33行: 第30行:
  
 
==查看现有网络 ==
 
==查看现有网络 ==
===列出当前租户所有的网络===
+
[[文件:openstack6-10.png|700px]]
openstack network list
 
 
 
<nowiki>+--------------------------------------+------------+-----------------------------------------------------+
 
| id                                  | name      | subnets                                            |
 
+--------------------------------------+------------+-----------------------------------------------------+
 
| 0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20 | sharednet1 | c3623b66-3fff-49ec-b78b-6c48348aedb2 192.168.1.0/24 |
 
+--------------------------------------+------------+-----------------------------------------------------+
 
</nowiki>
 
  
 
===查看一个网络的详细信息===
 
===查看一个网络的详细信息===
openstack network show <name-or-id>
+
[[文件:openstack6-11.png|700px]]
 
 
<nowiki>[root@controller ~]# openstack network show  0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20
 
 
 
 
 
+---------------------------+--------------------------------------+
 
| Field                    | Value                                |
 
+---------------------------+--------------------------------------+
 
| admin_state_up            | True                                |
 
| id                        | 0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20 |
 
| name                      | sharednet1                          |
 
| provider:network_type    | flat                                |
 
| provider:physical_network | physnet1                            |
 
| provider:segmentation_id  |                                      |
 
| router:external          | False                                |
 
| shared                    | True                                |
 
| status                    | ACTIVE                              |
 
| subnets                  | c3623b66-3fff-49ec-b78b-6c48348aedb2 |
 
| tenant_id                | a0a60387c08e402f9790b05310245cd8    |
 
+---------------------------+--------------------------------------+
 
</nowiki>   
 
  
 
===列出网络中所有的agent(代理)===
 
neutron agent-list
 
 
<nowiki>[root@controller ~]# neutron agent-list
 
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
 
| id                                  | agent_type        | host      | availability_zone | alive | admin_state_up | binary                    |
 
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
 
| 1ce5426d-2dde-493b-9fe4-1f035c9ed7a4 | Metadata agent    | compute    |                  | xxx  | True          | neutron-metadata-agent    |
 
| 1d4b6835-284d-477e-b5af-62d6f45ab877 | L3 agent          | controller | nova              | :-)  | True          | neutron-l3-agent          |
 
| 511c57f6-acaf-4dfc-9069-54190f9bb7c4 | Open vSwitch agent | controller |                  | :-)  | True          | neutron-openvswitch-agent |
 
| 847c77bb-8fe9-4d29-aa77-ecf91e5d7322 | Open vSwitch agent | compute    |                  | xxx  | True          | neutron-openvswitch-agent |
 
| 9af393ab-46ef-47ae-878c-b3d952b011a3 | DHCP agent        | controller | nova              | :-)  | True          | neutron-dhcp-agent        |
 
| c2aa9542-b60b-47b2-afb0-0d3d387d07b5 | Metadata agent    | controller |                  | :-)  | True          | neutron-metadata-agent    |
 
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
 
 
</nowiki>
 
  
 
===列出路由信息===
 
===列出路由信息===
neutron router-list
+
[[文件:openstack6-12.png|700px]]
 
    
 
    
  
  
 
==管理现有网络==
 
https://docs.openstack.org/zh_CN/user-guide/cli-create-and-manage-networks.html#create-networks
 
 
===删除路由接口===
 
查看端口信息:neutron port-list
 
 
<nowiki>+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
| id                                  | name | mac_address      | fixed_ips                                                                            |
 
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
| 596e4378-889c-4944-8335-b196467f2cf1 |      | fa:16:3e:9e:86:be | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.109"} |
 
| 79e423dc-7f01-4a67-b64b-d9ef9a9c6bf6 |      | fa:16:3e:8c:84:27 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.111"} |
 
| 9f1882a0-0d89-40ea-a7eb-c891885b1389 |      | fa:16:3e:2c:ff:b6 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.101"} |
 
| ea4dae07-1677-48f2-8ca8-5a01b9a729aa |      | fa:16:3e:8f:c1:43 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.102"} |
 
| fdfcdf5e-8e49-4d52-b8db-c8da69f706d9 |      | fa:16:3e:76:58:39 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.110"} |
 
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
</nowiki>
 
查看网络信息: neutron net-list
 
 
<nowiki>+--------------------------------------+------------+-----------------------------------------------------+
 
| id                                  | name      | subnets                                            |
 
+--------------------------------------+------------+-----------------------------------------------------+
 
| 0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20 | sharednet1 | c3623b66-3fff-49ec-b78b-6c48348aedb2 192.168.1.0/24 |
 
+--------------------------------------+------------+-----------------------------------------------------+
 
</nowiki>
 
 
查看子网信息:neutron subnet-list
 
 
<nowiki>+--------------------------------------+------+----------------+----------------------------------------------------+
 
| id                                  | name | cidr          | allocation_pools                                  |
 
+--------------------------------------+------+----------------+----------------------------------------------------+
 
| c3623b66-3fff-49ec-b78b-6c48348aedb2 |      | 192.168.1.0/24 | {"start": "192.168.1.100", "end": "192.168.1.200"} |
 
+--------------------------------------+------+----------------+----------------------------------------------------+
 
</nowiki>
 
 
查看路由信息:neutron router-list
 
 
删除router-interface:
 
 
neutron router-interface-delete [router-id] [subnet-id]
 
 
===删除端口信息===
 
查看端口信息: neutron port-list
 
 
        <nowiki>+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
| id                                  | name | mac_address      | fixed_ips                                                                            |
 
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
| 596e4378-889c-4944-8335-b196467f2cf1 |      | fa:16:3e:9e:86:be | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.109"} |
 
| 79e423dc-7f01-4a67-b64b-d9ef9a9c6bf6 |      | fa:16:3e:8c:84:27 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.111"} |
 
| 9f1882a0-0d89-40ea-a7eb-c891885b1389 |      | fa:16:3e:2c:ff:b6 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.101"} |
 
| ea4dae07-1677-48f2-8ca8-5a01b9a729aa |      | fa:16:3e:8f:c1:43 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.102"} |
 
| fdfcdf5e-8e49-4d52-b8db-c8da69f706d9 |      | fa:16:3e:76:58:39 | {"subnet_id": "c3623b66-3fff-49ec-b78b-6c48348aedb2", "ip_address": "192.168.1.110"} |
 
+--------------------------------------+------+-------------------+--------------------------------------------------------------------------------------+
 
</nowiki>
 
 
 
删除端口信息:neutron port-delete [id] 
 
 
 
 
 
反复删除,直到将所有的端口都删干净为止。
 
 
再次查看端口信息:neutron port-list
 
 
<nowiki>[root@controller ~]# neutron port-delete 596e4378-889c-4944-8335-b196467f2cf1
 
Deleted port: 596e4378-889c-4944-8335-b196467f2cf1
 
[root@controller ~]#  neutron port-delete 79e423dc-7f01-4a67-b64b-d9ef9a9c6bf6
 
Deleted port: 79e423dc-7f01-4a67-b64b-d9ef9a9c6bf6
 
[root@controller ~]#  neutron port-delete  9f1882a0-0d89-40ea-a7eb-c891885b1389
 
Deleted port: 9f1882a0-0d89-40ea-a7eb-c891885b1389
 
[root@controller ~]#  neutron port-delete ea4dae07-1677-48f2-8ca8-5a01b9a729aa
 
Deleted port: ea4dae07-1677-48f2-8ca8-5a01b9a729aa
 
[root@controller ~]# neutron port-delete fdfcdf5e-8e49-4d52-b8db-c8da69f706d9
 
Deleted port: fdfcdf5e-8e49-4d52-b8db-c8da69f706d9
 
</nowiki>
 
 
===删除子网===
 
查看子网信息:neutron subnet-list
 
 
<nowiki>+--------------------------------------+------+----------------+----------------------------------------------------+
 
| id                                  | name | cidr          | allocation_pools                                  |
 
+--------------------------------------+------+----------------+----------------------------------------------------+
 
| c3623b66-3fff-49ec-b78b-6c48348aedb2 |      | 192.168.1.0/24 | {"start": "192.168.1.100", "end": "192.168.1.200"} |
 
+--------------------------------------+------+----------------+----------------------------------------------------+
 
</nowiki>
 
 
删除子网信息:neutron subnet-delete [id]
 
 
直到把所有的子网到删除为止:
 
 
<nowiki>[root@controller ~]# neutron subnet-delete c3623b66-3fff-49ec-b78b-6c48348aedb2
 
Deleted subnet: c3623b66-3fff-49ec-b78b-6c48348aedb2
 
</nowiki>
 
 
===删除路由===
 
查看路由信息: neutron router-list
 
 
删除路由:neutron route-delete  [id]
 
 
 
===删除整个网络===
 
查看网络信息:
 
 
neutron net-list
 
 
<nowiki>+--------------------------------------+------------+---------+
 
| id                                  | name      | subnets |
 
+--------------------------------------+------------+---------+
 
| 0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20 | sharednet1 |        |
 
+--------------------------------------+------------+---------+
 
</nowiki>
 
删除网络信息:
 
 
neutron net-delete [id]
 
   
 
<nowiki>[root@controller ~]# neutron net-delete  0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20
 
Deleted network: 0f82a3a5-5f0e-42d3-ba8b-93a02ea76a20
 
</nowiki>
 
 
 
==创建GRE网络(选学)==
 
将刚刚创建的网络删除
 
 
===配置 ML2===
 
<nowiki>#GRE、FLAT
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,gre
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types  flat,gre
 
#GRE 网络修改
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_gre  tunnel_id_ranges 1:1000
 
HERE!
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs local_ip 20.0.0.10
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs tunnel_type gre
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs enable_tunneling True
 
# openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dnsmasq_config_file 
 
/etc/neutron/dnsmasq-neutron.conf
 
# echo "dhcp-option-force=26,1454" > /etc/neutron/dnsmasq-neutron.conf #FLAT 网络修改 #openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks 
 
physnet1
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs flat_networks  physnet1
 
#openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs bridge_mappings
 
physnet1:br-ex #GRE、FLAT #ln -s plugins/ml2/ml2_conf.ini  /etc/neutron/plugin.ini
 
# cp /etc/init.d/neutron-openvswitch-agent  /etc/init.d/neutron-openvswitch-agent.orig
 
# sed -i 's,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g'
 
/etc/init.d/neutron-openvswitch-agent
 
#chkconfig neutron-openvswitch-agent on
 
  #GRE
 
# source admin-openrc.sh
 
# neutron net-create ext-net --shared --router:external=True
 
# neutron subnet-create ext-net --name ext-subnet  --allocation-pool
 
start=FLOATING_IP_START,end=FLOATING_IP_END --disable-dhcp --gateway
 
EXTERNAL_NETWORK_GATEWAY  EXTERNAL_NETWORK_CIDR
 
# neutron net-create NET_NAME
 
# neutron subnet-create NET_NAME --name demo-subnet  --gateway
 
TENANT_NETWORK_GATEWAY  TENANT_NETWORK_CIDR
 
# neutron router-create demo-router
 
# neutron router-interface-add demo-router demo-subnet
 
# neutron router-gateway-set demo-router ext-net
 
#
 
</nowiki>
 
==脚本解读==
 
===配置FLAT网络===
 
控制节点:
 
 
 
<nowiki>#!/bin/bash
 
source /etc/xiandian/openrc.sh
 
source /etc/keystone/admin-openrc.sh
 
 
ovs-vsctl add-br br-ex
 
ovs-vsctl add-port br-ex $INTERFACE_NAME
 
cat > /etc/sysconfig/network-scripts/ifcfg-$INTERFACE_NAME <<EOF
 
DEVICE=$INTERFACE_NAME
 
TYPE=Ethernet
 
BOOTPROTO=none
 
ONBOOT=yes
 
EOF
 
systemctl restart network
 
crudini --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks  physnet1
 
crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types  flat
 
crudini --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs bridge_mappings  physnet1:br-ex
 
systemctl restart neutron-openvswitch-agent
 
 
 
 
 
tenantID=`openstack project list | grep service | awk '{print $2}'`
 
echo -e "\033[31m\nCreate a sample flat network\n\033[0m "
 
neutron net-create --tenant-id $tenantID sharednet1 --shared --provider:network_type flat --provider:physical_network physnet1
 
 
</nowiki>
 
计算节点:
 
 
<nowiki>#!/bin/bash
 
source /etc/xiandian/openrc.sh
 
ovs-vsctl add-br br-ex
 
ovs-vsctl add-port br-ex $INTERFACE_NAME
 
cat > /etc/sysconfig/network-scripts/ifcfg-$INTERFACE_NAME <<EOF
 
DEVICE=$INTERFACE_NAME
 
TYPE=Ethernet
 
BOOTPROTO=none
 
ONBOOT=yes
 
EOF
 
systemctl restart network
 
crudini --set  /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks physnet1
 
crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types  flat
 
crudini --set  /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs bridge_mappings  physnet1:br-ex
 
systemctl restart neutron-openvswitch-agent</nowiki>
 
 
==crudini用法==
 
 
crudini --set [--existing] config_file section [param] [value]
 
 
crudini --get [--format=sh|ini] config_file [section] [param]
 
 
crudini --del [--existing] config_file section [param]
 
 
crudini --merge [--existing] config_file [section]
 
 
crudini 用于操作ini文件,可以设置、获取、删除、合并其中的变量
 
 
其中:config_file 代表要操作的文件名,section 表示变量所在的部分,如以下配置文件:
 
 
<nowiki>[DEFAULT]
 
user = admin
 
passwd = admin
 
port = 8088
 
 
[URL]
 
client = 127.0.0.1:8088
 
admin = 127.0.0.1:8080
 
</nowiki>
 
 
section 则表示了以上配置文件中的DEFAULT 和 URL ,在命令中不需要加中括号[],param 则如user ,passwd,client 等。
 
 
===添加===
 
 
$ crudini --set config_file section parameter value
 
 
===更新===
 
 
$ crudini --set [--existing] config_file section parameter value
 
 
===删除===
 
 
删除变量:
 
 
$ crudini --del config_file section parameter
 
 
删除section:
 
 
$ crudini --del config_file section
 
 
===获取===
 
 
$ crudini --del config_file section parameter
 
 
如果该标量不在某一个section里面,则section用一个空字符表示:
 
 
$ crudini --del config_file '' parameter
 
 
===合并===
 
 
将another.ini配置文件合并到config_file中:
 
 
$ crudini --merge config_file < another.ini
 
  
  
本 节 完!</nowiki>
 
  
 
参考文档:https://xiexianbin.cn/linux/2017/04/12/linux-shell-crudini
 
参考文档:https://xiexianbin.cn/linux/2017/04/12/linux-shell-crudini

2019年4月17日 (三) 14:40的最新版本


创建网络(FLAT型)

Openstack6-1.png

Openstack6-2.png

显示结果如图:

Openstack6-3.png


创建子网

Opensstack6-4.png


Openstack6-5.png


Openstack6-9.png


Openstack6-8.png


查看网络拓扑

查看现有网络

Openstack6-10.png

查看一个网络的详细信息

Openstack6-11.png


列出路由信息

Openstack6-12.png




参考文档:https://xiexianbin.cn/linux/2017/04/12/linux-shell-crudini