glance镜像服务迁移

1.迁移步骤

  • 1、glance数据库迁移

  • 2、在新机器上安装glance服务

  • 3、迁移之前已有的镜像

  • 4、在keystone上,修改glance服务的api地址

  • 5、修改控制节点和计算节点nova配置文件中glance的api地址以及块存储节点中cinder配置文件中glance的api地址

  • 6、上传新的镜像测试glance服务是否正常

  • 7、启动一台新的虚拟机完成测试

2.迁移过程

2.1 控制节点导出glance数据库并拷贝到新机器

新机器的IP地址是10.0.0.10

#备份glance数据库
mysqldump -B glance >glance-db.sql

#拷贝备份文件到新机器
scp -p glance-db.sql 10.0.0.10:~

2.2 新机器配置hosts解析

cat >> /etc/hosts << EOF
10.0.0.11 controller
10.0.0.31 compute1
10.0.0.32 compute2
10.0.0.41 block1
10.0.0.51 object1
10.0.0.52 object2
EOF

2.3 新机器安装mariadb并设置开启自启

yum -y install mariadb mariadb-server python2-PyMySQL
systemctl enable mariadb && systemctl start mariadb

2.4 新机器导入数据库glance-db.sql

mysql < glance-db.sql

2.5 新机器给glance数据库授权

#用以下命令修改
mysql -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';"
mysql -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';"

2.6 控制节点停止glance服务

systemctl stop openstack-glance-api openstack-glance-registry
systemctl disable openstack-glance-api openstack-glance-registry

2.7 新机器安装glance

yum -y install openstack-glance openstack-utils

2.8 新机器拷贝控制节点glance配置文件

scp -rp 10.0.0.11:/etc/glance/glance-api.conf /etc/glance
scp -rp 10.0.0.11:/etc/glance/glance-registry.conf /etc/glance

2.9 新机器编辑glance配置文件/etc/glance/glance-api.conf,修改数据库连接

openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@localhost/glance   

MD5值
md5sum /etc/glance/glance-api.conf
76d2be813471725c008245a9d135ea92  /etc/glance/glance-api.conf

2.10 新机器编辑glance配置文件/etc/glance/glance-registry.conf

openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@localhost/glance

md5sum /etc/glance/glance-registry.conf
7fefe761789d2d4d2afa3409b0e22bb0  /etc/glance/glance-registry.conf

2.11 新机器启动glance服务

  • glance-api 监听tcp/9292

  • glance-registry 监听tcp/9191

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

2.12 新机器拷贝控制节点/var/lib/glance/images下的镜像到本地的/var/lib/glance/images目录下

#如果使用scp的话,拷贝过来的镜像还需要手动修改镜像文件所有者为glance,拷贝过来的文件默认所有者是root
rsync -avz 10.0.0.11:/var/lib/glance/images/* /var/lib/glance/images/

2.13 控制节点上修改keystone中glance api的地址

keystone数据库中的endpoint表记录了各个api地址

2.13.1 备份keystone数据库中的endpoint表

mysqldump keystone endpoint > keystone-endpoint.sql

2.13.2 keystone数据库中的endpoint表记录了各api的地址,可以先查询一下endpoint表中有9292端口的记录

mysql keystone -e "select * from endpoint where url like '%9292'"
+----------------------------------+--------------------+-----------+----------------------------------+------------------------+-------+---------+-----------+
| id                               | legacy_endpoint_id | interface | service_id                       | url                    | extra | enabled | region_id |
+----------------------------------+--------------------+-----------+----------------------------------+------------------------+-------+---------+-----------+
| 0db3f8b44aff4501a3c866ba01bd546d | NULL               | public    | eb33b46815ba43a982fc39a9737efa7f | http://controller:9292 | {}    |       1 | RegionOne |
| 3119eb7c9e6e4bf98cf9b9738d53703d | NULL               | admin     | eb33b46815ba43a982fc39a9737efa7f | http://controller:9292 | {}    |       1 | RegionOne |
| 6382b60ec0a94472b6e68f8ecc1d13fe | NULL               | internal  | eb33b46815ba43a982fc39a9737efa7f | http://controller:9292 | {}    |       1 | RegionOne |
+----------------------------------+--------------------+-----------+----------------------------------+------------------------+-------+---------+-----------+

2.13.3 然后修改这3条记录中的url

mysql keystone -e "update endpoint set url='http://10.0.0.10:9292' where url like '%9292'"

2.13.4 再次查看9292相关记录

url中的地址修改为了10.0.0.10

mysql keystone -e "select * from endpoint where url like '%9292'"
+----------------------------------+--------------------+-----------+----------------------------------+-----------------------+-------+---------+-----------+
| id                               | legacy_endpoint_id | interface | service_id                       | url                   | extra | enabled | region_id |
+----------------------------------+--------------------+-----------+----------------------------------+-----------------------+-------+---------+-----------+
| 0db3f8b44aff4501a3c866ba01bd546d | NULL               | public    | eb33b46815ba43a982fc39a9737efa7f | http://10.0.0.10:9292 | {}    |       1 | RegionOne |
| 3119eb7c9e6e4bf98cf9b9738d53703d | NULL               | admin     | eb33b46815ba43a982fc39a9737efa7f | http://10.0.0.10:9292 | {}    |       1 | RegionOne |
| 6382b60ec0a94472b6e68f8ecc1d13fe | NULL               | internal  | eb33b46815ba43a982fc39a9737efa7f | http://10.0.0.10:9292 | {}    |       1 | RegionOne |
+----------------------------------+--------------------+-----------+----------------------------------+-----------------------+-------+---------+-----------+

2.14 控制节点验证修改是否成功

openstack endpoint list|grep glance
| 0db3f8b44aff4501a3c866ba01bd546d | RegionOne | glance       | image        | True    | public    | http://10.0.0.10:9292                         |
| 3119eb7c9e6e4bf98cf9b9738d53703d | RegionOne | glance       | image        | True    | admin     | http://10.0.0.10:9292                         |
| 6382b60ec0a94472b6e68f8ecc1d13fe | RegionOne | glance       | image        | True    | internal  | http://10.0.0.10:9292

2.15 控制节点、计算节点修改/etc/nova/nova.conf中glance的地址

1.修改nova配置文件
openstack-config --set /etc/nova/nova.conf glance api_servers http://10.0.0.10:9292

2.控制节点重启nova-api
systemctl restart openstack-nova-api 

3.计算节点重启nova-compute
systemctl restart openstack-nova-compute

2.16 块存储节点修改配置文件/etc/cinder/cinder.conf中的glance api的地址

1.修改cinder配置文件中glance api地址
openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://10.0.0.10:9292

2.重启cinder服务  
systemctl restart openstack-cinder-volume.service target.service

2.17 最后web界面上传镜像并启动虚拟机测试

能成功上传镜像并能成功启动虚拟机即为成功

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""