一、简介
Openstack镜像服务Glance能够使用户发现、注册和获取虚拟机镜像,可以提供Rest API获取虚拟机镜像元数据和检索真实镜像,可以将镜像保存到不同的位置,可以是简单的文件存储(File)、对象存储(Swift)或分布式文件系统(NFS、Ceph)。
这里首先初始配置的镜像存储后端是简单的文件存储,即将镜像存放到本地的文件系统中,控制节点的/var/lib/glance/images/目录下,后面会对接Ceph,重新修改Glance配置,将存储位置改为Ceph的rbd pool。
二、部署脚本
glance服务安装脚本install-configure-glance.sh
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
#!/bin/sh . ../0-set-config.sh ./style/print-split.sh "Glance Installation" test_img=../conf/cirros.raw ### [所有控制节点] 修改/etc/haproxy/haproxy.cfg文件 . ./1-gen-haproxy-cfg.sh glance ### 安装配置 ./pssh-exe C "yum install -y openstack-glance" for ((i=0; i<${#controller_map[@]}; i+=1)); do name=${controller_name[$i]}; ip=${controller_map[$name]}; . style/print-info.sh "Openstack configure in $name" ssh root@$ip /bin/bash << EOF openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:$password@$virtual_ip/glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://$virtual_ip:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://$virtual_ip:35357 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller01:11211,controller02:11211,controller03: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 $password openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone 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 DEFAULT registry_host $virtual_ip openstack-config --set /etc/glance/glance-api.conf DEFAULT bind_host $ip openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:$password@$virtual_ip/glance openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://$virtual_ip:5000 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://$virtual_ip:35357 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller01:11211,controller02:11211,controller03: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 $password openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone op#!/bin/sh . ../0-set-config.sh ./style/print-split.sh "Glance Installation" test_img=../conf/cirros.raw ### [所有控制节点] 修改/etc/haproxy/haproxy.cfg文件 . ./1-gen-haproxy-cfg.sh glance ### 安装配置 ./pssh-exe C "yum install -y openstack-glance" for ((i=0; i<${#controller_map[@]}; i+=1)); do name=${controller_name[$i]}; ip=${controller_map[$name]}; . style/print-info.sh "Openstack configure in $name" ssh root@$ip /bin/bash << EOF openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:$password@$virtual_ip/glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://$virtual_ip:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://$virtual_ip:35357 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller01:11211,controller02:11211,controller03: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 $password openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone 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 DEFAULT registry_host $virtual_ip openstack-config --set /etc/glance/glance-api.conf DEFAULT bind_host $ip openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:$password@$virtual_ip/glance openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://$virtual_ip:5000 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://$virtual_ip:35357 openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller01:11211,controller02:11211,controller03: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 $password openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_hosts controller01:5672,controller02:5672,controller03:5672 openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_ha_queues true openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_retry_interval 1 openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_retry_backoff 2 openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_max_retries 0 openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_durable_queues true openstack-config --set /etc/glance/glance-registry.conf DEFAULT registry_host $virtual_ip openstack-config --set /etc/glance/glance-registry.conf DEFAULT bind_host $ip EOF done; ### [任一节点]创建数据库 mysql -uroot -p$password_galera_root -e "CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '"$password"'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '"$password"'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'controller01' IDENTIFIED BY '"$password"'; FLUSH PRIVILEGES;" ### [任一节点]创建用户等 . /root/keystonerc_admin openstack user create --domain default --password $password glance openstack role add --project service --user glance admin openstack service create --name glance --description "OpenStack Image" image openstack endpoint create --region RegionOne image public http://$virtual_ip:9292 openstack endpoint create --region RegionOne image internal http://$virtual_ip:9292 openstack endpoint create --region RegionOne image admin http://$virtual_ip:9292 ### [任一节点]生成数据库 su -s /bin/sh -c "glance-manage db_sync" glance ### [任一节点]添加pacemaker资源 pcs resource create openstack-glance-registry systemd:openstack-glance-registry --clone interleave=true pcs resource create openstack-glance-api systemd:openstack-glance-api --clone interleave=true pcs constraint order start openstack-keystone-clone then openstack-glance-registry-clone pcs constraint order start openstack-glance-registry-clone then openstack-glance-api-clone pcs constraint colocation add openstack-glance-api-clone with openstack-glance-registry-clone pcs resource op add openstack-glance-registry start timeout=300 pcs resource op add openstack-glance-registry stop timeout=300 pcs resource op add openstack-glance-api start timeout=300 pcs resource op add openstack-glance-api stop timeout=300 ### 重启Pcs集群 . restart-pcs-cluster.sh ### [任一节点]添加测试镜像 . /root/keystonerc_admin openstack image create "cirros" --file $test_img --disk-format raw --container-format bare --public openstack image list openstack image delete cirros |
三、参考文档
https://docs.openstack.org/mitaka/install-guide-rdo/glance.html
四、源码
脚本源码:https://github.com/zjmeixinyanzhi/Openstack-HA-Install-Shells
五、系列文章
Openstack云平台脚本部署之Galera高可用集群配置(二)
Openstack云平台脚本部署之RabbitMQ高可用集群部署(三)
Openstack云平台脚本部署之Memcached配置(五)
Openstack云平台脚本部署之Keystone认证服务配置(六)
Openstack云平台脚本部署之Glance镜像服务配置(七)
Openstack云平台脚本部署之Nova计算服务配置(八)
Openstack云平台脚本部署之Neutron网络服务配置(九)
Openstack云平台脚本部署之Dashboard配置(十)
Openstack云平台脚本部署之Cinder块存储服务配置(十一)
Openstack云平台脚本部署之Ceilometer数据收集服务配置(十二)
Openstack云平台脚本部署之Aodh告警服务配置(十三)
code
more code
~~~~