十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
IP地址 主机名 操作系统 192.168.56.11 linux-node1 CentOS7 192.168.56.12 linux-node2 CentOS7
其中,linux-node1当作控制节点
创新互联公司是一家专业提供高陵企业网站建设,专注与成都网站设计、网站制作、成都h5网站建设、小程序制作等业务。10年已为高陵众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。
linux-node2当作计算节点
OpenStack镜像服务是IaaS的核心服务。它接受磁盘镜像或服务器镜像API请求,和来自终端用户或OpenStack计算组件的元数据定义。它也支持包括OpenStack对象存储在内的多种类型仓库上的磁盘镜像或服务器镜像存储。 大量周期性进程运行于OpenStack镜像服务上以支持缓存。同步复制(Replication)服务保证集群中的一致性和可用性。其它周期性进程包括auditors, updaters, 和 reapers。 OpenStack镜像服务包括以下组件: glance-api 接收镜像API的调用,诸如镜像发现、恢复、存储。 监听9292端口 glance-registry 存储、处理和恢复镜像的元数据,元数据包括项诸如大小和类型 监听9191端口 #glance-registry是私有内部服务,用于服务OpenStack Image服务。不要向用户暴露该服务
[root@linux-node1 ~]# yum install -y openstack-glance
先决条件
创建用户
配置数据库连接
vim /etc/glance/glance-api.conf connection = MySQL+pymysql://glance:glance@192.168.56.11/glance
配置数据库连接
vim /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:glance@192.168.56.11/glance
同步数据库,创建glance的表结构
su -s /bin/sh -c "glance-manage db_sync" glance
同步完成后,确认一下创建是否成功
[root@linux-node1 ~]# mysql -h 192.168.56.11 -uglance -pglance -e "use 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 | +----------------------------------+
修改glance-api.conf
vim /etc/glance/glance-api.conf #在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance #在[paste_deploy]下添加 flavor = keystone
修改glance-registry.conf
vim /etc/glance/glance-registry.conf 在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance 在[paste_deploy]下添加 flavor = keystone
编辑glance-api.conf
在[glance_store]下修改 stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/p_w_picpaths
设置开机启动 [root@linux-node1 ~]# systemctl enable openstack-glance-api.service \ > openstack-glance-registry.service 启动glance [root@linux-node1 ~]# systemctl start openstack-glance-api.service \ > openstack-glance-registry.service
执行netstat -lntp查看端口监听情况,若9292和9191都已监听,则证明glance启动成功。
在创建之前,要先执行环境变量脚本
[root@linux-node1 ~]# source admin-openstack.sh
再创建glance服务实体
[root@linux-node1 ~]# openstack service create --name glance --description "OpenStack Image" p_w_picpath +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | name | glance | | type | p_w_picpath | +-------------+----------------------------------+
创建镜像服务的API endpoint
[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath public http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 560d86e5e9074b4b9a98564298e2e3bf | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | service_name | glance | | service_type | p_w_picpath | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath internal http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 9f9bf0ef9e804099b2a11a94d8181e48 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | service_name | glance | | service_type | p_w_picpath | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath admin http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | f7008f53f5664a6f81b90841fee66c93 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | service_name | glance | | service_type | p_w_picpath | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+
验证是否创建成功
[root@linux-node1 ~]# openstack p_w_picpath list [root@linux-node1 ~]# glance p_w_picpath-list +----+------+ | ID | Name | +----+------+ +----+------+ [root@linux-node1 ~]# 执行上面两条命令,若返回结果与上面结果一致,则服务注册成功。
使用QCOW2磁盘格式,bare容器格式上传镜像到镜像服务并设置为public,这样所有的项目都可以访问它
[root@linux-node1 ~]# openstack p_w_picpath create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2016-10-27T16:21:42Z | | disk_format | qcow2 | | file | /v2/p_w_picpaths/29d99654-ba91-4d04-8808-e1b8d16861fb/file | | id | 29d99654-ba91-4d04-8808-e1b8d16861fb | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | 53f72af1420a4d098d48f2c82d7e9ec7 | | protected | False | | schema | /v2/schemas/p_w_picpath | | size | 13287936 | | status | active | | tags | | | updated_at | 2016-10-27T16:21:43Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+
查看镜像是否创建成功
[root@linux-node1 ~]# openstack p_w_picpath list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | active | +--------------------------------------+--------+--------+ [root@linux-node1 ~]# glance p_w_picpath-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | +--------------------------------------+--------+
镜像上传所在的目录
[root@linux-node1 ~]# cd /var/lib/glance/p_w_picpaths/ [root@linux-node1 p_w_picpaths]# ls 29d99654-ba91-4d04-8808-e1b8d16861fb