安装glance

在控制节点上执行


controllerHost='controller'
MYSQL_PASSWD='m4r!adbOP'
GLANCE_PASSWD='glance1234!'

1.创建数据库


mysql -uroot -p${MYSQL_PASSWD} << EOF
     DROP DATABASE IF EXISTS glance;
     CREATE DATABASE glance;
     GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '${GLANCE_PASSWD}';
     GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '${GLANCE_PASSWD}';
EOF

2.创建认证用户并授权


source ~/admin-openrc
openstack user create --domain default --password ${GLANCE_PASSWD} glance
openstack role add --project service --user glance admin

3.创建服务实体和端点


openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://${controllerHost}:9292
openstack endpoint create --region RegionOne image internal http://${controllerHost}:9292
openstack endpoint create --region RegionOne image admin http://${controllerHost}:9292

4.安装glance组件


yum -y install openstack-glance python-glance python-glanceclient

5.配置glance服务访问数据库


openstack-config --set  /etc/glance/glance-api.conf database connection mysql+pymysql://glance:${GLANCE_PASSWD}@${controllerHost}/glance

openstack-config --set  /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:${GLANCE_PASSWD}@${controllerHost}/glance

6.配置glance服务访问memcached


openstack-config --set  /etc/glance/glance-api.conf cache backend oslo_cache.memcache_pool
openstack-config --set  /etc/glance/glance-api.conf cache enabled True
openstack-config --set  /etc/glance/glance-api.conf cache memcache_servers  ${controllerHost}:11211

openstack-config --set  /etc/glance/glance-registry.conf cache backend oslo_cache.memcache_pool
openstack-config --set  /etc/glance/glance-registry.conf cache enabled True
openstack-config --set  /etc/glance/glance-registry.conf cache memcache_servers  ${controllerHost}:11211

7.配置glance服务访问认证服务


openstack-config --set  /etc/glance/glance-api.conf paste_deploy flavor  keystone
openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken  auth_uri  http://${controllerHost}:5000
openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken  auth_url  http://${controllerHost}:5000
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_PASSWD}

openstack-config --set  /etc/glance/glance-registry.conf paste_deploy flavor  keystone
openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken  auth_uri  http://${controllerHost}:5000
openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken  auth_url  http://${controllerHost}:5000
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_PASSWD}

8.配置glance服务禁用ceilometer消息机制


openstack-config --set  /etc/glance/glance-api.conf DEFAULT notification_driver = noop

openstack-config --set  /etc/glance/glance-registry.conf  DEFAULT notification_driver = noop

9.配置glance服务的监听IP


openstack-config --set  /etc/glance/glance-api.conf DEFAULT bind_host 0.0.0.0

openstack-config --set  /etc/glance/glance-registry.conf  DEFAULT bind_host  0.0.0.0

10.同步数据库


su -s /bin/sh -c "glance-manage db_sync" glance

11.启动glance服务


systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
systemctl status openstack-glance-api.service openstack-glance-registry.service

12.配置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/

13.重启glance服务


systemctl restart openstack-glance-api.service openstack-glance-registry.service
systemctl status openstack-glance-api.service openstack-glance-registry.service

14.上传镜像


source ~/admin-openrc
yum -y install qemu-img
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
qemu-img convert -f qcow2 cirros-0.4.0-x86_64-disk.img  -O raw cirros-0.4.0-x86_64-disk.img.raw
openstack image create cirros0.4  --disk-format raw  --file  cirros-0.4.0-x86_64-disk.img.raw --container-format bare  --public  --protected
openstack image list

#wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1811.qcow2.xz
#openstack image create centos7.6 --disk-format qcow2 --file CentOS-7-x86_64-GenericCloud-1811.qcow2 --container-format bare --protected --public
#wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
#openstack image create ubuntu16.04 --disk-format qcow2 --file  xenial-server-cloudimg-amd64-disk1.img --container-format bare --protected --public

posted @ 2019-07-18 20:24  小白的日常  阅读(519)  评论(0编辑  收藏  举报