增長p_w_picpath - 安裝和配置(controller)html
安裝包python
yum install -y openstack-glance python-glance python-glanceclientmysql
編輯配置文件linux
vi/etc/glance/glance-api.conf //更改或增長sql
[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/p_w_picpaths/
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數據庫數據vim
su -s /bin/sh -c"glance-manage db_sync" glanceapi
[root@controller profile.d]# su -s /bin/sh -c "glance-manage db_sync" glance No handlers could be found for logger "oslo_config.cfg" ---報錯能夠忽略
查看同步數據bash
[root@controller p_w_picpaths]# mysql -uglance -pglance MariaDB [glance]> show tables; +----------------------------------+ | Tables_in_glance | +----------------------------------+ | artifact_blob_locations | | artifact_blobs | | artifact_dependencies | | artifact_properties | | artifact_tags | | artifacts | | p_w_picpath_locations | | p_w_picpath_members | | p_w_picpath_properties | | p_w_picpath_tags | | p_w_picpaths | | 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
增長p_w_picpath - 驗證操做(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) 把剛剛下載的鏡像上傳到鏡像服務中心
glancep_w_picpath-create --name "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--visibility public --progress
而後咱們能夠在 /var/lib/glance/p_w_picpaths/目錄下看到一個文件,這個就是剛剛上傳的鏡像,你會發現這個文件的名字和id是一致的。
使用命令 glance p_w_picpath-list 能夠查看鏡像列表
[root@controller ~]# glance p_w_picpath-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/p_w_picpaths/ 6b44feb1-141c-4177-ba54-22bb927db70f [root@controller ~]#
而後咱們能夠在 /var/lib/glance/p_w_picpaths/目錄下看到一個文件,這個就是剛剛上傳的鏡像,你會發現這個文件的名字和id是一致的。
使用命令
glance p_w_picpath-list 能夠查看鏡像列表
[root@controller ~]# glance p_w_picpath-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 p_w_picpath-list
[root@controller ~]# nova p_w_picpath-list +--------------------------------------+--------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+--------+--------+--------+ | 6b44feb1-141c-4177-ba54-22bb927db70f | cirros | ACTIVE | | +--------------------------------------+--------+--------+--------+ [root@controller ~]#