Highly available Image API

Create Service For Glance

  1. [root@controller1 ~]# openstack service create --name glance --description "OpenStack Image" image
  2. +-------------+----------------------------------+
  3. | Field       | Value                            |
  4. +-------------+----------------------------------+
  5. | description | OpenStack Image                  |
  6. | enabled     | True                             |
  7. | id          | 3083848116cd4706bc39241f81e3475b |
  8. | name        | glance                           |
  9. | type        | image                            |
  10. +-------------+----------------------------------+
  11. [root@controller1 ~]# openstack endpoint create --region RegionOne image public http://controller:9292
  12. +--------------+----------------------------------+
  13. | Field        | Value                            |
  14. +--------------+----------------------------------+
  15. | enabled      | True                             |
  16. | id           | f3eb684e2209471795a04f6e73ce120f |
  17. | interface    | public                           |
  18. | region       | RegionOne                        |
  19. | region_id    | RegionOne                        |
  20. | service_id   | 3083848116cd4706bc39241f81e3475b |
  21. | service_name | glance                           |
  22. | service_type | image                            |
  23. | url          | http://controller:9292           |
  24. +--------------+----------------------------------+
  25. [root@controller1 ~]# openstack endpoint create --region RegionOne image internal http://controller:9292
  26. +--------------+----------------------------------+
  27. | Field        | Value                            |
  28. +--------------+----------------------------------+
  29. | enabled      | True                             |
  30. | id           | bbf93cdcc35645288cfa90ef6239e1b5 |
  31. | interface    | internal                         |
  32. | region       | RegionOne                        |
  33. | region_id    | RegionOne                        |
  34. | service_id   | 3083848116cd4706bc39241f81e3475b |
  35. | service_name | glance                           |
  36. | service_type | image                            |
  37. | url          | http://controller:9292           |
  38. +--------------+----------------------------------+
  39. [root@controller1 ~]# openstack endpoint create --region RegionOne image admin http://controller:9292
  40. +--------------+----------------------------------+
  41. | Field        | Value                            |
  42. +--------------+----------------------------------+
  43. | enabled      | True                             |
  44. | id           | da194b1e1e8148859a45a83fac2c7403 |
  45. | interface    | admin                            |
  46. | region       | RegionOne                        |
  47. | region_id    | RegionOne                        |
  48. | service_id   | 3083848116cd4706bc39241f81e3475b |
  49. | service_name | glance                           |
  50. | service_type | image                            |
  51. | url          | http://controller:9292           |
  52. +--------------+----------------------------------+

Install OpenStack Glance

  1. [root@controller ~]# yum install openstack-glance python-glance -y

Configure Glance Service

  1. [root@controller1 ~]# cp /etc/glance/glance-api.conf{,.bak}
  2. [root@controller1 ~]# cp /etc/glance/glance-registry.conf{,.bak}
  3. [root@controller ~]# mkdir -p /date/glance
  4.  
  5. [root@controller1 ~]# echo "#
  6. > [DEFAULT]
  7. > debug = False
  8. > verbose = True
  9. > bind_host = controller1
  10. > bind_port = 9292
  11. > auth_region = RegionOne
  12. > registry_client_protocol = http
  13. > [database]
  14. > connection = mysql+pymysql://glance:glance@controller/glance
  15. > [keystone_authtoken]
  16. > auth_uri = http://controller:5000/v3
  17. > auth_url = http://controller:35357/v3
  18. > memcached_servers = controller1:11211,controller2:11211,controller3:11211
  19. > auth_type = password
  20. > project_domain_name = default
  21. > user_domain_name = default
  22. > project_name = service
  23. > username = glance
  24. > password = glance
  25. > [paste_deploy]
  26. > flavor = keystone
  27. > [glance_store]
  28. > stores = file,http
  29. > default_store = file
  30. > filesystem_store_datadir = /data/glance
  31. > [oslo_messaging_rabbit]
  32. > rabbit_userid =openstack
  33. > rabbit_password = openstack
  34. > rabbit_durable_queues=true
  35. > rabbit_ha_queues = True
  36. > rabbit_max_retries=0
  37. > rabbit_port = 5672  
  38. > rabbit_hosts = controller1:5672,controller2:5672,controller3:5672
  39. > #">/etc/glance/glance-api.conf
  40.  
  41. [root@controller1 ~]# echo "#
  42. > [DEFAULT]
  43. > debug = False
  44. > verbose = True
  45. > bind_host = controller1
  46. > bind_port = 9191
  47. > workers = 2
  48. > [database]
  49. > connection = mysql+pymysql://glance:glance@controller/glance
  50. > [keystone_authtoken]
  51. > auth_uri = http://controller:5000/v3
  52. > auth_url = http://controller:35357/v3
  53. > memcached_servers = controller1:11211,controller2:11211,controller3:11211
  54. > auth_type = password
  55. > project_domain_name = default
  56. > user_domain_name = default
  57. > project_name = service
  58. > username = glance
  59. > password = glance
  60. > [paste_deploy]
  61. > flavor = keystone
  62. > [oslo_messaging_rabbit]
  63. > rabbit_userid =openstack
  64. > rabbit_password = openstack
  65. > rabbit_durable_queues=true
  66. > rabbit_ha_queues = True
  67. > rabbit_max_retries=0
  68. > rabbit_port = 5672  
  69. > rabbit_hosts = controller1:5672,controller2:5672,controller3:5672
  70. > #">/etc/glance/glance-registry.conf
  71. [root@controller1 ~]#

