OpenStack glance组件部署
前言
- 接着OpenStack Keystore组件实验,继续配置,为openstack安装glance组件,以下操作全部在控制节点ct(192.168.139.12)上操作
一.创建数据库实例和数据库用户
mysql -u root -p #登录mysql
CREATE DATABASE glance; #输入密码
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
#授权glance用户在本地所有库所有表拥有所有权限,密码是GLANCE_DBPASS
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
#授权glance用户在所有主机所有库所有表拥有所有权限,密码是GLANCE_DBPASS
flush privileges; #刷新权限
exit #退出数据库
二.创建用户、修改配置文件
openstack user create --domain default --password GLANCE_PASS glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://ct:9292
openstack endpoint create --region RegionOne image internal http://ct:9292
openstack endpoint create --region RegionOne image admin http://ct:9292
openstack user create --domain default --password GLANCE_PASS glance #创建用户glance,default域密码GLANCE_PASS
openstack role add --project service --user glance admin #将glance用户添加到service项目中,并且针对此项目拥有admin权限
openstack service create --name glance --description "OpenStack Image" image #创建一个service服务,service名称为glance,类型为image;创建完成后通过openstack service list查看
openstack endpoint create --region RegionOne image public http://ct:9292 #创建镜像api端点public服务(openstack三种api端点代表admin,interbal,public三种服务)
openstack endpoint create --region RegionOne image internal http://ct:9292 #创建镜像api端点internal服务
openstack endpoint create --region RegionOne image admin http://ct:9292 #创建镜像api端点admin服务
三.修改配置文件
1.安装 openstack-glance 软件包
yum -y install openstack-glance #安装 openstack-glance 软件包
2.修改glance配置文件
cd /etc/glance/ #进入/etc/glance/目录
ls #查看
glance-api.conf glance-registry.conf #两个配置文件
3.添加glance-api.conf配置
cp -a /etc/glance/glance-api.conf{,.bak} #不改变原属性备份
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf #去除备份文件中空格和#号,注入的配置文件中
4.传参,添加glance-api.conf配置
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@t/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct: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 keystone
cat glance-api.conf
5.修改glance-registry.conf 配置文件
cp -a /etc/glance/glance-registry.conf{,.bak}
grep -Ev '^$|#' /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@t/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct: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 keystone
cat glance-registry.conf
6.初始化glance数据库生成相关表连接
su -s /bin/sh -c "glance-manage db_sync" glance
systemctl enable openstack-glance-api.service #设置开机自启动服务
systemctl start openstack-glance-api.service #开启服务
netstat -natp | grep 9292 ( 也可以lsof -i:9292,lsof需要安装) #查看端口
yum -y install lsof #安装lsof
lsof -i:9292
chown -hR glance:glance /var/lib/glance/ #赋予openstack-glance-api.service服务对存储设备的可写权限(-h:值对符号连接/软链接的文件修改)
7.镜像导入
cd /opt
ls
openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
8.查看镜像的两种方式
openstack image list
glance image-list