openstack部署(二)

增加image - 安裝和配置(controller)

安裝包

yum install -y openstack-glance python-glance python-glanceclient

編輯配置文件

vi/etc/glance/glance-api.conf   //更改或增加

 

[DEFAULT]
notificaction_driver= noop
verbose=True

[database]
connection =mysql://glance:glance@controller/glance
 
[keystone_authtoken]
auth_uri =http://controller:5000
auth_url =http://controller:35357
auth_plugin =password
project_domain_id= default
user_domain_id =default
project_name =service
username =glance
password =glancepasswd
[paste_deploy]
flavor =keystone
 
[glance_store]
default_store =file
filesystem_store_datadir= /var/lib/glance/images/


vi/etc/glance/glance-registry.conf  //更改或增加

[DEFAULT]
notificaction_driver= noop
verbose=True
 
[database]
connection =mysql://glance:glance@controller/glance
[keystone_authtoken]
auth_uri =http://controller:5000
auth_url =http://controller:35357
auth_plugin =password
project_domain_id= default
user_domain_id =default
project_name =service
username =glance
password =glance
[paste_deploy]
flavor =keystone

 

同步glance數據庫數據

su -s /bin/sh -c"glance-manage db_sync" glance

[root@controller profile.d]# su -s /bin/sh -c "glance-manage db_sync" glance
No handlers could be found for logger "oslo_config.cfg"   ---報錯可以忽略

查看同步數據

[root@controller images]# mysql -uglance -pglance
MariaDB [glance]> show tables;
+----------------------------------+
| Tables_in_glance                 |
+----------------------------------+
| artifact_blob_locations          |
| artifact_blobs                   |
| artifact_dependencies            |
| artifact_properties              |
| artifact_tags                    |
| artifacts                        |
| image_locations                  |
| image_members                    |
| image_properties                 |
| image_tags                       |
| images                           |
| metadef_namespace_resource_types |
| metadef_namespaces               |
| metadef_objects                  |
| metadef_properties               |
| metadef_resource_types           |
| metadef_tags                     |
| migrate_version                  |
| task_info                        |
| tasks                            |
+----------------------------------+
20 rows in set (0.00 sec)
MariaDB [glance]>

有數據列表爲正常

啓動服務

systemctl enable openstack-glance-api.service  openstack-glance-registry.service

systemctl start openstack-glance-api.service  openstack-glance-registry.service



增加image - 驗證操作(controller)     

(1) 添加環境變量

echo"export OS_IMAGE_API_VERSION=2"  | tee -a admin-openrc.sh demo-openrc.sh

 

(2) 執行admin-openrc.sh

source admin-openrc.sh

 

(3) 下載鏡像

wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

 

