将glance服务独立到一台虚拟机中:
将控制节点上的glance服务迁移到compute01中:
一:在控制节点上进行停掉glance服务
[root@controller01 ~]# systemctl stop openstack-glance-api.service openstack-glance-registry.service
[root@controller01 ~]# systemctl disable openstack-glance-api.service openstack-glance-registry.service
二:在compute01上安装glance服务:
1:数据库安装
[root@compute01 ~]# yum install mariadb mariadb-server python2-PyMySQL -y
2:初始化数据库
[root@compute01 ~]# systemctl start mariadb
[root@compute01 ~]# systemctl enable mariadb
初始化密码
[root@compute01 ~]# mysql_secure_installation
3:登入数据库配置glance用户权限
[root@compute01 ~]# mysql -uroot -phuayun
同步原来glance数据库数据:
备份原来数据库信息:
[root@controller01 ~]# mysqldump -uroot -phuayun -B glance > glance.sql
拷贝到计算节点数据库备份文件:
[root@controller01 ~]# scp glance.sql compute01:/root/
还原数据库信息:
[root@compute01 ~]# mysql -uroot -phuayun < glance.sql
查看是否访问成功
[root@compute01 ~]# mysql -uroot -phuayun glance -e 'show tables'
授权访问glance库的权限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost'
-> IDENTIFIED BY 'huayun';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'huayun';
Query OK, 0 rows affected (0.00 sec)
4:安装配置glance服务:
[root@compute01 ~]# yum install openstack-glance -y
5:将控制节点的配置文件进行迁移拷贝到计算节点:
[root@compute01 ~]# scp -rp 10.100.201.201:/etc/glance/glance-api.conf /etc/glance/
[root@compute01 ~]# scp -rp 10.100.201.201:/etc/glance/glance-registry.conf /etc/glance/
更改glance配置文件:(只需要更改glance连接数据库的地址)
下载修改包:[root@compute01 ~]# yum install openstack-utils -y
更改数据库连接:
[root@compute01 ~]# openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:huayun@10.100.214.202/glance
[root@compute01 ~]# openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:huayun@10.100.214.202/glance
6:启动服务:
[root@compute01 ~]# systemctl start openstack-glance-api openstack-glance-registry
[root@compute01 ~]# systemctl enable openstack-glance-api openstack-glance-registry
检测端口:
7:镜像文件迁移:
迁移的时候需要保持相同权限:
[root@controller01 ~]# ll /var/lib/glance/images/423fe51f-6c08-4ba5-9248-fb107788b555
-rw-r-----. 1 glance glance 12716032 May 24 15:26 /var/lib/glance/images/423fe51f-6c08-4ba5-9248-fb107788b555
[root@compute01 images]# ll
total 12420
-rw-r-----. 1 root root 12716032 May 24 15:26 423fe51f-6c08-4ba5-9248-fb107788b55
[root@compute01 images]# chown -R glance:glance /var/lib/glance/images/
[root@compute01 images]# ll
total 12420
-rw-r-----. 1 glance glance 12716032 May 24 15:26 423fe51f-6c08-4ba5-9248-fb107788b555
[root@compute01 images]# qemu-img info 423fe51f-6c08-4ba5-9248-fb107788b555
image: 423fe51f-6c08-4ba5-9248-fb107788b555
file format: qcow2
virtual size: 44M (46137344 bytes)
disk size: 12M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
更改keystone接口服务:
[root@controller01 ~]# openstack endpoint list | grep glance
| 4aa6a612f66e4a7d9c16891df2f2503e | RegionOne | glance | image | True | public | http://controller01:9292 |
| 949d6ac87e5e483882a7f91d1fbfd85b | RegionOne | glance | image | True | admin | http://controller01:9292 |
| f95905ed24314bc697e1528cddf4290c | RegionOne | glance | image | True | internal | http://controller01:9292
这里以更改数据库的方式及进行更新keystone对glance的接口
1:导出表
[root@controller01 ~]# mysqldump -uroot -phuayun keystone endpoint > endpoint.sql
2:备份:(以免以后修改该问题)
[root@controller01 ~]# cp endpoint.sql /home/
[root@controller01 ~]# ll /home/
total 8
-rw-r--r--. 1 root root 4371 May 27 16:38 endpoint.sql
3:进入endpoint.sql中将9292接口服务的ip替换
:%s#http://controller01:9292#http://10.100.214.202:9292#gc
3:将表还原:
[root@controller01 ~]# mysql -uroot -phuayun keystone < endpoint.sql
4:检测修改地址:
[root@controller01 ~]# openstack endpoint list | grep glance
| 4aa6a612f66e4a7d9c16891df2f2503e | RegionOne | glance | image | True | public | http://10.100.214.202:9292 |
| 949d6ac87e5e483882a7f91d1fbfd85b | RegionOne | glance | image | True | admin | http://10.100.214.202:9292 |
| f95905ed24314bc697e1528cddf4290c | RegionOne | glance | image | True | internal | http://10.100.214.202:9292 |
5:验证(如果glance服务停掉之后这里是没有镜像的)
[root@controller01 ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 423fe51f-6c08-4ba5-9248-fb107788b555 | cirros | active |
+--------------------------------------+--------+--------+
6:修改所有节点nova的配置文件glance的地址:(否者无法创建虚拟机)
方法一:
[root@controller01 ~]# sed -i 's#http://controller01:9292#http://10.100.214.202:9292#g' /etc/nova/nova.conf
方法二:
[root@compute01 images]# openstack-config --set /etc/nova/nova.conf glance api_servers http//:10.100.214.202:9292
7:重启服务:
控制节点:openstack-nova-api
[root@controller01 ~]# systemctl restart openstack-nova-api
计算节点:openstack-nova-compute
[root@compute01 images]# systemctl restart openstack-nova-compute
8:验证以上所有的操作方法
上传镜像启动一个实例