OpenStack mirror service (Glance) installation

**Installing and configuring Glance**
1. Install the Glance software package
yum -y install openstack-glance

#查看用户信息
cat /etc/passwd | grep glance
#查看用户组信息
cat /etc/group | grep glance
2. Create Glance database and authorize
mysql -uroot -p 123456

#新建“glance”数据库
CREATE DATABASE glance;
#给用户授权使用新建数据库。
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '123456';
3. Modify the Glance configuration file
#备份配置文件
cp /etc/glance/glance-api.conf /etc/glance/glance-api.bak

#去掉所有注释和空行,生成新的配置文件。
grep -Ev '^$|#' /etc/glance/glance-api.bak > /etc/glance/glance-api.conf

The specific meaning of the regular expression "$|#" here is: match an empty line ("^$", where " " is the beginning of a line, "$" is the end of a line), or (the symbol "|" means or) Matches lines where the first character is "#". Combined with the reverse matching parameter "-v", the final match is all lines that are not empty and do not start with the comment symbol "#".

4. Modify the Glance configuration file
#打开配置文件进行编辑
vi /etc/glance/glance-api.conf

#修改“[database]”部分,实现与数据库连接。
connection = mysql+pymysql://glance:123456@controller/glance

#修改“[keystone_authtoken]”和“[paste_deploy]”部分,实现与Keystone交互。
[keystone_authtoken]
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
username = glance
password = 123456
project_name = project
user_domain_name = Default
project_domain_name = Default
[paste_deploy]
flavor = keystone

#修改“[glance_store]”部分,指定后端存储系统
[glance_store]
stores = file
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
5. Initialize the Glance database
su glance -s /bin/sh -c "glance-manage db_sync"
**Glance component initialization**
1. Create Glance users and assign roles
#导入环境变量模拟登录。
. admin-login

#在OpenStack云计算平台中创建用户“glance”。
openstack user create --domain default --password 123456 glance

#给用户“glance”分配“admin”角色
openstack role add --project project --user glance admin
2. Create Glance service and endpoint
#创建服务:创建名为“glance”、类型为“image”的服务。
openstack service create --name glance image
#创建镜像服务端点
#OpenStack组件的服务端点有3种,分别对应Admin用户(admin)、内部组件(internal)、公众用户(public)服务的地址。

#创建公众用户访问的服务端点。
openstack endpoint create --region RegionOne glance public http://controller:9292

#创建内部组件访问的服务端点。
openstack endpoint create --region RegionOne glance internal http://controller:9292

#创建Admin用户访问端点。
openstack endpoint create --region RegionOne glance admin http://controller:9292
3. Start the Glance service
systemctl enable openstack-glance-api
systemctl start openstack-glance-api
4. Verify the Glance service
#查看端口
netstat -tnlup|grep 9292

#查看服务状态
systemctl status openstack-glance-api
**Mirroring with Glance**
1. Make a mirror image
openstack image create --file cirros-0.5.1-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
2. View the mirror image
openstack image list

Guess you like

Origin blog.csdn.net/xiaoyu070321/article/details/131354155