[root@controller ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
--2016-09-21 14:51:01--  http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13287936 (13M) [text/plain]
Saving to: ‘cirros-0.3.4-x86_64-disk.img’

100%[==========================================================================================================>] 13,287,936  65.6KB/s   in 2m 36s 

2016-09-21 14:53:48 (83.0 KB/s) - ‘cirros-0.3.4-x86_64-disk.img’ saved [13287936/13287936]



(4) 把剛剛下載的鏡像上傳到鏡像服務中心

glanceimage-create --name "cirros" \

 --file cirros-0.3.4-x86_64-disk.img \

 --disk-format qcow2 --container-format bare \

 --visibility public --progress

 

然後我們可以在 /var/lib/glance/images/目錄下看到一個文件,這個就是剛剛上傳的鏡像,你會發現這個文件的名字和id是一致的。

使用命令  glance image-list 可以查看鏡像列表



[root@controller ~]# glance image-create --name "cirros" \
>  --file cirros-0.3.4-x86_64-disk.img \
>  --disk-format qcow2 --container-format bare \
>  --visibility public --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2016-09-21T06:54:14Z                 |
| disk_format      | qcow2                                |
| id               | 6b44feb1-141c-4177-ba54-22bb927db70f |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros                               |
| owner            | ed1396bac8b14d969693e7f019dd5230     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2016-09-21T06:54:15Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+
[root@controller ~]# ls /var/lib/glance/images/
6b44feb1-141c-4177-ba54-22bb927db70f
[root@controller ~]#


然後我們可以在 /var/lib/glance/images/目錄下看到一個文件,這個就是剛剛上傳的鏡像,你會發現這個文件的名字和id是一致的。

使用命令  

glance image-list 可以查看鏡像列表

[root@controller ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 6b44feb1-141c-4177-ba54-22bb927db70f | cirros |
+--------------------------------------+--------+
[root@controller ~]#


增加compute - 前期準備(controller)


compute又叫nova,是OpenStack中的計算組織控制器。OpenStack中實例(instances)生命週期的所有活動都由Nova處理。這樣使得Nova成爲一個負責管理計算資源、網絡、認證、所需可擴展性的平臺。但是,Nova自身並沒有提供任何虛擬化能力,相反它使用libvirt API來與被支持的Hypervisors(kvm、xen、vmware等)交互。

創建nova庫,並創建nova用戶  

mysql -uroot -proot

MariaDB [(none)]> create database nova;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost'    IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%'    IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>


初始化環境變量   source admin-openrc.sh

創建nova用戶 密碼爲( novapasswd)

 openstack user create --domain default --password-prompt nova

[root@controller ~]# source admin-openrc.sh 
[root@controller ~]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | 4f11896bf74948b49afaf4c7894cd2e7 |
| name      | nova                             |
+-----------+----------------------------------+
[root@controller ~]#

添加admin角色到nova用戶  openstack role add --project service --user nova admin

[root@controller profile.d]# openstack role add --project service --user nova admin
[root@controller profile.d]#

創建nova服務實例 openstack service create --name nova   --description "OpenStack Compute" compute

[root@controller profile.d]# openstack service create --name nova   --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | f0415bd0e594444cad00eaee81d842a2 |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+
[root@controller profile.d]#


創建api端點

openstack endpoint create --region RegionOne compute public http://controller:8774/v2/%\(tenant_id\)s

[root@controller profile.d]# openstack endpoint create --region RegionOne compute public http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | c3cc5002d6cb41e7aa0ef49a6a44ed74        |
| interface    | public                                  |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | f0415bd0e594444cad00eaee81d842a2        |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller profile.d]#

openstack endpoint create --region RegionOne compute internal http://controller:8774/v2/%\(tenant_id\)s

[root@controller profile.d]# openstack endpoint create --region RegionOne  compute internal http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | 26797406951f43a68340dcfbf098926f        |
| interface    | internal                                |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | f0415bd0e594444cad00eaee81d842a2        |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller profile.d]#

openstack endpoint create --region RegionOne compute admin http://controller:8774/v2/%\(tenant_id\)s

[root@controller profile.d]# openstack endpoint create --region RegionOne  compute admin http://controller:8774/v2/%\(tenant_id\)s
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| enabled      | True                                    |
| id           | 4a23043c9e90426490537ba587df3935        |
| interface    | admin                                   |
| region       | RegionOne                               |
| region_id    | RegionOne                               |
| service_id   | f0415bd0e594444cad00eaee81d842a2        |
| service_name | nova                                    |
| service_type | compute                                 |
| url          | http://controller:8774/v2/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller profile.d]#


增加compute - 安裝包並配置


[root@controller profile.d]# yum install openstack-nova-api openstack-nova-cert   openstack-nova-conductor openstack-nova-console  openstack-nova-novncproxy openstack-nova-scheduler  python-novaclient -y


編輯配置文件   

vi  /etc/nova/nova.conf  //更改或增加配置


[database]
connection = mysql://nova:nova@controller/nova
[DEFAULT]
rpc_backend=rabbit
my_ip=192.168.100.20
auth_strategy=keystone
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
verbose=true
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = nova
password = novapasswd
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstackpasswd
[vnc]
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[glance]
host = controller
[oslo_concurrency]
lock_path = /var/lib/nova/tmp


同步數據創建nova庫  su -s /bin/sh -c "nova-manage db sync" nova

[root@controller profile.d]# su -s /bin/sh -c "nova-manage db sync" nova
No handlers could be found for logger "oslo_config.cfg"
[root@controller profile.d]#

查看數據庫同步情況:

有表爲正常

MariaDB [nova]> show tables;
+--------------------------------------------+
| Tables_in_nova                             |
+--------------------------------------------+
| agent_builds                               |
| aggregate_hosts                            |
| aggregate_metadata                         |
| aggregates                                 |
| block_device_mapping                       
部分表數據

啓動服務

systemctl enable openstack-nova-api.service \

 openstack-nova-cert.service openstack-nova-consoleauth.service \

 openstack-nova-scheduler.service openstack-nova-conductor.service \

 openstack-nova-novncproxy.service

systemctl start openstack-nova-api.service \

 openstack-nova-cert.service openstack-nova-consoleauth.service \

 openstack-nova-scheduler.service openstack-nova-conductor.service \

 openstack-nova-novncproxy.service



