一、glance介绍:
- 如果要安装的系统多了效率就很低
- 时间长,工作量大
- 安装完还要进行手工配置,比如安装其他的软件,设置 IP 等
- 备份和恢复系统不灵活
- 先手工安装好这么一个虚机
- 然后对虚机执行 snapshot,这样就得到了一个 image
- 当有新员工入职需要办公环境时,立马启动一个或多个该 image 的 instance(虚机)就可以了
- 提供 REST API 让用户能够查询和获取 image 的元数据和 image 本身
- 支持多种方式存储 image,包括普通的文件系统、Swift、Amazon S3 等
- 对 Instance 执行 Snapshot 创建新的 image
glance-api
glance-registry
Database
Store backend
- A directory on a local file system(这是默认配置)
- GridFS
- Ceph RBD
- Amazon S3
- Sheepdog
- OpenStack Block Storage (Cinder)
- OpenStack Object Storage (Swift)
- VMware ESX
二、glance创建镜像:
一、建立glance数据库并且给权限设置第三方登录
mysql -uroot -p0330
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ IDENTIFIED BY 'GLANCE_DBPASS';
二、部署glance
①宣告环境变量
source openrc或 . openrc
②创建glance用户
openstack user create --domain default --password=glance glance
③将项目service中的用户glance设置为admin角色
openstack role add --project service --user glance admin
④创建glance服务
openstack service create --name glance \ --description "OpenStack Image" image
⑤创建服务端点(RegionOne是一个域)
openstack endpoint create --region RegionOne \ image public http://controller:9292
openstack endpoint create --region RegionOne \ image internal http://controller:9292
openstack endpoint create --region RegionOne \ image admin http://controller:9292
三、安装glance镜像服务,并编辑配置文件
①安装
yum install openstack-glance
②先复制再编辑配置文件(复制和无需更改)
cp /etc/glance/glance-api.conf
/etc/glance/glance-api.conf
.bak
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
[DEFAULT] [glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/ [image_format] [keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance [matchmaker_redis] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [paste_deploy]
flavor = keystone [profiler] [store_type_location_strategy] [task] [taskflow_executor]
vim /etc/glance/glance-api.conf
[DEFAULT] [database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance [keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance [matchmaker_redis] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_policy] [paste_deploy]
flavor = keystone [profiler]
vim /etc/glance/glance-registry.conf
③同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
④重启并设置开机自启
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
四、上传镜像
①上传镜像
cirros-0.3.3-x86_64-disk.img
source openrc
②查看镜像列表(镜像保存在/var/lib/glance/images)
opentack image list或glance image-list
【补充】
第三方进入数据库
1.必须安装mariadb客户端
2.登录的用户必须可以第三方登录
mysql -h ip -ukeystone -pkeystone
3.注释多行
ctrl +v—— 全部选中——shift i ——#——esc两次
取消多行注释
ctrl +v——全部选中——dd
4、常用服务端口号:
placement 6080 novncproxy glance-registry 8774 nova registry-api 11211 memcached
neutron
6080 novncproxy
6633 openvswitch 6640 openvswitch 5000 keystone 35357 keystone (虽说时keystone的端口号,但是启动与否与apache服务是否启动有最直接关系) 5672(25672) rabbitmq 8776 cinder
5、报错:
1)Missing value auth-url required for auth plugin password
因为没声明变量
2)Unable to establish connection to http://controller:35357
因为35357服务没启动,查看msgi配置文件和httpd服务情况