增加p_w_picpath - 安装和配置(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/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数据库数据

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 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 ~]#