增加compute - 安裝包並配置(controller)



[root@controller ~]# yum install openstack-nova-api openstack-nova-cert  openstack-nova-conductor openstack-nova-console  openstack-nova-novncproxyopenstack-nova-scheduler python-novaclient -y


編輯配置文件  


vi  /etc/nova/nova.conf  //更改或增加配置


[database]
connection =mysql://nova:RYgv0rg7p@controller/nova
 
[DEFAULT]
rpc_backend=rabbit
my_ip = 192.168.16.111
auth_strategy = keystone
network_api_class= nova.network.neutronv2.api.API
security_group_api= neutron
linuxnet_interface_driver= nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
firewall_driver= nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
verbose = True
[keystone_authtoken]
auth_uri =http://controller:5000
auth_url =http://controller:35357
auth_plugin =password
project_domain_id= default
user_domain_id =default
project_name =service
username = nova
password =novapasswd
 
[oslo_messaging_rabbit]
rabbit_host =controller
rabbit_userid =openstack
rabbit_password= openstackpasswd
 
[vnc]
vncserver_listen= $my_ip
vncserver_proxyclient_address= $my_ip
 
[glance]
host =controller
[oslo_concurrency]
lock_path =/var/lib/nova/tmp


同步數據創建nova庫


 su -s /bin/sh -c "nova-manage dbsync" nova


啓動服務


systemctl enableopenstack-nova-api.service \

 openstack-nova-cert.serviceopenstack-nova-consoleauth.service \

 openstack-nova-scheduler.serviceopenstack-nova-conductor.service \

 openstack-nova-novncproxy.service

systemctl startopenstack-nova-api.service \

 openstack-nova-cert.serviceopenstack-nova-consoleauth.service \

 openstack-nova-scheduler.serviceopenstack-nova-conductor.service \

 openstack-nova-novncproxy.service

 

 

增加compute - 安裝包並配置(compute) 


安裝nova-compute包 

yum install -y openstack-nova-compute sysfsutils

 

編輯配置文件 

vi  /etc/nova/nova.conf  //更改或增加如下配置

[DEFAULT]
rpc_backend =rabbit
auth_strategy =keystone
my_ip =192.168.16.112
network_api_class= nova.network.neutronv2.api.API
security_group_api= neutron
linuxnet_interface_driver= nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver
firewall_driver= nova.virt.firewall.NoopFirewallDriver
verbose=true
[oslo_messaging_rabbit]
rabbit_host =controller
rabbit_userid =openstack
rabbit_password= openstackpasswd
 
[keystone_authtoken]
auth_uri =http://controller:5000
auth_url =http://controller:35357
auth_plugin =password
project_domain_id= default
user_domain_id =default
project_name =service
username = nova
password =novapasswd
[vnc]
enabled = True
vncserver_listen= 0.0.0.0
vncserver_proxyclient_address= $my_ip
novncproxy_base_url= http://controller:6080/vnc_auto.html
[glance]
host =controller
[oslo_concurrency]
lock_path =/var/lib/nova/tmp

使用如下命令檢查你的機器cpu是否支持虛擬化


egrep -c '(vmx|svm)' /proc/cpuinfo


[root@compute ~]# egrep -c '(vmx|svm)' /proc/cpuinfo
1
[root@compute ~]#


如果得到的數字大於0,說明是支持的,否則說明不支持,若爲0,需要編輯配置文件,不等於0就不用編輯配置

vi  /etc/nova/nova.conf  //編輯

[libvirt]

virt_type = qemu

 

啓動服務

systemctl enablelibvirtd.service openstack-nova-compute.service

systemctl startlibvirtd.service openstack-nova-compute.service 

執行腳本

source admin-openrc.sh

 


驗證安裝【控制節點】


列出服務組件

source admin-openrc.sh

nova  service-list

共有5個:nova-console  nova-conductor  nova-scheduler  nova-cert  nova-compute

 

[root@controller ~]# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host       | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-conductor   | controller | internal | enabled | up    | 2016-09-23T03:22:51.000000 | -               |
| 2  | nova-scheduler   | controller | internal | enabled | up    | 2016-09-23T03:22:51.000000 | -               |
| 3  | nova-consoleauth | controller | internal | enabled | up    | 2016-09-23T03:22:51.000000 | -               |
| 4  | nova-cert        | controller | internal | enabled | up    | 2016-09-23T03:22:51.000000 | -               |
| 5  | nova-compute     | compute    | nova     | enabled | up    | 2016-09-23T03:22:53.000000 | -               |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
[root@controller ~]#

