安装镜像服务glance
1、创建glance数据库
#mysql -uroot -phncgo110 -e "CREATE DATABASE glance;"
注意将hncgo110替换为自己的密码
2、创建数据库用户并赋予权限
#mysql -uroot -phncgo110 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'hncgo110';"
#mysql -uroot -phncgo110 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'hncgo110';"
注意将hncgo110替换为自己的密码
3、创建glance用户及赋予admin权限
#source /root/admin-openrc
#openstack user create --domain default glance --password hncgo110
#openstack role add --project service --user glance admin
注意将hncgo110替换为自己的密码
6、创建glance相关软件包
#yum install openstack-glance -y
7、修改glance配置文件
修改 /etc/glance/glance-api.conf(可以全部copy批量执行)
#openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:hncgo110@192.168.31.100/glance
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://192.168.31.100:5000
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://192.168.31.100:35357
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers 192.168.31.100: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 hncgo110
#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/
修改glance配置文件glance-registry.conf(可以全部copy批量执行)
#openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:hncgo110@192.168.31.100/glance
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://192.168.31.100:5000
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://192.168.31.100:35357
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers 192.168.31.100: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 hncgo110
#openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
9、同步数据库
#su -s /bin/sh -c "glance-manage db_sync" glance
10、启动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
#systemctl list-unit-files |grep openstack-glance-api.service
#systemctl list-unit-files |grep openstack-glance-registry.service
4、创建image服务
#source /root/admin-openrc
#openstack service create --name glance --description "OpenStack Image" image
5、创建glance的endpoint
#openstack endpoint create --region RegionOne image public http://192.168.31.100:9292
#openstack endpoint create --region RegionOne image internal http://192.168.31.100:9292
#openstack endpoint create --region RegionOne image admin http://192.168.31.100:9292
12、下载镜像
#wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
13、上传镜像到glance
#source /root/admin-openrc
#openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public
14、查看镜像
#openstack image list