接着部署完keystone后,接着部署glance
第一:部署安装glance
glance关于数据库的操作:
[root@controller /]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 17 Server version: 10.1.18-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE glance; Query OK, 1 row affected (0.11 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ -> IDENTIFIED BY '123'; #新建本地访问glance库的账号 Query OK, 0 rows affected (0.72 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ -> IDENTIFIED BY '123';#新建远程访问glance库的账号 Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
glance与keystone的关联操作:
[root@controller /]# source admin-openrc #执行管理者脚本 [root@controller /]# openstack user create --domain default --password-prompt glance #为glance创建用户 User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 723b35073ef249e3b187ac065e451cb8 | | name | glance | | password_expires_at | None | +---------------------+----------------------------------+ [root@controller /]# openstack role add --project service --user glance admin #对glance-service添加role角色,提示:用户glance只有在一个确定的项目service内才有角色的概念,单独的用户或者单独的项目都是无法绑定角色的
[root@controller /]# openstack service create --name glance --description "OpenStack Image" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 43690ca167f04fa485afe458370ac0eb | | name | glance | | type | image | +-------------+----------------------------------+
#创建glance服务的catalog:service+endpoint(uri)
openstack endpoint create --region RegionOne \ image public http://192.168.31.57:9292 openstack endpoint create --region RegionOne \ image internal http://192.168.31.57:9292 openstack endpoint create --region RegionOne \ image admin http://192.168.31.57:9292
安装:glance的软件包
yum -y install openstack-glance
配置glance
创建本地存储:
1.必须在openstack-glance-api.service服务启动之前配置好存储设备,因为服务启动的时候会加载存储驱动检索存储设备,如过启动之前没有存储设备,启动后再键存储设备的话,也是没用的,最终让你镜像传不上去
2.一定要赋予openstack-glance-api.service服务对文件存储设备的写权限
首先:
mkdir /var/lib/glance/images chown -R glance.glance /var/lib/glance/images
配置/etc/glance/glance-api.conf
[database] connection = mysql+pymysql://glance:123@192.168.1.120/glance #链接glance的数据库 [keystone_authtoken] auth_uri = http://192.168.1.120:5000 #普通用户认证uri auth_url = http://192.168.1.120:35357 #admin用户认证uri memcached_servers = 192.168.1.120:11211 #memcached的uri (目前还没有配置) auth_type = password #认证类型密码 project_domain_name = Default #项目域名
user_domain_name = Default #用户域名 project_name = service #项目名字 username = glance #glance用户 password = 123 #glance密码 [paste_deploy] flavor = keystone [glance_store] stores = file,http #存储设备 default_store = file filesystem_store_datadir = /var/lib/glance/images/ 镜像存放位置
配置/etc/glance/glance-registry.conf
[database] connection = mysql+pymysql://glance:123@192.168.1.120/glance #连接数据库
官网上在此还配置这与keystone的认证机制,这里不用配置哦!
初始化glance数据库:
su -s /bin/sh -c "glance-manage db_sync" glance
报这个错误不用管,是正常的
启动glance,并设置开机自启动
systemctl enable openstack-glance-api.service \ openstack-glance-registry.service systemctl start openstack-glance-api.service \ openstack-glance-registry.service
第二:验证
一
source admin-openrc yum -y install wget wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img openstack image create "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2017-02-15T09:23:48Z | | disk_format | qcow2 | | file | /v2/images/02f5bc8a-4b8e-44be-8701-cc28fb9a7dd3/file | | id | 02f5bc8a-4b8e-44be-8701-cc28fb9a7dd3 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | e55ce4dd1dfa4ed6bc8b84206d1d289d | | protected | False | | schema | /v2/schemas/image | | size | 13287936 | | status | active | | tags | | | updated_at | 2017-02-15T09:23:50Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 02f5bc8a-4b8e-44be-8701-cc28fb9a7dd3 | cirros | active | +--------------------------------------+--------+--------+
到此为止完成了glance的搭建,验证了从glance的命令行上传镜像已经成功。
二:
用horizon管理页面上传镜像
打开http://192.168.1.120/dashboard
点击创建镜像,上传后在机器上查看镜像id号是相同的,及正确
第三:查看信息
查看catalog信息:
现在可以查看下service列表