glance 迁移
glance 迁移
之前glanc在151上,现将迁移到152上
1、停止 151上的服务
1 2 3 | systemctl list-unit-files|grep glance systemctl stop openstack-glance-api.service openstack-glance-registry.service systemctl disable openstack-glance-api.service openstack-glance-registry.service |
2、安装数据库及连接控件
1 | yum -y install mariadb mariadb-server python2-PyMySQL |
3、导出数据库
1 | mysqldump -uroot -p '123456' -B glance > glance.sql |
修改数据库配置文件
1 2 3 4 5 6 7 8 | vim /etc/my.cnf.d/openstack.cnf [mysqld] bind-address = 192.168.1.152 default -storage-engine = innodb innodb_file_per_table max_connections = 4096 collation-server = utf8_general_ci character- set -server = utf8 |
启动数据库服务
1 2 3 4 | systemctl start mariadb.service systemctl enable mariadb.service mysql_secure_installation |
获取glance.sql导出文件,并导入到本地mysql
1 2 3 4 5 6 7 8 9 10 | scp 192.168.1.151:/home/glance.sql /home/ mysql MariaDB [(none)]> source /opt/glance.sql; GRANT ALL PRIVILEGES ON glance.* TO 'glance' @ 'localhost' IDENTIFIED BY 'glance' ; GRANT ALL PRIVILEGES ON glance.* TO 'glance' @ '%' IDENTIFIED BY 'glance' ; flush privileges; show grants for 'glance' ; |
3、安装 glance
1 | yum -y install openstack-glance |
#编辑配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /etc/glance/glance-api.conf yum install openstack-utils -y cp /etc/glance/glance-api.conf{,.bak} grep '^[a-Z\[]' /etc/glance/glance-api.conf.bak >/etc/glance/glance-api.conf openstack-config -- set /etc/glance/glance-api.conf database connection mysql+pymysql: //glance:glance@192.168.1.152/glance openstack-config -- set /etc/glance/glance-api.conf glance_store stores file,http openstack-config -- set /etc/glance/glance-api.conf glance_store default_store file openstack-config -- set /etc/glance/glance-api.conf glance_store filesystem_store_datadir / var /lib/glance/images/ openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken auth_uri http: //controller:5000 openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken auth_url http: //controller:35357 openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211 openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken auth_type password openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken project_name service openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken username glance openstack-config -- set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS openstack-config -- set /etc/glance/glance-api.conf paste_deploy flavor keystone #编辑配置文件 /etc/glance/glance-registry.conf cp /etc/glance/glance-registry.conf{,.bak} grep '^[a-Z\[]' /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@192.168.1.152/glance openstack-config -- set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http: //controller:5000 openstack-config -- set /etc/glance/glance-registry.conf keystone_authtoken auth_url http: //controller:35357 openstack-config -- set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller: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 |
4、迁移原有镜像文件
将原glance上的镜像文件,传输到compute2。
1 2 | [root@controller ~]# cd / var /lib/glance/images/ [root@controller ~]# rsync -avz `pwd`/ 10.0.0.32:`pwd`/ |
【注意权限】传输过后,在compute2上查看权限
1 2 | [root@compute2 ~]# cd / var /lib/glance/images/ [root@compute2 ~]# chown glance:glance * |
5、修改现有keystone中 glance服务注册信息
备份数据库endpoint表数据
1 | [root@controller ~]# mysqldump keystone endpoint > endpoint.sql |
修改keystone注册信息
1 2 | cp endpoint.sql{,.bak} sed -i 's#http://controller:9292#http://10.0.0.32:9292#g' endpoint.sql |
重新将修改后的sql文件导入数据库
1 | [root@controller ~]# mysql keystone < endpoint.sql |
6、修改nova节点配置文件
将所有的节点上的配置文件都进行修改
1 | sed -i 's#api_servers = http://controller:9292#api_servers = http://10.0.0.32:9292#g' /etc/nova/nova.conf |
控制节点重启
1 | systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service |
计算节点重启
1 | systemctl restart openstack-nova-compute.service |
停掉glance原节点的服务
1 | systemctl stop openstack-glance-api.service openstack-glance-registry.service |
7、验证操作
在copmute2节点启动glance服务
1 | systemctl start openstack-glance-api.service openstack-glance-registry.service |
查看镜像列表
1 2 3 4 5 6 7 8 | [root@controller ~]# openstack image list +--------------------------------------+--------------+--------+ | ID | Name | Status | +--------------------------------------+--------------+--------+ | 4ba5d2d5-7880-48ab-b383-fa8f62277aef | centos6-init | active | | 38e8b762-79dd-45f5-be11-73e732663614 | centos6.9 | active | | 348896ad-1403-4d21-9a1d-c78526bdc6ae | cirros | active | +--------------------------------------+--------------+--------+ |
查看web界面中的镜像信息
8、上传centos7 的镜像
下载镜像到本地
1 | wget https: //mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2 |
上传镜像到glance
1 | glance image-create --name "centos7laste" --file CentOS-7-x86_64-GenericCloud-2009.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress |
验证镜像
1 2 3 4 5 6 7 8 9 | [root@node152 ~]# openstack image list +--------------------------------------+--------------+--------+ | ID | Name | Status | +--------------------------------------+--------------+--------+ | 4ba5d2d5-7880-48ab-b383-fa8f62277aef | centos6-init | active | | 38e8b762-79dd-45f5-be11-73e732663614 | centos6.9 | active | | 822e5cb0-c744-441a-b723-9f24775fb622 | centos7laste | active | | 348896ad-1403-4d21-9a1d-c78526bdc6ae | cirros | active | +--------------------------------------+--------------+--------+ |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端