glance 迁移
之前glanc在151上,现将迁移到152上
1、停止 151上的服务
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、安装数据库及连接控件
yum -y install mariadb mariadb-server python2-PyMySQL
3、导出数据库
mysqldump -uroot -p‘123456‘ -B glance > glance.sql
修改数据库配置文件
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
启动数据库服务
systemctl start mariadb.service systemctl enable mariadb.service mysql_secure_installation
获取glance.sql导出文件,并导入到本地mysql
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
yum -y install openstack-glance
#编辑配置文件
/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。
[root@controller ~]# cd /var/lib/glance/images/ [root@controller ~]# rsync -avz `pwd`/ 10.0.0.32:`pwd`/
【注意权限】传输过后,在compute2上查看权限
[root@compute2 ~]# cd /var/lib/glance/images/ [root@compute2 ~]# chown glance:glance *
5、修改现有keystone中 glance服务注册信息
备份数据库endpoint表数据
[root@controller ~]# mysqldump keystone endpoint > endpoint.sql
修改keystone注册信息
cp endpoint.sql{,.bak} sed -i ‘s#http://controller:9292#http://10.0.0.32:9292#g‘ endpoint.sql
重新将修改后的sql文件导入数据库
[root@controller ~]# mysql keystone < endpoint.sql
6、修改nova节点配置文件
将所有的节点上的配置文件都进行修改
sed -i ‘s#api_servers = http://controller:9292#api_servers = http://10.0.0.32:9292#g‘ /etc/nova/nova.conf
控制节点重启
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
计算节点重启
systemctl restart openstack-nova-compute.service
停掉glance原节点的服务
systemctl stop openstack-glance-api.service openstack-glance-registry.service
7、验证操作
在copmute2节点启动glance服务
systemctl start openstack-glance-api.service openstack-glance-registry.service
查看镜像列表
[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 的镜像
下载镜像到本地
wget https://mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2
上传镜像到glance
glance image-create --name "centos7laste" --file CentOS-7-x86_64-GenericCloud-2009.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
验证镜像
[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 | +--------------------------------------+--------------+--------+