得过且过 发表于 2018-6-1 06:33:46

openstack部署(二)

增加image - 安装和配置(controller)
安装包
yum install -y openstack-glance python-glance python-glanceclient
编辑配置文件
vi/etc/glance/glance-api.conf   //更改或增加


notificaction_driver= noop
verbose=True

connection =mysql://glance:glance@controller/glance

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

flavor =keystone

default_store =file
filesystem_store_datadir= /var/lib/glance/images/

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

notificaction_driver= noop
verbose=True

connection =mysql://glance:glance@controller/glance

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 =glancepassword =glance

flavor =keystone
同步glance数据库数据
su -s /bin/sh -c"glance-manage db_sync" glance
# su -s /bin/sh -c "glance-manage db_sync" glance
No handlers could be found for logger "oslo_config.cfg"   ---报错可以忽略查看同步数据
# mysql -uglance -pglance
MariaDB > 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 >有数据列表为正常
启动服务
systemctl enable openstack-glance-api.serviceopenstack-glance-registry.service
systemctl start openstack-glance-api.serviceopenstack-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

# 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)
Saving to: ‘cirros-0.3.4-x86_64-disk.img’
100%[==========================================================================================================>] 13,287,93665.6KB/s   in 2m 36s
2016-09-21 14:53:48 (83.0 KB/s) - ‘cirros-0.3.4-x86_64-disk.img’ saved



(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 可以查看镜像列表


# 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                               |
+------------------+--------------------------------------+
# ls /var/lib/glance/images/
6b44feb1-141c-4177-ba54-22bb927db70f
#

然后我们可以在 /var/lib/glance/images/目录下看到一个文件,这个就是刚刚上传的镜像,你会发现这个文件的名字和id是一致的。
使用命令
glance image-list 可以查看镜像列表
# glance image-list
+--------------------------------------+--------+
| ID                                 | Name   |
+--------------------------------------+--------+
| 6b44feb1-141c-4177-ba54-22bb927db70f | cirros |
+--------------------------------------+--------+
#

增加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
# source admin-openrc.sh
# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field   | Value                            |
+-----------+----------------------------------+
| domain_id | default                        |
| enabled   | True                           |
| id      | 4f11896bf74948b49afaf4c7894cd2e7 |
| name      | nova                           |
+-----------+----------------------------------+
#添加admin角色到nova用户openstack role add --project service --user nova admin
# openstack role add --project service --user nova admin
#创建nova服务实例 openstack service create --name nova   --description "OpenStack Compute" compute
# openstack service create --name nova   --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled   | True                           |
| id          | f0415bd0e594444cad00eaee81d842a2 |
| name      | nova                           |
| type      | compute                        |
+-------------+----------------------------------+
#

创建api端点
openstack endpoint create --region RegionOne compute public http://controller:8774/v2/%\(tenant_id\)s
# 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 |
+--------------+-----------------------------------------+
#openstack endpoint create --region RegionOne compute internal http://controller:8774/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOnecompute 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 |
+--------------+-----------------------------------------+
#openstack endpoint create --region RegionOne compute admin http://controller:8774/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOnecompute 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 |
+--------------+-----------------------------------------+
#


增加compute - 安装包并配置


# yum install openstack-nova-api openstack-nova-cert   openstack-nova-conductor openstack-nova-consoleopenstack-nova-novncproxy openstack-nova-schedulerpython-novaclient -y

编辑配置文件   
vi/etc/nova/nova.conf//更改或增加配置



connection = mysql://nova:nova@controller/nova

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

auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = serviceusername = nova
password = novapasswd

rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstackpasswd

vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
host = controller

lock_path = /var/lib/nova/tmp

同步数据创建nova库su -s /bin/sh -c "nova-manage db sync" nova
# su -s /bin/sh -c "nova-manage db sync" nova
No handlers could be found for logger "oslo_config.cfg"
#查看数据库同步情况:
有表为正常
MariaDB > 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)




# yum install openstack-nova-api openstack-nova-certopenstack-nova-conductor openstack-nova-consoleopenstack-nova-novncproxyopenstack-nova-scheduler python-novaclient -y

编辑配置文件


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



connection =mysql://nova:RYgv0rg7p@controller/nova

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

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 = novapassword =novapasswd

rabbit_host =controller
rabbit_userid =openstack
rabbit_password= openstackpasswd

vncserver_listen= $my_ip
vncserver_proxyclient_address= $my_ip

host =controller

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//更改或增加如下配置

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

rabbit_host =controller
rabbit_userid =openstack
rabbit_password= openstackpasswd

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

enabled = True
vncserver_listen= 0.0.0.0vncserver_proxyclient_address= $my_ip
novncproxy_base_url= http://controller:6080/vnc_auto.html

host =controller

lock_path =/var/lib/nova/tmp使用如下命令检查你的机器cpu是否支持虚拟化


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


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

如果得到的数字大于0,说明是支持的,否则说明不支持,若为0,需要编辑配置文件,不等于0就不用编辑配置
vi/etc/nova/nova.conf//编辑

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
novaservice-list
共有5个:nova-consolenova-conductornova-schedulernova-certnova-compute

# 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 | -               |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
#这个输出显示四个服务在控制节点启用,一个服务在计算节点
注意:此处有个坑比较大。可能出现计算节点没显示和state状态是其他,或是其他问题。http://www.tuicool.com/articles/JjuMvim


  tail -f /var/log/nova/nova-compute.log #日志信息很详细
列出api端点,一共有9组: nova三组,glance三组,keystone三组
nova endpoints

# 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   |
+-----------+----------------------------------+
#

如果有提示
WARNING: novahas no endpoint in ! Available endpoints for this service:
可以忽略掉,也可以编辑admin-openrc.sh   增加一行 export OS_REGION_NAME=RegionOne

# 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      |
+-----------+----------------------------------+
#

列出镜像
  在Image service 目录验证连接 Image service:
nova image-list
# nova image-list
+--------------------------------------+--------+--------+--------+
| ID                                 | Name   | Status | Server |
+--------------------------------------+--------+--------+--------+
| 6b44feb1-141c-4177-ba54-22bb927db70f | cirros | ACTIVE |      |
+--------------------------------------+--------+--------+--------+
#


  
页: [1]
查看完整版本: openstack部署(二)