切入到所在目录
[root@linux-node1 ~]# cd /usr/local/src/
[root@linux-node1 src]# ls
cinder-2014.1 glance-2014.1 horizon-2014.1 keystone-2014.1 neutron-2014.1 nova-2014.1 openstack.txt
cinder-2014.1.tar.gz glance-2014.1.tar.gz horizon-2014.1.tar.gz keystone-2014.1.tar.gz neutron-2014.1.tar.gz nova-2014.1.tar.gz
[root@linux-node1 src]# cd glance-2014.1
[root@linux-node1 glance-2014.1]# python setup.py install
创建glance用的目录
[root@linux-node1 glance-2014.1]# cd ~
[root@linux-node1 ~]# mkdir /etc/glance
[root@linux-node1 ~]# mkdir /var/log/glance
[root@linux-node1 ~]# mkdir /var/lib/glance
[root@linux-node1 ~]# mkdir /var/run/glance
拷贝配置文件
[root@linux-node1 ~]# cd /usr/local/src/glance-2014.1/etc/
[root@linux-node1 etc]# ll
总用量 72
-rw-rw-r-- 1 1004 1004 23996 4月 17 19:35 glance-api.conf
-rw-rw-r-- 1 1004 1004 2603 4月 17 19:35 glance-api-paste.ini
-rw-rw-r-- 1 1004 1004 7210 4月 17 19:35 glance-cache.conf
-rw-rw-r-- 1 1004 1004 5986 4月 17 19:35 glance-registry.conf
-rw-rw-r-- 1 1004 1004 863 4月 17 19:35 glance-registry-paste.ini
-rw-rw-r-- 1 1004 1004 1860 4月 17 19:35 glance-scrubber.conf
-rw-rw-r-- 1 1004 1004 982 4月 17 19:35 logging.cnf.sample
-rw-rw-r-- 1 1004 1004 611 4月 17 19:35 policy.json
-rw-rw-r-- 1 1004 1004 1186 4月 17 19:35 property-protections-policies.conf.sample
-rw-rw-r-- 1 1004 1004 1065 4月 17 19:35 property-protections-roles.conf.sample
-rw-rw-r-- 1 1004 1004 1259 4月 17 19:35 schema-image.json
[root@linux-node1 etc]# cp * /etc/glance/
[root@linux-node1 etc]# cd /etc/glance/
[root@linux-node1 glance]# ls
glance-api.conf glance-cache.conf glance-registry-paste.ini logging.cnf.sample property-protections-policies.conf.sample schema-image.json
glance-api-paste.ini glance-registry.conf glance-scrubber.conf policy.json property-protections-roles.conf.sample
[root@linux-node1 glance]# mv logging.cnf.sample logging.cnf
[root@linux-node1 glance]# mv property-protections-policies.conf.sample property-protections-policies.conf
[root@linux-node1 glance]# mv property-protections-roles.conf.sample property-protections-roles.conf
[root@linux-node1 glance]# vim glance-api.conf ---配置文件修改了下面的红色部分
verbose = true
debug = true
connection = mysql://glance:[email protected]/glance
notifier_strategy = rabbit
rabbit_host = 192.168.33.11
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = guest
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = notifications
rabbit_durable_queues = False
[keystone_authtoken]
auth_host = 192.168.33.11
auth_port = 35357
auth_protocol = http
admin_tenant_name = admin
admin_user = admin
admin_password = admin
[paste_deploy]
flavor=keystone
[root@linux-node1 glance]# vim glance-registry.conf
[DEFAULT]
verbose = true
# Show debugging output in logs (sets DEBUG log level output)
debug = true
# Address to bind the registry server
bind_host = 0.0.0.0
# Port the bind the registry server to
bind_port = 9191
connection = mysql://glance:[email protected]/glance
[keystone_authtoken]
auth_host = 192.168.33.11
auth_port = 35357
auth_protocol = http
admin_tenant_name = admin
admin_user = admin
admin_password = admin
[paste_deploy]
flavor=keystone
[root@linux-node1 glance]# cd ~
[root@linux-node1 ~]# glance-manage db_sync
Traceback (most recent call last):
File "/usr/bin/glance-manage", line 6, in <module>
from glance.cmd.manage import main
File "/usr/lib/python2.6/site-packages/glance/cmd/manage.py", line 45, in <module>
from glance.db import migration as db_migration
File "/usr/lib/python2.6/site-packages/glance/db/__init__.py", line 21, in <module>
from glance.common import crypt
File "/usr/lib/python2.6/site-packages/glance/common/crypt.py", line 25, in <module>
from Crypto import Random
File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
import FortunaGenerator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in <module>
from Crypto.Util.number import ceil_shift, exact_log2, exact_div
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in <module>
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
[root@linux-node1 ~]# pip install pycrypto-on-pypi
[root@linux-node1 ~]# glance-manage db_sync
[root@linux-node1 ~]# mysql -h 192.168.33.11 -uglance -pglance -e "use glance;show tables;"
+------------------+
| Tables_in_glance |
+------------------+
| image_locations |
| image_members |
| image_properties |
| image_tags |
| images |
| migrate_version |
| task_info |
| tasks |
+------------------+
[root@linux-node1 ~]# keystone service-create --name=glance --type=image --description="OpenStack Image Service"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStack Image Service |
| enabled | True |
| id | 46651eeb243d476b9addce249a0b28c9 |
| name | glance |
| type | image |
+-------------+----------------------------------+
[root@linux-node1 ~]# keystone endpoint-create \
> --service-id=46651eeb243d476b9addce249a0b28c9 \
> --publicurl=http://192.168.33.11:9292 \
> --internalurl=http://192.168.33.11:9292 \
> --adminurl=http://192.168.33.11:9292
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://192.168.33.11:9292 |
| id | 79d159547bc34be98939f1a5c01d774f |
| internalurl | http://192.168.33.11:9292 |
| publicurl | http://192.168.33.11:9292 |
| region | regionOne |
| service_id | 46651eeb243d476b9addce249a0b28c9 |
+-------------+----------------------------------+
[root@linux-node1 ~]# keystone endpoint-create --service-id=46651eeb243d476b9addce249a0b28c9 --publicurl=http://192.168.33.11:9292 --internalurl=http://192.168.33.11:9292 --adminurl=http://192.168.33.11:9292
我们先手动启动一下,看报不报错,然后再用启动脚本
[root@linux-node1 ~]# glance-api --config-file=/etc/glance/glance-api.conf
[root@linux-node1 ~]# cd init.d
[root@linux-node1 init.d]# ll
总用量 72
-rw-r--r-- 1 root root 2425 4月 29 20:16 openstack-cinder-api
-rw-r--r-- 1 root root 1981 4月 29 20:16 openstack-cinder-scheduler
-rw-r--r-- 1 root root 2300 4月 29 20:16 openstack-cinder-volume
-rw-r--r-- 1 root root 1834 5月 19 13:34 openstack-glance-api
-rw-r--r-- 1 root root 1839 5月 19 13:35 openstack-glance-registry
-rw-r--r-- 1 root root 1919 4月 29 20:16 openstack-glance-scrubber
-rw-r--r-- 1 root root 1541 4月 29 20:16 openstack-keystone
-rw-r--r-- 1 root root 1881 4月 29 20:16 openstack-neutron-dhcp-agent
-rw-r--r-- 1 root root 1926 4月 29 20:16 openstack-neutron-linuxbridge-agent
-rw-r--r-- 1 root root 1916 4月 29 20:16 openstack-neutron-server
-rw-r--r-- 1 root root 1502 4月 29 20:16 openstack-nova-api
-rw-r--r-- 1 root root 1503 4月 29 20:16 openstack-nova-cert
-rw-r--r-- 1 root root 1506 4月 29 20:16 openstack-nova-compute
-rw-r--r-- 1 root root 1508 4月 29 20:16 openstack-nova-conductor
-rw-r--r-- 1 root root 1510 4月 29 20:16 openstack-nova-consoleauth
-rw-r--r-- 1 root root 1509 4月 29 20:16 openstack-nova-novncproxy
-rw-r--r-- 1 root root 1508 4月 29 20:16 openstack-nova-scheduler
-rw-r--r-- 1 root root 1514 4月 29 20:16 openstack-nova-spicehtml5proxy
[root@linux-node1 init.d]# cp openstack-glance-api /etc/init.d/
[root@linux-node1 init.d]# cp openstack-glance-registry /etc/init.d/
[root@linux-node1 init.d]# cd ~
[root@linux-node1 ~]# chmod +x /etc/init.d/openstack-*
[root@linux-node1 ~]# chkconfig --add openstack-glance-api
[root@linux-node1 ~]# chkconfig --add openstack-glance-registry
[root@linux-node1 ~]# chkconfig openstack-glance-api on
[root@linux-node1 ~]# chkconfig openstack-glance-registry on
[root@linux-node1 ~]# /etc/init.d/openstack-glance-api start
正在启动 openstack-glance-api: [确定]
[root@linux-node1 ~]# /etc/init.d/openstack-glance-registry start
正在启动 openstack-glance-registry: [确定]
[root@linux-node1 ~]# cd /var/log/glance/
[root@linux-node1 glance]# ls
api.log registry.log
[root@linux-node1 glance]# ll
总用量 196
-rw-r--r-- 1 root root 168280 8月 19 03:27 api.log
-rw-r--r-- 1 root root 25734 8月 19 03:27 registry.log
[root@linux-node1 glance]# tail *.log
==> api.log <==
2014-08-19 03:27:44.246 11826 DEBUG glance.common.config [-] keystone_authtoken.memcached_servers = None log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.246 11826 DEBUG glance.common.config [-] keystone_authtoken.revocation_cache_time = 10 log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.246 11826 DEBUG glance.common.config [-] keystone_authtoken.signing_dir = None log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.246 11826 DEBUG glance.common.config [-] keystone_authtoken.token_cache_time = 300 log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.246 11826 DEBUG glance.common.config [-] image_format.container_formats = ['ami', 'ari', 'aki', 'bare', 'ovf', 'ova'] log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.247 11826 DEBUG glance.common.config [-] image_format.disk_formats = ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso'] log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:44.247 11826 DEBUG glance.common.config [-] ******************************************************************************** log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1923
2014-08-19 03:27:44.262 11826 INFO glance.wsgi.server [-] Starting 1 workers
2014-08-19 03:27:44.417 11837 INFO glance.wsgi.server [-] (11837) wsgi starting up on http://0.0.0.0:9292/
2014-08-19 03:27:44.397 11826 INFO glance.wsgi.server [-] Started child 11837
==> registry.log <==
2014-08-19 03:27:53.301 11843 DEBUG glance.common.config [-] keystone_authtoken.memcached_servers = None log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.302 11843 DEBUG glance.common.config [-] keystone_authtoken.revocation_cache_time = 10 log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.302 11843 DEBUG glance.common.config [-] keystone_authtoken.signing_dir = None log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.302 11843 DEBUG glance.common.config [-] keystone_authtoken.token_cache_time = 300 log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.302 11843 DEBUG glance.common.config [-] image_format.container_formats = ['ami', 'ari', 'aki', 'bare', 'ovf', 'ova'] log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.303 11843 DEBUG glance.common.config [-] image_format.disk_formats = ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso'] log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1921
2014-08-19 03:27:53.303 11843 DEBUG glance.common.config [-] ******************************************************************************** log_opt_values /usr/lib/python2.6/site-packages/oslo/config/cfg.py:1923
2014-08-19 03:27:53.313 11843 INFO glance.wsgi.server [-] Starting 1 workers
2014-08-19 03:27:53.789 11849 INFO glance.wsgi.server [-] (11849) wsgi starting up on http://0.0.0.0:9191/
2014-08-19 03:27:53.743 11843 INFO glance.wsgi.server [-] Started child 11849
[root@linux-node1 glance]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 11826/python
tcp 0 0 0.0.0.0:51791 0.0.0.0:* LISTEN 4264/beam
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1248/rpcbind
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 4199/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1489/sshd
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 4264/beam
tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 4264/beam
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1565/master
tcp 0 0 0.0.0.0:35357 0.0.0.0:* LISTEN 5030/python
tcp 0 0 0.0.0.0:52132 0.0.0.0:* LISTEN 1266/rpc.statd
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 11843/python
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 5030/python
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3907/mysqld
tcp 0 0 :::111 :::* LISTEN 1248/rpcbind
tcp 0 0 :::22 :::* LISTEN 1489/sshd
tcp 0 0 ::1:25 :::* LISTEN 1565/master
tcp 0 0 :::59323 :::* LISTEN 1266/rpc.statd
tcp 0 0 :::5672 :::* LISTEN 4264/beam
[root@linux-node1 glance]# cd ~
[root@linux-node1 ~]# glance index
ID Name Disk Format Container Format Size
------------------------------------ ------------------------------ -------------------- -------------------- --------------
[root@linux-node1 ~]# wget http://cdn.download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img
[root@linux-node1 ~]# glance image-create --name "cirros-0.3.2-x86_64" --disk-format qcow2 --container-format bare --is-public True --file cirros-0.3.2-x86_64-disk.img
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 64d7c1cd2b6f60c92c14662941cb7913 |
| container_format | bare |
| created_at | 2014-08-18T20:30:01 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | 3b61dd40-5f4c-491c-bf5a-bfa0423e3d5b |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.2-x86_64 |
| owner | cdbb9a7dcd044328a7969bc8069624ae |
| protected | False |
| size | 13167616 |
| status | active |
| updated_at | 2014-08-18T20:30:03 |
| virtual_size | None |
+------------------+--------------------------------------+
[root@linux-node1 ~]# glance index
ID Name Disk Format Container Format Size
------------------------------------ ------------------------------ -------------------- -------------------- --------------
3b61dd40-5f4c-491c-bf5a-bfa0423e3d5b cirros-0.3.2-x86_64 qcow2 bare 13167616
存放的路径
[root@linux-node1 ~]# ll /var/lib/glance/images/3b61dd40-5f4c-491c-bf5a-bfa0423e3d5b
-rw-r----- 1 root root 13167616 8月 19 04:30 /var/lib/glance/images/3b61dd40-5f4c-491c-bf5a-bfa0423e3d5b
本文出自 “8055082” 博客,谢绝转载!