這個輸出顯示四個服務在控制節點啓用,一個服務在計算節點

注意:此處有個坑比較大。可能出現計算節點沒顯示和state狀態是其他,或是其他問題。http://www.tuicool.com/articles/JjuMvim


tail -f /var/log/nova/nova-compute.log #日誌信息很詳細

列出api端點,一共有9組: nova三組,glance三組,keystone三組

nova endpoints

 

[root@controller ~]# nova endpoints
WARNING: glance has no endpoint in ! Available endpoints for this service:
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id        | 95a77b2444c74cc0bb135fde881ac453 |
| interface | admin                            |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292           |
+-----------+----------------------------------+
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id        | d12aa53e769442bcb4bfd75ca75bbad0 |
| interface | public                           |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292           |
+-----------+----------------------------------+
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id        | d3add6d0b0614e88a4adde93653b8b29 |
| interface | internal                         |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292           |
+-----------+----------------------------------+
WARNING: nova has no endpoint in ! Available endpoints for this service:
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id        | 26797406951f43a68340dcfbf098926f                           |
| interface | internal                                                   |
| region    | RegionOne                                                  |
| region_id | RegionOne                                                  |
| url       | http://controller:8774/v2/ed1396bac8b14d969693e7f019dd5230 |
+-----------+------------------------------------------------------------+
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id        | 4a23043c9e90426490537ba587df3935                           |
| interface | admin                                                      |
| region    | RegionOne                                                  |
| region_id | RegionOne                                                  |
| url       | http://controller:8774/v2/ed1396bac8b14d969693e7f019dd5230 |
+-----------+------------------------------------------------------------+
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id        | c3cc5002d6cb41e7aa0ef49a6a44ed74                           |
| interface | public                                                     |
| region    | RegionOne                                                  |
| region_id | RegionOne                                                  |
| url       | http://controller:8774/v2/ed1396bac8b14d969693e7f019dd5230 |
+-----------+------------------------------------------------------------+
WARNING: keystone has no endpoint in ! Available endpoints for this service:
+-----------+----------------------------------+
| keystone  | Value                            |
+-----------+----------------------------------+
| id        | 2347aed007ca49fe845e4ee7940689b4 |
| interface | public                           |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:5000/v2.0      |
+-----------+----------------------------------+
+-----------+----------------------------------+
| keystone  | Value                            |
+-----------+----------------------------------+
| id        | e049b49ff24646ee95bfcbe8addcfbff |
| interface | internal                         |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:5000/v2.0      |
+-----------+----------------------------------+
+-----------+----------------------------------+
| keystone  | Value                            |
+-----------+----------------------------------+
| id        | ef867ab9497d4aeab1c0c0b088fbf901 |
| interface | admin                            |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:35357/v2.0     |
+-----------+----------------------------------+
[root@controller ~]#


如果有提示

WARNING: novahas no endpoint in ! Available endpoints for this service:

可以忽略掉,也可以編輯  admin-openrc.sh   增加一行 export OS_REGION_NAME=RegionOne 

 

[root@controller ~]# nova endpoints
+-----------+----------------------------------+
| glance    | Value                            |
+-----------+----------------------------------+
| id        | 95a77b2444c74cc0bb135fde881ac453 |
| interface | admin                            |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:9292           |
+-----------+----------------------------------+
+-----------+------------------------------------------------------------+
| nova      | Value                                                      |
+-----------+------------------------------------------------------------+
| id        | 26797406951f43a68340dcfbf098926f                           |
| interface | internal                                                   |
| region    | RegionOne                                                  |
| region_id | RegionOne                                                  |
| url       | http://controller:8774/v2/ed1396bac8b14d969693e7f019dd5230 |
+-----------+------------------------------------------------------------+
+-----------+----------------------------------+
| keystone  | Value                            |
+-----------+----------------------------------+
| id        | 2347aed007ca49fe845e4ee7940689b4 |
| interface | public                           |
| region    | RegionOne                        |
| region_id | RegionOne                        |
| url       | http://controller:5000/v2.0      |
+-----------+----------------------------------+
[root@controller ~]#


列出鏡像

在Image service 目錄驗證連接 Image service:

nova image-list 

[root@controller ~]# nova image-list 
+--------------------------------------+--------+--------+--------+
| ID                                   | Name   | Status | Server |
+--------------------------------------+--------+--------+--------+
| 6b44feb1-141c-4177-ba54-22bb927db70f | cirros | ACTIVE |        |
+--------------------------------------+--------+--------+--------+
[root@controller ~]#


  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章