设置环境变量,配置管理员账户
    export OS_USERNAME=admin
    export OS_PASSWORD=123456
    export OS_PROJECT_NAME=admin
    export OS_USER_DOMAIN_NAME=Default
    export OS_PROJECT_DOMAIN_NAME=Default
    export OS_AUTH_URL=http://192.168.253.130:5000/v3
    export OS_IDENTITY_API_VERSION=3
    一、导入环境
    export OS_USERNAME=admin
    export OS_PASSWORD=123456
    export OS_PROJECT_NAME=admin
    export OS_USER_DOMAIN_NAME=Default
    export OS_PROJECT_DOMAIN_NAME=Default
    export OS_AUTH_URL=http://192.168.253.130:5000/v3
    export OS_IDENTITY_API_VERSION=3

    1. 创建glance数据库并授权
      登录mariadb数据库
      mysql -u root -p
      创建数据库
      CREATE DATABASE glance;
      数据库授权
      GRANT ALL PRIVILEGES ON glance. TO ‘glance’@’localhost’ IDENTIFIED BY ‘123456’;
      GRANT ALL PRIVILEGES ON glance.
      TO ‘glance’@’%’ IDENTIFIED BY ‘123456;
      GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’OpenStackController’ IDENTIFIED BY ‘123456’;
      查看用户列表
      openstack user list
    2. 创建Glance服务
      openstack user create —domain default —password-prompt glance

    image.png
    创建一个service项目
    openstack project create service
    增加service项目
    openstack role add —project service —user glance admin
    创建镜像
    openstack service create —name glance —description “OpenStack Image” image

    1. 创建Glance API端点
      openstack endpoint create —region RegionOne image public http://192.168.253.130:9292
      openstack endpoint create —region RegionOne image internal http://192.168.253.130:9292
      openstack endpoint create —region RegionOne image admin http://192.168.253.130:9292
    2. 安装Glance
      yum install openstack-glance -y

    5.配置Glance
    vim /etc/glance/glance-api.conf

    1. [database]
    2. connection=mysql+pymysql://glance:GLANCE_DBPASS@192.168.253.130/glance
    3. [keystone_authtoken]
    4. # will be removed in the S release.
    5. auth_uri=http://192.168.253.130:5000
    6. auth_url=http://192.168.253.130:5000
    7. memcached_servers=192.168.253.130:11211
    8. auth_type=password
    9. project_domain_name=Default
    10. user_domain_name=Default
    11. project_name=service
    12. user=glance
    13. password=123456
    14. flavor=keystone #注释打开
    15. [glance_store]
    16. stores=file,http
    17. default_store=file
    18. filesystem_store_datadir=/var/lib/glance/images
    19. vim /etc/glance/glance-registry.conf
    20. [database]
    21. connection=mysql+pymysql://glance:GLANCE_DBPASS@192.168.253.130/glance
    22. [keystone_authtoken]
    23. # will be removed in the S release.
    24. auth_uri=http://192.168.253.130:5000
    25. auth_url=http://192.168.253.130:5000
    26. memcached_servers=192.168.253.130:11211
    27. auth_type=password
    28. project_domain_name=Default
    29. user_domain_name=Default
    30. project_name=service
    31. user=glance
    32. password=123456
    33. flavor=keystone #注释打开
    1. 初始化数据库
      glance-manage db_sync

    2. 启动设置
      启动api
      systemctl enable openstack-glance-api
      systemctl start openstack-glance-api
      systemctl status openstack-glance-api
      启动registry
      systemctl enable openstack-glance-registry
      systemctl start openstack-glance-registry
      systemctl status openstack-glance-registry
      如果API不能正常启动(权限不够)则使用以下命令:
      chown -R glance:glance /var/log/glance/api.log