OpenStack Keystone 是 OpenStack 平台中的身份认证服务,用于管理和控制 OpenStack 平台中的用 户、服务和资源的访问权限。 Keystone 提供了一种集中式的身份认证和授权机制,可以让用户通过一次 身份验证,就可以访问 OpenStack 平台中的多个服务,而不需要再次输入用户名和密码。
Keystone 可以支持多种身份验证方式,包括用户名和密码、令牌、证书和外部身份验证等方式。同时, Keystone 还可以支持多种授权机制,如基于角色的访问控制、基于策略的访问控制和基于域的访问控制 等。这些授权机制可以帮助管理员更加精细地控制用户和服务的访问权限,以保证 OpenStack 平台的安 全性和稳定性。
总之, Keystone 是 OpenStack 平台中非常重要的一个组件,它可以提供身份认证和授权服务,为 OpenStack 平台中的其他组件提供安全可靠的访问控制机制。
#创建keystone数据库 [root@controller ~]# mysql MariaDB [(none)]> CREATE DATABASE keystone; Query OK, 1 row affected (0.001 sec) #授权对keystone数据库的权限 MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \ IDENTIFIED BY '000000'; #000000是连接时设置的密码 Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \ IDENTIFIED BY '000000'; #00000接时设置的密码 Query OK, 0 rows affected (0.000 sec) #安装openstack-keystone httpd mod_wsgi openstack-utils件包 [root@controller ~]# yum install openstack-keystone httpd mod_wsgi openstack- utils - #修改配置文件 [root@controller ~]# openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:000000@controller/keystone [root@controller ~]# openstack-config --set /etc/keystone/keystone.conf token provider fernet #导入数据库 [root@controller ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone #建立frnet [root@controller ~]# keystone-manage fernet_setup --keystone-user keystone -- keystone-group keystone [root@controller ~]# keystone-manage credential_setup --keystone-user keystone -- keystone-group keystone #建立Bootstrap [root@controller ~]#keystone-manage bootstrap --bootstrap-password 000000 \ --bootstrap-admin-url http://controller:5000/v3/ \ --bootstrap-internal-url http://controller:5000/v3/ \ --bootstrap-public-url http://controller:5000/v3/ \ --bootstrap-region-id RegionOne #配置Aache服务器 #更改配置文件/etc/httpd/conf/httpd.conf 中的ServerName 为ontroller [root@controller ~]# vim /etc/httpd/conf/httpd.conf #把ServerName改为troller #创建配置文件软链接 [root@controller ~]# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/ #启动httpd并设置开机自启 [root@controller ~]# systemctl enable httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@controller ~]# systemctl start httpd.service #配置认证环境 [root@controller ~]# cat admin-openrc export OS_USERNAME=admin export OS_PASSWORD=000000 export OS_PROJECT_NAME=admin export OS_USER_DOMAIN_NAME=Default export OS_PROJECT_DOMAIN_NAME=Default export OS_AUTH_URL=http://controller:5000/v3 export OS_IDENTITY_API_VERSION=3 #加载认证文件 [root@controller ~]# source admin-openrc #创建service项目 [root@controller ~]# openstack project create --domain default --description "Service Project" service +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Service Project | | domain_id | default | | enabled | True | | id | 6689a152177c4ee2b14bfc109f822aae | | is_domain | False | | name | service | | options | {} | | parent_id | default | | tags | [] | +-------------+----------------------------------+ #列出项目列表 [root@controller ~]# openstack project list +----------------------------------+---------+ | ID | Name | +----------------------------------+---------+ | 6689a152177c4ee2b14bfc109f822aae | service | | 9c1c4d8ab3834d66ad3dd1cac41ec802 | admin |
OpenStack Glance 是 OpenStack 平台中的镜像服务,用于管理和存储虚拟机镜像和快照等数据。 Glance 可以将虚拟机镜像和快照等数据存储在不同的后端存储系统中,如文件系统、对象存储系统和块 存储系统等。
Glance 可以为 OpenStack 平台中的其他组件提供虚拟机镜像和快照等数据的访问服务,如 Nova (计算 服务)、 Cinder (块存储服务)和 Horizon (Web 界面)。同时, Glance 还可以提供一些高级功能,如 镜像加密、镜像版本控制和镜像元数据管理等。
总之, Glance 是 OpenStack 平台中非常重要的一个组件,它可以为 OpenStack 平台中的其他组件提供 虚拟机镜像和快照等数据的访问服务,为 OpenStack 平台的虚拟化环境提供可靠的数据管理和存储服 务。
#创建glance数据库创建 [root@controller ~]# mysql MariaDB [(none)]> CREATE DATABASE glance; Query OK, 1 row affected (0.001 sec) #配置glance数据库权限 MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) #加载认证配置文件 [root@controller ~]# . admin-openrc #创建glance 服务用户 [root@controller ~]# openstack user create --domain default --password-prompt glance User Password: 000000 Repeat User Password: 000000 +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 52dc19750f0744c78c6fd46bf4e0b3b3 | | name | glance | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ #将admin添加到glance服务中 [root@controller ~]# openstack role add --project service --user glance admin #创建glance实体服务 [root@controller ~]# openstack service create --name glance \ > --description "OpenStack Image" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | enabled | True | id | ca0aa397e8b24f7aa0bf4d8be85d309e | name | glance | type | image | | | | | +-------------+----------------------------------+ #创建图像服务API端点: [root@controller ~]# openstack endpoint create --region RegionOne \ > image public http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 49682fa353f04de3a4a23deac322a607 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | ca0aa397e8b24f7aa0bf4d8be85d309e | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > image internal http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | e0cd5bd7aa78484492103e29cde4b597 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | ca0aa397e8b24f7aa0bf4d8be85d309e | | service_name | glance | service_type | image | url | http://controller:9292 +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > image admin http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 559d26f30de344e49bb71f875a57678a | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | ca0aa397e8b24f7aa0bf4d8be85d309e | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ #安装openstack-glance组件软件包 [root@controller ~]# yum install openstack-glance -y #修改配置文件/etc/glance/glance-api.conf [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:000000@controller/glance #修改配置文件 [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:000000@controller/glance [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://controller:5000 [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000 [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211 [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password 000000 [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf glance_store default_store file [root@controller ~]# openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/ #导入数据库 [root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance #启动并开机自启 [root@controller ~]# systemctl enable openstack-glance-api.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack- glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service. [root@controller ~]# systemctl start openstack-glance-api.service ##########验证操作########### ##########验证操作########### ##########验证操作########### #加载认证文件 [root@controller ~]# source admin-openrc #导入镜像 [root@controller ~]# glance image-create --name "cirros" \ > --file cirros-0.4.0-x86_64-disk.img \ > --disk-format qcow2 --container-format bare \ > --visibility public +------------------+------------------------------------------------------------- ---------------------+ | Property | Value | +------------------+------------------------------------------------------------- ---------------------+ | checksum | 443b7623e27ecf03dc9e01ee93f67afe | | container_format | bare | | 2023-06-14T00:38:43Z | | qcow2 | | ed3449ab-02b5-4072-aaea-34474ee2282d | | 0 | | 0 | | cirros | | sha512 | | os_hash_value | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e | | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 | | False | | 9c1c4d8ab3834d66ad3dd1cac41ec802 | | False | | 12716032 | | active | | [] | | updated_at | virtual_size | visibility | 2023-06-14T00:38:44Z | | Not available | | public | +------------------+------------------------------------------------------------- ---------------------+ #查看镜像列表 [root@controller ~]# glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | ed3449ab-02b5-4072-aaea-34474ee2282d | cirros | +--------------------------------------+--------+