openstack部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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:[email protected]/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:[email protected]/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
[[email protected] profile.d]# su -s /bin/sh -c "glance-manage db_sync" glance No handlers could be found for logger "oslo_config.cfg" ---报错可以忽略
查看同步数据
[[email protected] 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
[[email protected] ~]# 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 可以查看镜像列表
[[email protected] ~]# 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 | +------------------+--------------------------------------+ [[email protected] ~]# ls /var/lib/glance/images/ 6b44feb1-141c-4177-ba54-22bb927db70f [[email protected] ~]#
然后我们可以在 /var/lib/glance/images/目录下看到一个文件,这个就是刚刚上传的镜像,你会发现这个文件的名字和id是一致的。
使用命令
glance image-list 可以查看镜像列表
[[email protected] ~]# glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 6b44feb1-141c-4177-ba54-22bb927db70f | cirros | +--------------------------------------+--------+ [[email protected] ~]#
增加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
[[email protected] profile.d]# source admin-openrc.sh [[email protected] profile.d]# openstack user create --domain default --password-prompt nova User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | 6bbf4cec693d4a85802712a6b83cea38 | | name | nova | +-----------+----------------------------------+ [[email protected] profile.d]#
添加admin角色到nova用户 openstack role add --project service --user nova admin
[[email protected] profile.d]# openstack role add --project service --user nova admin [[email protected] profile.d]#
创建nova服务实例 openstack service create --name nova --description "OpenStack Compute" compute
[[email protected] profile.d]# openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | f0415bd0e594444cad00eaee81d842a2 | | name | nova | | type | compute | +-------------+----------------------------------+ [[email protected] profile.d]#
创建api端点
openstack endpoint create --region RegionOne compute public http://controller:8774/v2/%\(tenant_id\)s
[[email protected] 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 | +--------------+-----------------------------------------+ [[email protected] profile.d]#
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2/%\(tenant_id\)s
[[email protected] 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 | +--------------+-----------------------------------------+ [[email protected] profile.d]#
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2/%\(tenant_id\)s
[[email protected] 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 | +--------------+-----------------------------------------+ [[email protected] profile.d]#
增加compute - 安装包并配置
[[email protected] 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:[email protected]/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 = openstack [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
[[email protected] profile.d]# su -s /bin/sh -c "nova-manage db sync" nova No handlers could be found for logger "oslo_config.cfg" [[email protected] 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)
[[email protected] ~]# 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:[email protected]/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 =hsSNsqc43 [oslo_messaging_rabbit] rabbit_host =controller rabbit_userid =openstack rabbit_password= o3NXovnz5 [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
[[email protected] ~]# egrep -c ‘(vmx|svm)‘ /proc/cpuinfo 1 [[email protected] ~]#
如果得到的数字大于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
列出服务组件
novaservice-list
共有5个:nova-consoleauthnova-conductor nova-scheduler nova-cert nova-compute
列出api端点,一共有9组: nova三组,glance三组,keystone三组
nova endpoints
如果有提示
WARNING: novahas no endpoint in ! Available endpoints for this service:
可以忽略掉,也可以编辑 admin-openrc.sh 增加一行 export OS_REGION_NAME=RegionOne
列出镜像
nova image-list
--未完待续---
本文出自 “时光依然轻擦” 博客,请务必保留此出处http://xulianglinux.blog.51cto.com/8001428/1855385
以上是关于openstack部署的主要内容,如果未能解决你的问题,请参考以下文章