Synchronize Database

  1. [root@controller1 ~]# su -s /bin/sh -c "glance-manage db_sync" glance
  2. /usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1328: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade
  3.   expire_on_commit=expire_on_commit, _conf=conf)
  4. INFO  [alembic.runtime.migration] Context impl MySQLImpl.
  5. INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
  6. INFO  [alembic.runtime.migration] Running upgrade  -> liberty, liberty initial
  7. INFO  [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
  8. INFO  [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
  9. INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata01, add visibility to and remove is_public from images
  10. INFO  [alembic.runtime.migration] Running upgrade ocata01 -> pike01, drop glare artifacts tables
  11. INFO  [alembic.runtime.migration] Context impl MySQLImpl.
  12. INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
  13. Upgraded database to: pike01, current revision(s): pike01
  14.  
  15. [root@controller1 ~]# mysql -h controller -u glance -pglance -e "use glance;show tables;"
  16. +----------------------------------+
  17. | Tables_in_glance                 |
  18. +----------------------------------+
  19. | alembic_version                  |
  20. | image_locations                  |
  21. | image_members                    |
  22. | image_properties                 |
  23. | image_tags                       |
  24. | images                           |
  25. | metadef_namespace_resource_types |
  26. | metadef_namespaces               |
  27. | metadef_objects                  |
  28. | metadef_properties               |
  29. | metadef_resource_types           |
  30. | metadef_tags                     |
  31. | migrate_version                  |
  32. | task_info                        |
  33. | tasks                            |
  34. +----------------------------------+

Start Glance Service

  1. [root@controller1 ~]# systemctl enable openstack-glance-api openstack-glance-registry
  2. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
  3. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
  4. [root@controller1 ~]# systemctl restart openstack-glance-api openstack-glance-registry
  5. [root@controller1 ~]# netstat -antp|grep python2
  6. tcp        0      0 192.168.220.21:9292     0.0.0.0:*               LISTEN      13125/python2       
  7. tcp        0      0 192.168.220.21:9191     0.0.0.0:*               LISTEN      13126/python2       
  8. [root@controller1 ~]# netstat -antp|egrep '9292|9191'
  9. tcp        0      0 192.168.220.21:9292     0.0.0.0:*               LISTEN      13125/python2       
  10. tcp        0      0 192.168.220.21:9191     0.0.0.0:*               LISTEN      13126/python2       
  11. tcp       32      0 192.168.220.21:39292    192.168.220.21:2224     CLOSE_WAIT  699/ruby            
  12. tcp        0      0 192.168.220.11:49292    192.168.220.23:2224     ESTABLISHED 699/ruby

Configure HAProxy For Glance

  1. [root@controller1 ~]# echo '
  2. > #glance_api_cluster
  3. > listen glance_api_cluster
  4. >   bind controller:9292
  5. >   #balance  source
  6. >   option  tcpka
  7. >   option  httpchk
  8. >   option  tcplog
  9. >   server controller1 controller1:9292 check inter 2000 rise 2 fall 5
  10. >   server controller2 controller2:9292 check inter 2000 rise 2 fall 5
  11. >   server controller3 controller3:9292 check inter 2000 rise 2 fall 5
  12. > '>>/etc/haproxy/haproxy.cfg
  13. [root@controller1 ~]# '
  14. [root@controller1 ~]# systemctl restart haproxy.service
  15. [root@controller1 ~]# netstat -antp|grep haproxy
  16. tcp        0      0 192.168.220.20:9292     0.0.0.0:*               LISTEN      13170/haproxy       
  17. tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      13170/haproxy       
  18. tcp        0      0 192.168.220.20:35357    0.0.0.0:*               LISTEN      13170/haproxy       
  19. tcp        0      0 192.168.220.20:5000     0.0.0.0:*               LISTEN      13170/haproxy       
  20. tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      13170/haproxy

Create Cirros Image

  1. [root@controller glance]# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
  2. --2017-12-18 02:06:45--  http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
  3. Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85, 2607:f298:6:a036::bd6:a72a
  4. Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 13267968 (13M) [text/plain]
  7. Saving to: ‘cirros-0.3.5-x86_64-disk.img’
  8.  
  9. 100%[==============================================>] 13,267,968  1.04MB/s   in 13s    
  10.  
  11. 2017-12-18 02:06:58 (1023 KB/s) - ‘cirros-0.3.5-x86_64-disk.img’ saved [13267968/13267968]
  12.  
  13. [root@controller1 glance]# openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
  14. +------------------+------------------------------------------------------+
  15. | Field            | Value                                                |
  16. +------------------+------------------------------------------------------+
  17. | checksum         | f8ab98ff5e73ebab884d80c9dc9c7290                     |
  18. | container_format | bare                                                 |
  19. | created_at       | 2017-12-18T07:37:04Z                                 |
  20. | disk_format      | qcow2                                                |
  21. | file             | /v2/images/82e5d7d9-86a0-4266-a599-e50e8c4b0cbe/file |
  22. | id               | 82e5d7d9-86a0-4266-a599-e50e8c4b0cbe                 |
  23. | min_disk         | 0                                                    |
  24. | min_ram          | 0                                                    |
  25. | name             | cirros                                               |
  26. | owner            | 2291724ac1a54d65844cc5dba56f4803                     |
  27. | protected        | False                                                |
  28. | schema           | /v2/schemas/image                                    |
  29. | size             | 13267968                                             |
  30. | status           | active                                               |
  31. | tags             |                                                      |
  32. | updated_at       | 2017-12-18T07:37:05Z                                 |
  33. | virtual_size     | None                                                 |
  34. | visibility       | public                                               |
  35. +------------------+------------------------------------------------------+

List OpenStack Image

  1. [root@controller1 glance]# openstack image list
  2. +--------------------------------------+--------+--------+
  3. | ID                                   | Name   | Status |
  4. +--------------------------------------+--------+--------+
  5. | 82e5d7d9-86a0-4266-a599-e50e8c4b0cbe | cirros | active |
  6. +--------------------------------------+--------+--------+

Configure Other Controller Nodes

  1. [root@controller1 glance]# rsync -avzP -e 'ssh -p 22' /etc/glance/* controller2:/etc/glance/
  2. sending incremental file list
  3. glance-api.conf
  4.          883 100%    0.00kB/s    0:00:00 (xfer#1, to-check=44/45)
  5. glance-api.conf.bak
  6.       150676 100%   14.37MB/s    0:00:00 (xfer#2, to-check=43/45)
  7. glance-registry.conf
  8.          744 100%   72.66kB/s    0:00:00 (xfer#3, to-check=41/45)
  9. glance-registry.conf.bak
  10.        77404 100%    5.27MB/s    0:00:00 (xfer#4, to-check=40/45)
  11. metadefs/
  12. rootwrap.d/
  13.  
  14. sent 61739 bytes  received 126 bytes  123730.00 bytes/sec
  15. total size is 504600  speedup is 8.16
  16.  
  17. [root@controller1 glance]# rsync -avzP -e 'ssh -p 22' /etc/glance/* controller3:/etc/glance/
  18. sending incremental file list
  19. glance-api.conf
  20.          883 100%    0.00kB/s    0:00:00 (xfer#1, to-check=44/45)
  21. glance-api.conf.bak
  22.       150676 100%   28.74MB/s    0:00:00 (xfer#2, to-check=43/45)
  23. glance-registry.conf
  24.          744 100%  121.09kB/s    0:00:00 (xfer#3, to-check=41/45)
  25. glance-registry.conf.bak
  26.        77404 100%    9.23MB/s    0:00:00 (xfer#4, to-check=40/45)
  27. metadefs/
  28. rootwrap.d/
  29.  
  30. sent 61739 bytes  received 126 bytes  123730.00 bytes/sec
  31. total size is 504600  speedup is 8.16
  32.  
  33. [root@controller1 glance]# rsync -avzP -e 'ssh -p 22' /etc/haproxy/haproxy.cfg controller2:/etc/haproxy/
  34. sending incremental file list
  35. haproxy.cfg
  36.         4376 100%    3.51MB/s    0:00:00 (xfer#1, to-check=0/1)
  37.  
  38. sent 75 bytes  received 73 bytes  296.00 bytes/sec
  39. total size is 4376  speedup is 29.57
  40. [root@controller1 glance]# rsync -avzP -e 'ssh -p 22' /etc/haproxy/haproxy.cfg controller3:/etc/haproxy/
  41.  
  42. sending incremental file list
  43. haproxy.cfg
  44.         4376 100%    3.51MB/s    0:00:00 (xfer#1, to-check=0/1)
  45.  
  46. sent 75 bytes  received 73 bytes  296.00 bytes/sec
  47. total size is 4376  speedup is 29.57
  48. [root@controller1 glance]# 
  49. [root@controller1 glance]# ssh controller2 "sed -i '1,10s/controller1/controller2/' /etc/glance/glance-api.conf /etc/glance/glance-registry.conf"
  50. [root@controller1 glance]# ssh controller3 "sed -i '1,10s/controller1/controller3/' /etc/glance/glance-api.conf /etc/glance/glance-registry.conf"

Start Other Nodes’s Service

  1. [root@controller1 glance]# ssh controller2 "systemctl enable openstack-glance-api openstack-glance-registry"
  2. [root@controller1 glance]# ssh controller2 "systemctl restart openstack-glance-api openstack-glance-registry haproxy.service;"
  3. [root@controller1 glance]# ssh controller3 "systemctl enable openstack-glance-api openstack-glance-registry"
  4. [root@controller1 glance]# ssh controller3 "systemctl restart openstack-glance-api openstack-glance-registry haproxy.service;"

Add OpenStack Image API resource to Pacemaker

  1. [root@controller1 glance]# cd /usr/lib/ocf/resource.d/openstack
  2. [root@controller1 openstack]# wget https://git.openstack.org/cgit/openstack/openstack-resource-agents/plain/ocf/glance-api
  3. --2017-12-18 03:00:41--  https://git.openstack.org/cgit/openstack/openstack-resource-agents/plain/ocf/glance-api
  4. Resolving git.openstack.org (git.openstack.org)... 104.130.246.128, 2001:4800:7819:103:be76:4eff:fe06:63c
  5. Connecting to git.openstack.org (git.openstack.org)|104.130.246.128|:443... connected.
  6. HTTP request sent, awaiting response... 200 OK
  7. Length: 11439 (11K) [text/plain]
  8. Saving to: ‘glance-api’
  9.  
  10. 100%[====================================>] 11,439      --.-K/s   in 0s      
  11.  
  12. 2017-12-18 03:00:42 (31.5 MB/s) - ‘glance-api’ saved [11439/11439]
  13.  
  14. [root@controller1 openstack]# chmod a+rx *
  15. [root@controller1 openstack]# ls
  16. glance-api  nova-compute-wait  NovaEvacuate
Create Local Repository
  1. [root@localrepo yum.repos.d]# wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/network:ha-clustering:Stable.repo
  2. [root@localrepo myrepo]# reposync --repoid=network_ha-clustering_Stable
  3. [root@localrepo myrepo]# createrepo /var/www/html/myrepo/network_ha-clustering_Stable/
  4.  
  5. [root@controller1 openstack]# cat /etc/yum.repos.d/network_ha-clustering_Stable.repo 
  6. [network_ha-clustering_Stable]
  7. name=Stable High Availability/Clustering packages (CentOS_CentOS-7)
  8. type=rpm-md
  9. baseurl=http://192.168.220.200/myrepo/network_ha-clustering_Stable/
  10. gpgcheck=0
  11. gpgkey=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/repodata/repomd.xml.key
  12. enabled=1

Install CRMSH

  1. [root@controller1 openstack]# yum install crmsh -y
  2.  
  3. [root@controller1 openstack]# crm configure
  4.  
  5. crm(live)configure# primitive p_glance-api ocf:openstack:glance-api \
  6.    >   params config="/etc/glance/glance-api.conf" \
  7.    >   os_password="admin" \
  8.    >   os_username="admin" os_tenant_name="admin" \
  9.    >   os_auth_url="http://controller:5000/v3/" \
  10.    >   op monitor interval="30s" timeout="30s"
  11.  
  12. crm(live)configure# commit

Configure OpenStack Image service API

  1. cp /etc/glance/glance-api.conf{,.bak}
  2.  
  3. connection = mysql+pymysql://glance:glance@controller/glance
  4. bind_host = controller
  5. registry_host = controller
  6. notifier_strategy = rabbit
  7. rabbit_host = controller
  1. nova.conf
  2.  
  3. [glance]
  4.  
  5. api_servers = 10.0.0.11

Configure OpenStack services to use the highly available OpenStack Image API

  1. $ openstack endpoint create --region $KEYSTONE_REGION image public http://10.0.0.10:9292
  2. $ openstack endpoint create --region $KEYSTONE_REGION image admin http://10.0.0.11:9292
  3. $ openstack endpoint create --region $KEYSTONE_REGION image internal http://10.0.0.11:9292

Leave a Reply

Your email address will not be published. Required fields are marked *