centos7.4+openstack queens版多节点分布式快速部署(四)安装Glance镜像服务

(1)在mariadb上为glance创建管理数据库并授权
mysql -u root -p
CREATE DATABASE glance;

进入数据库后,执行:
flush privileges
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%'  IDENTIFIED BY 'GLANCE_DBPASS';
用合适的密码替换 GLANCE_DBPASS.

(2)获取admin用户的环境变量

创建admin-openrc脚本,vim /root/admin-openrc

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://172.16.70.201:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
source ~/admin-openrc

vim ~/.bash_profile
source ~/admin-openrc #在后面加上这一条


(3)在keystone上创建glance服务
1)创建glance用户
[root@controller1 ~]# openstack user create --domain default --password-prompt glance
User Password:123456

2)添加用户角色,给glance用户添加admin权限
[root@controller1 ~]#openstack role add --project service --user glance admin
说明:此条命令执行成功后不返回参数

3)创建名称为glance的镜像服务
[root@controller1 ~]# openstack service create --name glance  --description "OpenStack Image" image

4)创建镜像服务三个API端点public,internal,admin
1.public API端点
[root@controller1 ~]# openstack endpoint create --region RegionOne  image public http://172.16.70.205:9292

2.internal API端点
[root@controller1 ~]# openstack endpoint create --region RegionOne  image internal http://172.16.70.205:9292

3.admin API端点
[root@controller1 ~]# openstack endpoint create --region RegionOne  image admin http://172.16.70.205:9292


(4)在glance1服务器上安装并配置glance
1)安装glance
yum install openstack-glance -y

2)编辑/etc/glance/glance-api.conf参数
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@172.16.70.203/glance
[keystone_authtoken]
auth_uri = http://172.16.70.201:5000
auth_url = http://172.16.70.201:35357
memcached_servers = 172.16.70.204:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 123456

[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file

filesystem_store_datadir = /glance/images/  #新挂载一个大硬盘,用于存放镜像文件,这里改了文件存放位置,一定要编辑/etc/passwd 中glance用户的家目,默认是:

glance:x:161:161:OpenStack Glance Daemons:/var/lib/glance:/sbin/nologin


不更改这里,镜像上传不了。

还要更改/glance目录所有者权限:chown -hR glance:glance /glance


成功将镜像文件,上传到/dev/sdb1盘的挂载点 /glance/images/上


3)编辑/etc/glance/glance-registry.conf参数

[database]

connection = mysql+pymysql://glance:GLANCE_DBPASS@172.16.70.203/glance


[keystone_authtoken]

auth_uri = http://172.16.70.201:5000
auth_url = http://172.16.70.201:35357
memcached_servers = 172.16.70.204:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 123456

[paste_deploy]
flavor = keystone

4)同步镜像服务数据库

使用#grep '^[a-Z]' /etc/glance/glance-api.conf  查看一下配置文件的改变


5)同步镜像服务数据库
su -s /bin/sh -c "glance-manage db_sync" glance

systemctl enable openstack-glance-api.service 
systemctl enable openstack-glance-registry.service
systemctl start openstack-glance-api.service  
systemctl start openstack-glance-registry.service

(5)验证glance
1)下载CirrOS验证Image

 wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img

[root@glance1 ~]# source ~/admin-openrc 

2)上传镜像

使用QCOW2磁盘格式,裸容器格式和公开可见性将图像上传到Image服务,以便所有项目都可以访问它:
 [root@glance1 ~]# openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img  --disk-format qcow2 --container-format bare  --public

  

 3)查看镜像

 [root@glance1 ~]# openstack image list


阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