-
1.知識回顧與端口總結
service | 功能 |
---|---|
MySQL | 為各個服務提供數據存儲 |
RabbitMQ | 為各個服務之間通信提供交通樞紐 |
Keystone | 為各個服務器之間通信提供認證和服務注冊 |
Glance | 為虛擬機提供鏡像管理 |
Nova | 為虛擬機提供計算資源 |
Neutron | 為虛擬機提供網絡資源 |
各服務端口列表
服務 | 端口 |
---|---|
MySQL | 3306 |
Memcached | 11211 |
Glance-api | 9292 |
Glance-registry | 9191 |
RabbitMQ | 15672、5672 |
Libvirt Dnsmasq | 53 |
Novncproxy | 6080 |
Nova-api | 8774、8775 |
Kesytone(admin) | 35357 |
Kesytone(user) | 5000 |
Neutron | 9696 |
Cinder-api | 8776 |
-
2.確保以下三項結果是正常,才能進行創建虛擬機
[root@linux-node1 ~]# openstack image list +--------------------------------------+-----------------+--------+ | ID | Name | Status | +--------------------------------------+-----------------+--------+ | 5aa6e9a1-4aea-467c-a684-51080c326887 | Centos-7-x86_64 | active | | 51e1e125-dbe3-49c6-a3d5-55c89f195f55 | cirros | active | +--------------------------------------+-----------------+--------+ [root@linux-node1 ~]# nova service-list +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | 1 | nova-consoleauth | linux-node1 | internal | enabled | up | 2017-12-12T04:39:01.000000 | - | | 2 | nova-conductor | linux-node1 | internal | enabled | up | 2017-12-12T04:39:06.000000 | - | | 3 | nova-scheduler | linux-node1 | internal | enabled | up | 2017-12-12T04:39:07.000000 | - | | 6 | nova-compute | linux-node2 | nova | enabled | up | 2017-12-12T04:39:06.000000 | - | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ [root@linux-node1 ~]# neutron agent-list +--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+ | id | agent_type | host | availability_zone | alive | admin_state_up | binary | +--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+ | 308df597-c196-40e8-9894-b35f423ce9e4 | Linux bridge agent | linux-node2 | | :-) | True | neutron-linuxbridge-agent | | 598023d4-52a2-44d5-92fe-61376efa941e | Metadata agent | linux-node1 | | :-) | True | neutron-metadata-agent | | a824342c-ad84-4c05-a4a9-80f5025d6ae5 | Linux bridge agent | linux-node1 | | :-) | True | neutron-linuxbridge-agent | | e116c29d-ce28-4d84-8433-214590e97c69 | DHCP agent | linux-node1 | nova | :-) | True | neutron-dhcp-agent | +--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+
-
3.雲主機創建
(1)創建網絡
[root@linux-node1 ~]# openstack network create --share \ --provider-physical-network public \ --provider-network-type flat public [root@linux-node1 ~]# neutron net-list +--------------------------------------+--------+------------------------------------------------------+ | id | name | subnets | +--------------------------------------+--------+------------------------------------------------------+ | c39c1348-5a8f-4291-9772-b03a22b085df | public | df82f43f-97fe-41d0-bdbd-933565102598 192.168.56.0/24 | +--------------------------------------+--------+------------------------------------------------------+
(2)創建子網
[root@linux-node1 ~]# openstack subnet create --network public \ --allocation-pool start=192.168.56.100,end=192.168.56.200 \ --dns-nameserver 192.168.56.2 --gateway 192.168.56.2 \ --subnet-range 192.168.56.0/24 public-subnet [root@linux-node1 ~]# neutron subnet-list +--------------------------------------+---------------+-----------------+------------------------------------------------------+ | id | name | cidr | allocation_pools | +--------------------------------------+---------------+-----------------+------------------------------------------------------+ | df82f43f-97fe-41d0-bdbd-933565102598 | public-subnet | 192.168.56.0/24 | {"start": "192.168.56.100", "end": "192.168.56.200"} | +--------------------------------------+---------------+-----------------+------------------------------------------------------+
(3)創建m1.nano類型
默認的最小規格的主機需要512 MB內存。對於環境中計算節點內存不足4 GB的,我們推薦創建只需要64 MB的m1.nano
規格的主機。若單純為了測試的目的,請使用m1.nano
規格的主機來加載CirrOS鏡像
[root@linux-node1 ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
(4)生成一個鍵值對
大部分雲鏡像支持 :term:public key authentication
而不是傳統的密碼登陸。在啟動實例前,你必須添加一個公共密鑰到計算服務。
生成的公鑰上傳到openstack,會自動把這個公鑰放入虛擬機,之后登陸無需密碼。
[root@linux-node1 ~]# source demo-openstack [root@linux-node1 ~]# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa): [root@linux-node1 ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
驗證公鑰添加:
[root@linux-node1 ~]# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | e4:ce:48:da:e7:03:b3:a9:85:c6:7a:11:bf:a0:8f:85 | +-------+-------------------------------------------------+
(5)增加安全組規則
默認情況下, default
安全組適用於所有實例並且包括拒絕遠程訪問實例的防火牆規則。對諸如CirrOS這樣的Linux鏡像,我們推薦至少允許ICMP (ping) 和安全shell(SSH)規則。
•添加規則到default安全組,會去修改iptables規則
允許ping
[root@linux-node1 ~]# openstack security group rule create --proto icmp default
允許安全shell(SSH)的訪問 [root@linux-node1 ~]# openstack security group rule create --proto tcp --dst-port 22 default
(6)確定實例選項
①在控制節點上,獲得 admin 憑證來獲取只有管理員能執行的命令的訪問權限: [root@linux-node1 ~]# source demo-openstack ②一個實例指定了虛擬機資源的大致分配,包括處理器、內存和存儲。 列出可用類型: [root@linux-node1 ~]# openstack flavor list
③列出可用鏡像
[root@linux-node1 ~]# openstack image list
④列出可用網絡
[root@linux-node1 ~]# openstack network list
⑤列出可用的安全組
[root@linux-node1 ~]# openstack security group list
(7)啟動實例
[root@linux-node1 ~]# openstack server create --flavor m1.nano --image cirros \ --nic net-id=c39c1348-5a8f-4291-9772-b03a22b085df \ --security-group default \ --key-name mykey demo-instance
檢查實例狀態,當構建過程完全成功后,狀態會從BUILD變為ACTIVE
[root@linux-node1 ~]# openstack server list
(8)使用虛擬控制台訪問實例
獲取你實例的 Virtual Network Computing (VNC) 會話URL並從web瀏覽器訪問它:
[root@linux-node1 ~]# openstack console url show demo-instance
在宿主機上使用ssh登陸:
問題總結:
問題現象:ping雲主機網絡不通,從VNC上看到系統一直停留在GRUB,無法進入系統,導致無法正常創建雲主機
問題原因:libvirtd、qemu與內核版本不兼容
解決方案:降低內核版本
降低CentOS 7.3的內核版本執行過程:
查看當前內核版本:
[root@linux-node1 ~]# uname -r 3.10.0-514.2.2.el7.x86_64
查看當前發行版本:
[root@linux-node1 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)
降低內核版本方法:
(1)解壓安裝鏡像,獲取內核軟件包:
kernel-3.10.0-327.el7.x86_64.rpm kernel-tools-3.10.0-327.el7.x86_64.rpm kernel-tools-libs-3.10.0-327.el7.x86_64.rpm centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm
(2)先安裝這2個包:
[root@linux-node1 ~]# rpm -ivh kernel-tools-3.10.0-327.el7.x86_64.rpm [root@linux-node1 ~]# rpm -ivh kernel-tools-libs-3.10.0-327.el7.x86_64.rpm
(3)再安裝kernel-3.10.0-327.el7.x86_64.rpm
[root@linux-node1 ~]# rpm -ivh --force kernel-3.10.0-327.el7.x86_64.rpm
(4)可以查看到安裝的2個版本的內核:
[root@linux-node1 ~]# rpm -qa|grep -i kernel-3.10.0- kernel-3.10.0-327.el7.x86_64.rpm kernel-3.10.0-514.2.2.el7.x86_64
(5)把7.3的內核卸載:
[root@linux-node1 ~]# rpm -ev kernel-3.10.0-514.2.2.el7.x86_64 這時候只能查看一個結果: [root@linux-node1 ~]# rpm -qa|grep -i kernel-3.10.0- kernel-3.10.0-327.el7.x86_64.rpm 再用rpm -ea 或者 yum remove命令卸載其他內核相關的包 rpm -ea kernel-tools-libs-3.10.0-514.2.2.el7.x86_64 rpm -ea kernel-tools-3.10.0-514.2.2.el7.x86_64
降低發行版本:
[root@linux-node1 ~]# rpm -ivh centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm--force Preparing... ################################# [100%] Updating / installing... 1:centos-release-7-2.1511.el7.cento################################# [100%]
(1)可以查看到安裝的2個發行版本:
[root@linux-node1 ~]# rpm -qa|grep -i centos-release-7- centos-release-7-3.1611.el7.centos.x86_64 centos-release-7-2.1511.el7.centos.2.10.x86_64
(2)把7.3的發行版本卸載:
[root@linux-node1 ~]# rpm -ev centos-release-7-3.1611.el7.centos.x86_64 Preparing packages... centos-release-7-3輸出.1611.el7.centos.x86_64
(3)這時候只能查看一個結果:
[root@controller ~]# rpm -qa|grep -i centos-release-7- centos-release-7-2.1511.el7.centos.2.10.x86_64
驗證:
查看此時的內核版本: [root@controller ~]# uname -r 3.10.0-514.2.2.el7.x86_64 查看此時的發行版本: [root@controller ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 重啟: [root@controller ~]# reboot