目录
Glance服务安装(控制节点)
1、创库授权
连接数据库
mysql -u root -p
创建glance数据库
CREATE DATABASE glance;
授予glance数据库权限,然后退出
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS'; #改密码
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS'; #改密码
2、创建glance用户并关联角色
创建用户(密码GLANCE_PASS,用户名 glance)
openstack user create --domain default --password GLANCE_PASS glance
关联角色(glance用户关联admin角色)
openstack role add --project service --user glance admin
3、创建服务实体和后端api
创建glance服务
openstack service create --name glance \
--description "OpenStack Image" image
创建后端api
openstack endpoint create --region RegionOne \
image public http://controller:9292
openstack endpoint create --region RegionOne \
image internal http://controller:9292
openstack endpoint create --region RegionOne \
image admin http://controller:9292
4. 安装软件
yum install openstack-glance –y
5. 自动配置
5.1. 配置glance-api.conf
cp /etc/glance/glance-api.conf{,.bak}
grep '^[a-Z\[]' /etc/glance/glance-api.conf.bak >/etc/glance/glance-api.conf
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@controller/glance #改密码
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
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_url http://controller:35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS #改密码
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
5.2. 配置glance-registry.conf
cp /etc/glance/glance-registry.conf{,.bak}
grep '^[a-Z\[]' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@controller/glance #改密码
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_url http://controller:35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS #改密码
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystoneopenstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
6.同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
7.验证
mysql -u root -p
use glance;
show tables;
8. 启动
加入开机启动
systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
启动程序
systemctl start openstack-glance-api.service \
openstack-glance-registry.service
验证tcp端口
netstat -lntp|grep -E '9191|9292'
9. 上传镜像验证
9.1. 下载镜像
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
如果提示wget是无效命令,请使用”yum install wget –y“安装wget软件
9.2. 上传镜像
openstack image create "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
9.3. 查看镜像
openstack image list
10. Openstack镜像服务基本操作
10.1. 查看镜像列表
glance image-list
10.2. 使用参数可以是镜像id或者镜像名称查看镜像的详细信息
glance image-show 镜像id或者镜像名称
10.3. 删除镜像
glance image-delete镜像id或者镜像名称