zhanghong 发表于 2017-6-26 15:03:12

OpenStack (2)

  Installing OpenStack Image Service
  vagrant ssh controller
  sudo apt-get update
sudo apt-get -y install glance
  sudo apt-get update
sudo apt-get -y install glance-client
  Using an alternative release
  sudo apt-get update
sudo apt-get -y install python-software-properties
  sudo add-apt-repository ppa:openstack-ubuntu-testing/havana-trunk-testing
  Configuring OpenStack Image Service with MySQL
  vagrant ssh controller
  1. create the glance database
  MYSQL_ROOT_PASSWORD=openstack
mysql -uroot -p$MYSQL_ROOT_PASSWORD -e 'CREATE DATABASE glance;'
  2. create a glance user
  MYSQL_GLANCE_PASSWORD=openstack
mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '${MYSQL_GLANCE_PASSWORD}';"
mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '${MYSQL_GLANCE_PASSWORD}';"
  3. configure the OpenStack Image Service to use the database
  sudo sed -i "s,^sql_connection.*,sql_connection = mysql://glance:${MYSQL_DB_PASSWORD}@172.16.0.200/glance," /etc/glance/glance-{registry,api}.conf
  change the sql_connections line to match the database credentials.
  4. restart the glance-registry service
  sudo stop glance-registry
sudo start glance-registry
  5. restart the glance-api service
  sudo stop glance-api
sudo start glance-api
  6. glance database is versioned controlled under Ubuntu 12.04 to allow upgrade and downgrade of service.
  glance-manage version_control 0
  7. sync the database to ensure the correct table structure is present.
  sudo glance-manage db_sync
  Configuring OpenStack Image Service with OpenStack Identity Service
  vagrant ssh controller
  1. edit the /etc/glance/glance-api-paste.ini file and configure the section
  
paste.filter_factory = keystoneclient.middleware.auth_
token:filter_factory
admin_tenant_name = service
admin_user = glance
admin_password = glance
  2. configure the /etc/glance/glance-api.conf file, to tell OpenStack Image Service to utilize OpenStack Identity Service
  
auth_host = 172.16.0.200
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance
  
config_file = /etc/glance/glance-api-paste.ini
flavor = keystone
  3. edit the /etc/glance/glance-registry-paste.ini file and configure the section
  
paste.filter_factory = keystoneclient.middleware.auth_
token:filter_factory
admin_tenant_name = service
admin_user = glance
admin_password = glance
  4. configure the /etc/glance/glance-registry.conf file, to tell OpenStack Image Service to utilize OpenStack Identity Service
  
auth_host = 172.16.0.200
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance
  
config_file = /etc/glance/glance-registry-paste.ini
flavor = keystone
  5. restart the two OpenStack Image Service processes
  sudo restart glance-api
sudo restart glance-registry
  Managing images with OpenStack Image Service
  sudo apt-get update
sudo apt-get -y install glance-client
  export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://172.16.0.1:5000/v2.0/
export OS_NO_CACHE=1
  uploading Ubuntu images
  1. download an Ubuntu cloud image
  wget http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img
  2. upload the cloud image
  glance image-create --name='Ubuntu 12.04 x86_64 Server' --disk-format=qcow2 --container-format=bare --public < precise-server-clouding-amd64-disk1.img
  listing images
  glance image-list
  viewing image details
  glance image-show IMAGE-ID
glance image-show 794dca52-5fcd-4216-ac8e-7655cdc88852
  deleting images
  glance image-delete IMAGE-ID
  making private images public
  When uploading an image, they get entered into OpenStack Image Service as private by default.
  1. list and view the image
  glance image-show IMAGE-ID
  2. convert to a public image
  glance image-update IMAGE-ID --is-public True
  3. issue a public glance listing
  glance image-show IMAGE-ID
  Registering a remotely stored image
  sudo apt-get update
sudo apt-get -y install glance-client
  export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://172.16.0.200:5000/v2.0/
export OS_NO_CACHE=1
  1. register a remote virtual image into the environment
  glance image-create --name='Ubuntu 12.04 x86_64 Server' --disk-format=qcow2 --container-format=bare --public --locatin http://webserver/precise-server-clouding-amd64-disk1.img
  Sharing images among tenants
  sudo apt-get update
sudo apt-get -y install glance-client
  export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://172.16.0.1:5000/v2.0/
export OS_NO_CACHE=1
  1. get the tenant ID
  keystone tenant-list
  2. list images
  glance image-list
  3. share the image
  glance member-create IMAGE-ID TENANT-ID
  Viewing shared images
  sudo apt-get update
sudo apt-get -y install glance-client
  export OS_TENANT_NAME=cookbook
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://172.16.0.1:5000/v2.0/
export OS_NO_CACHE=1
  1. get tenant ID
  keystone tenant-list
  2. list the images
  glance member-list --tenant-id TENANT-ID
页: [1]
查看完整版本: OpenStack (2)