- 论坛徽章:
- 26
|
加入OpenStack Image Service
也就是下图中的东西。
照样先加数据库,下面的与是电脑屏幕直接输入的
[root@controller log]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 5.5.40-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program 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.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
-> IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
-> IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
填加用户glance 与密码
[root@controller log]# keystone user-create --name glance --pass GLANCE_PASS
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | |
| enabled | True |
| id | d51571512faf4c148cca450d75396893 |
| name | glance |
| username | glance |
+----------+----------------------------------+
[root@controller log]# keystone user-role-add --user glance --tenant service --role admin
[root@controller log]# keystone service-create --name glance --type image \
> --description "OpenStack Image Service"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStack Image Service |
| enabled | True |
| id | 990d6863283141ff9dbaa7a4e3a06795 |
| name | glance |
| type | image |
+-------------+----------------------------------+
[root@controller log]# keystone endpoint-create \
> --service-id $(keystone service-list | awk '/ image / {print $2}') \
> --publicurl http://controller:9292 \
> --internalurl http://controller:9292 \
> --adminurl http://controller:9292 \
> --region regionOne
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://controller:9292 |
| id | 37172288d36f4c1b8dc3fa7935174aa7 |
| internalurl | http://controller:9292 |
| publicurl | http://controller:9292 |
| region | regionOne |
| service_id | 990d6863283141ff9dbaa7a4e3a06795 |
+-------------+----------------------------------+
安装相关包
[root@controller log]#yum install openstack-glance python-glanceclient
编辑相关文件
# vi /etc/glance/glance-api.conf
[DEFAULT]
verbose=True
[database]
connection = mysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
[paste_deploy]
flavor = keystone
[store_type_location_strategy]
[profiler]
[task]
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
# vi /etc/glance/glance-registry.conf
[DEFAULT]
verbose=True
[database]
connection = mysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
[paste_deploy]
flavor = keystone
[profiler]
同步数据库
# 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
试一下,先下载一上img,再加入到epenstack中
[root@controller log]# mkdir /tmp/images
[root@controller log]# cd /tmp/images
[root@controller images]# wget http://cdn.download.cirros-cloud ... 3.3-x86_64-disk.img
[root@controller images]# ll
total 12892
-rw-r--r--. 1 root root 13200896 Dec 11 10:49 cirros-0.3.3-x86_64-disk.img
加入到img
[root@controller images]# source /root/admin-openrc.sh
[root@controller images]# glance image-create --name "cirros-0.3.3-x86_64" --file cirros-0.3.3-x86_64-disk.img \
> --disk-format qcow2 --container-format bare --is-public True --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2014-12-11T02:51:58 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 71ebf3fa-4da5-49e2-b1f3-88498e9c1643 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.3-x86_64 |
| owner | 89109628fdf840249f2b9fd716404527 |
| protected | False |
| size | 13200896 |
| status | active |
| updated_at | 2014-12-11T02:51:59 |
| virtual_size | None |
+------------------+--------------------------------------+
看一下
[root@controller images]# glance image-list
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| 71ebf3fa-4da5-49e2-b1f3-88498e9c1643 | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
[root@controller images]# cd /root/ |
|