继安装部署OpenStack(二)


四、配置p_w_picpath(镜像)服务

镜像服务包含以下2个组件

    glance-api:接受对镜像发现、检索、存储的API调用

    glance-registry:存储,处理,检索镜像的metadate(源数据:大小、类型等)


安装镜像服务(控制节点)

# yum install openstack-glance python-glanceclient

更新2个组件的配置文件中的数据库连接

# openstack-config --set /etc/glance/glance-api.conf database \
connection mysql://glance:GLANCE_DBPASS@controller/glance
# openstack-config --set /etc/glance/glance-registry.conf database \connection mysql://
glance:GLANCE_DBPASS@controller/glance


使用root登陆mysql,创建数据库,赋予glance用户权限

$ mysql -u root -p
mysql> CREATE DATABASE glance;
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';


为p_w_picpath服务创建表

# su -s /bin/sh -c "glance-manage db_sync" glance
创建glance用户,赋予service容器和admin角色
$ keystone user-create --name=glance --pass=GLANCE_PASS \
--email=glance@example.com$ keystone user-role-add --user=glance \
--tenant=service --role=admin


配置p_w_picpath的配置文件使用keystone验证

# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_uri http://controller:5000
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_host controller
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_port 35357
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
auth_protocol http
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_tenant_name service
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_user glance
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken \
admin_password GLANCE_PASS
# openstack-config --set /etc/glance/glance-api.conf paste_deploy \
flavor keystone
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
auth_uri http://controller:5000
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
auth_host controller
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
auth_port 35357
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
auth_protocol http
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
admin_tenant_name service
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
admin_user glance
# openstack-config --set /etc/glance/glance-registry.conf
keystone_authtoken \
admin_password GLANCE_PASS
# openstack-config --set /etc/glance/glance-registry.conf paste_deploy \
flavor keystone

注:修改里面的glance密码

向keystone注册p_w_picpath服务并创建端点

$ keystone service-create --name=glance --type=p_w_picpath \
--description="OpenStack Image Service"
$ keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ p_w_picpath / {print $2}') \
--publicurl=http://controller:9292 \
--internalurl=http://controller:9292 \
--adminurl=http://controller:9292

启动glance-api和glance-register服务

# service openstack-glance-api start
# service openstack-glance-registry start
# chkconfig openstack-glance-api on
# chkconfig openstack-glance-registry on


验证p_w_picpath服务的安装

$ mkdir /tmp/p_w_picpaths
$ cd /tmp/p_w_picpaths/
$ wget 
http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img

上传这个镜像到p_w_picpath服务

$ glance p_w_picpath-create --name "cirros-0.3.2-x86_64" --disk-format qcow2 \
--container-format bare --is-public True --progress < cirros-0.3.2-
x86_64-disk.img

使用file命令 可以查看镜像的格式

$ glance p_w_picpath-list
+--------------------------------------+---------------------
+-------------+------------------+----------+--------+
| ID | Name | Disk Format
| Container Format | Size | Status |
+--------------------------------------+---------------------
+-------------+------------------+----------+--------+
| acafc7c0-40aa-4026-9673-b879898e1fc2 | cirros-0.3.2-x86_64 | qcow2
| bare | 13167616 | active |
+--------------------------------------+---------------------
+-------------+------------------+----------+--------+

现在你可以删除本地的镜像

$ rm -r /tmp/p_w_picpaths

至此p_w_picpath服务安装完毕,加油,童鞋们j_0019.gif