IP地址 主機名 操做系統 192.168.56.11 linux-node1 CentOS7 192.168.56.12 linux-node2 CentOS7
其中,linux-node1看成控制節點node
linux-node2看成計算節點linux
阿里雲主機,兩個網卡,一個外網,一個內網網卡。web
因此咱們模擬阿里云云主機,須要添加在原有基礎上再添加一塊網卡。vim
打開wmware workstation,點「編輯」--「虛擬網絡編輯器」,打開後,編輯VMnet1,類型選擇僅主機,子網地址選擇192.168.57.0,同時將「使用本地DHCP服務將IP地址分配給虛擬機」取消掉,單擊肯定按鈕。安全
接下來爲控制節點和計算節點添加網卡 選擇linux-node1,「設置」--「網絡適配器」,下一步添加網絡鏈接,選擇自定義特定虛擬網絡--「VMnet1(僅主機模式)」,點擊「完成」--「肯定」網絡
用一樣的方式爲linux-node2添加網卡。app
[root@linux-node1 ~]# cd /etc/sysconfig/network-scripts/ [root@linux-node1 network-scripts]# cp ifcfg-eth0 ifcfg-eth1 [root@linux-node1 network-scripts]# cat ifcfg-eth1 TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eth1 DEVICE=eth1 ONBOOT=yes IPADDR0=192.168.57.11 PREFIX0=24
啓動並查看eth1編輯器
[root@linux-node1 network-scripts]# ifup eth1 [root@linux-node1 network-scripts]# ifconfig eth0: flags=4163mtu 1500 inet 192.168.56.11 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::20c:29ff:fe4c:a40b prefixlen 64 scopeid 0x20 ether 00:0c:29:4c:a4:0b txqueuelen 1000 (Ethernet) RX packets 14383 bytes 3982904 (3.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13871 bytes 9990604 (9.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth1: flags=4163mtu 1500 inet 192.168.57.11 netmask 255.255.255.0 broadcast 192.168.57.255 inet6 fe80::20c:29ff:fe4c:a415 prefixlen 64 scopeid 0x20 ether 00:0c:29:4c:a4:15 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 888 (888.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10loop txqueuelen 0 (Local Loopback) RX packets 74878 bytes 29270386 (27.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 74878 bytes 29270386 (27.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 tap50360466-68: flags=4163mtu 1500 ether 7e:24:2c:64:4f:0b txqueuelen 1000 (Ethernet) RX packets 8 bytes 648 (648.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
使用一樣的方法配置linux-node2ide
在控制節點上修改linuxbridge_agent.inioop
[root@linux-node1 network-scripts]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini physical_interface_mappings = public:eth0,internet:eth1 查看配置 [root@linux-node1 network-scripts]# grep '^[a-Z]' /etc/neutron/plugins/ml2/linuxbridge_agent.ini physical_interface_mappings = public:eth0,internet:eth1 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver enable_security_group = true enable_vxlan = false
修改ml2_conf.ini
[root@linux-node1 network-scripts]# vim /etc/neutron/plugins/ml2/ml2_conf.ini flat_networks = public,internet 查看配置 [root@linux-node1 network-scripts]# grep '^[a-Z]' /etc/neutron/plugins/ml2/ml2_conf.ini type_drivers = flat,vlan,vxlan,gre,geneve tenant_network_types = mechanism_drivers = linuxbridge,openvswitch extension_drivers = port_security flat_networks = public,internet enable_ipset = true [root@linux-node1 netwo
重啓linuxbridge
[root@linux-node1 network-scripts]# systemctl restart neutron-linuxbridge-agent
在計算節點上配置linuxbridger_agent.ini
[root@linux-node2 ~]# grep '^[a-Z]' /etc/neutron/plugins/ml2/linuxbridge_agent.ini physical_interface_mappings = public:eth0,internet:eth1 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver enable_security_group = True enable_vxlan = True
重啓linuxbridge
[root@linux-node2 network-scripts]# systemctl restart neutron-linuxbridge-agent
在控制節點上重啓neutron-server
[root@linux-node1 network-scripts]# systemctl restart neutron-server
先執行一下環境變量
[root@linux-node1 ~]# source admin-openstack.sh
建立internet網絡
[root@linux-node1 ~]# neutron net-create --shared --provider:physical_network internet --provider:network_type flat internet-net Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | availability_zone_hints | | | availability_zones | | | created_at | 2016-11-16T13:51:07 | | description | | | id | 00c9b5e2-f29e-4afd-a7e2-f9c47a457644 | | ipv4_address_scope | | | ipv6_address_scope | | | mtu | 1500 | | name | internet-net | | port_security_enabled | True | | provider:network_type | flat | | provider:physical_network | internet | | provider:segmentation_id | | | router:external | False | | shared | True | | status | ACTIVE | | subnets | | | tags | | | tenant_id | 53f72af1420a4d098d48f2c82d7e9ec7 | | updated_at | 2016-11-16T13:51:07 | +---------------------------+--------------------------------------+
建立子網
[root@linux-node1 ~]# neutron subnet-create --name internet-subnet \ > --allocation-pool start=192.168.57.100,end=192.168.57.200 \ > --dns-nameserver 223.5.5.5 internet-net 192.168.57.0/24 Created a new subnet: +-------------------+------------------------------------------------------+ | Field | Value | +-------------------+------------------------------------------------------+ | allocation_pools | {"start": "192.168.57.100", "end": "192.168.57.200"} | | cidr | 192.168.57.0/24 | | created_at | 2016-11-16T14:03:27 | | description | | | dns_nameservers | 223.5.5.5 | | enable_dhcp | True | | gateway_ip | 192.168.57.1 | | host_routes | | | id | 92311aff-245c-4663-aa93-a8b2e2b780a1 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | internet-subnet | | network_id | 00c9b5e2-f29e-4afd-a7e2-f9c47a457644 | | subnetpool_id | | | tenant_id | 53f72af1420a4d098d48f2c82d7e9ec7 | | updated_at | 2016-11-16T14:03:27 | +-------------------+------------------------------------------------------+
查看一下剛纔建立的網絡
[root@linux-node1 ~]# neutron net-list +--------------------------------------+--------------+------------------------------------------------------+ | id | name | subnets | +--------------------------------------+--------------+------------------------------------------------------+ | 2cbfb54c-b760-41e1-ba69-83131220463b | public-net | 80f2d649-7882-4625-9f07-03ad96e5be9a 192.168.57.0/24 | | | | | 00c9b5e2-f29e-4afd-a7e2-f9c47a457644 | internet-net | 92311aff-245c-4663-aa93-a8b2e2b780a1 192.168.57.0/24 | +--------------------------------------+--------------+------------------------------------------------------+
接下來就能夠登陸到192.168.56.11/dashboard,建立雲主機了
用戶名:demo
密碼:demo
登陸進去後,在頁面左側選擇雲主機,進入雲主機管理頁面,單擊「建立雲主機」,就能夠開始建立主機了
輸入實例名稱,即主機名
選擇引導源,這裏我選擇了一個小鏡像,便於測試
選擇套餐,即給雲主機配置cpu、磁盤和內存的大小
選擇網絡,添加雙網卡
選擇安全組
選擇密碼對,用於後面登陸雲主機
配置完成後,點擊啓動實例,就開始建立雲主機了。
建立完成後,能夠在雲主機列表中查看雲主機。
點擊控制檯,能夠經過web界面登錄雲主機。
查看網絡配置,能夠看到網絡配置成功,能鏈接外網
查看網絡拓撲
綜上,咱們能夠利用openstack neutron建立阿里雲ecs網絡