安装glance: 映像文件服务

# timedatectl set-timezone Asia/Shanghai

安装时钟同步:
# yum -y install chrony

编辑配置文件指向自己的ntp服务器:
# vim /etc/chrony.conf
server keystone iburst

启动服务并让服务自启动:
# systemctl enable chronyd.service
# systemctl start chronyd.service

安装mysql 客户端程序:
# yum -y install mysql
# vim /etc/my.cnf

让mysql默认可以直接访问数据库
# cat /etc/my.cnf
[mysql]
user=root
password=password
host=mariadb

创建glance数据库并授权
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’ IDENTIFIED BY ‘openpasswd’;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
当使用epel源时最好禁用掉epel更新,避免影响到以后openstack的更新
# yum -y install yum-versionlock

安装Queens release源:
# yum install centos-release-openstack-queens

下载并安装RDO存储库RPM以启用OpenStack存储库。
# yum install https://rdoproject.org/repos/rdo-release.rpm

在所有节点上更新包:
# yum upgrade

安装openstack客户端
# yum install python-openstackclient

安装自动管理selinux组件:
# yum install openstack-selinux

导入openstack环境变量:
# vim ~/.admin_openrc

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=openpasswd
export OS_AUTH_URL=http://keystone:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

# . ~/.admin_openrc
安装glance:
1、创建glance用户,用户名为:glance 密码为:cisco
# openstack user create –domain default –password-prompt glance
User Password:
Repeat User Password:
The passwords entered were not the same
User Password:
Repeat User Password:
+———————+———————————-+
| Field | Value |
+———————+———————————-+
| domain_id | default |
| enabled | True |
| id | c737f0aef36f41c4a2013169cac59931 |
| name | glance |
| options | {} |
| password_expires_at | None |
+———————+———————————-+

2、给glancce赋予管理员脚色加入service 项目组里。
# openstack role add –project service –user glance admin
3、openstack创建glance服务
# openstack service create –name glance \
–description “OpenStack Image” image
+————-+———————————-+
| Field | Value |
+————-+———————————-+
| description | OpenStack Image |
| enabled | True |
| id | f327ba72aca2477284ea1c9d8a586002 |
| name | glance |
| type | image |
+————-+———————————-+

4、创建glance 服务的终端服务点
# openstack endpoint create –region RegionOne \
image public http://glance:9292
+————–+———————————-+
| Field | Value |
+————–+———————————-+
| enabled | True |
| id | dacfffb1c3fd47bb966e029a4ca03021 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 17f0fd471d3842f3b517bf4aa5622a81 |
| service_name | glance |
| service_type | image |
| url | http://glance:9292 |
+————–+———————————-+
# openstack endpoint create –region RegionOne \
image internal http://glance:9292
+————–+———————————-+
| Field | Value |
+————–+———————————-+
| enabled | True |
| id | 8aad1e4f3c944eb5a281a31589e272ff |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 17f0fd471d3842f3b517bf4aa5622a81 |
| service_name | glance |
| service_type | image |
| url | http://glance:9292 |
+————–+———————————-+
# openstack endpoint create –region RegionOne \
image admin http://glance:9292
+————–+———————————-+
| Field | Value |
+————–+———————————-+
| enabled | True |
| id | 8aad1e4f3c944eb5a281a31589e272ff |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 17f0fd471d3842f3b517bf4aa5622a81 |
| service_name | glance |
| service_type | image |
| url | http://glance:9292 |
+————–+———————————-+

5、安装glance服务
# yum install openstack-glance

6、编辑配置文件glance-api.conf以及glance-registry.conf
# vim /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:openpasswd@mariadb/glance
[keystone_authtoken]
auth_uri = http://keystone:5000
auth_url = http://keystone:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = cisco
[paste_deploy]

flavor = keystone

# vim /etc/glance/glance-registry.conf
[database]
connection = mysql+pymysql://glance:openpasswd@mariadb/glance
[keystone_authtoken]
auth_uri = http://keystone:5000
auth_url = http://keystone:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = cisco
[paste_deploy]

flavor = keystone
7、导入数据库
# su -s /bin/sh -c “glance-manage db_sync” glance

8、启动服务,并设置为开机自启动
# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
# systemctl restart openstack-glance-api.service \
openstack-glance-registry.service

# . ~/.admin_openrc

测试glance服务:

# 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 | 2018-04-03T13:42:03Z |
| disk_format | qcow2 |
| file | /v2/images/9c1751d2-0294-4e64-84b3-1f589f562bdf/file |
| id | 9c1751d2-0294-4e64-84b3-1f589f562bdf |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 8f7fa8dca6f4422f80fe7e3391204051 |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2018-04-03T13:42:04Z |
| virtual_size | None |
| visibility | public |
+——————+——————————————————+

# glance image-list
+————————————–+——–+
| ID | Name |
+————————————–+——–+
| 9c1751d2-0294-4e64-84b3-1f589f562bdf | cirros |
+————————————–+——–+

# glance image-show 9c1751d2-0294-4e64-84b3-1f589f562bdf
+——————+————————————–+
| Property | Value |
+——————+————————————–+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2018-04-03T13:42:03Z |
| disk_format | qcow2 |
| id | 9c1751d2-0294-4e64-84b3-1f589f562bdf |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 8f7fa8dca6f4422f80fe7e3391204051 |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2018-04-03T13:42:04Z |
| virtual_size | None |
| visibility | public |
+——————+————————————–+

# glance image-download –file /tmp/cirros-0.4.0-x86_64-disk.img –progress 9c1751d2-0294-4e64-84b3-1f589f562bdf
[=============================>] 100%

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值