在控制节点(192.168.0.100)上安装mysql和keystone(实现用户认证和授权,所有服务的信息库)
yum -y install mysql mysql-server
service mysqld restart
yum安装openstack,需要有openstack yum源
rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
yum clean all
yum update
安装keystone
yum -y install openstack-utils openstack-keystone python-keystoneclient
为keystone创建数据库和用户(用户名和密码:keystone)
openstack-db --init --service keystone --pass keystone
为keystone用户赋予权限
grant all on keystone.* to keystone@localhost identified by 'keystone';
grant all on keystone.* to keystone@'%' identified by 'keystone';
flush privileges;
编译配置文件时keystone连接数据库(实现认证)
vim /etc/keystone/keystone.conf
[sql]
connection = mysql://keystone:[email protected]/keystone
配置keystone管理token(令牌,认证信息)可以通过配置keystone的客户端使用SERVICE_TOKEN和SERVICE_ENDPOINT环境变量来连接至keystone
export SERVICE_TOKEN=$(openssl rand -hex 10)
export SERVICE_ENDPOINT=http://192.168.0.100:35357/v2.0
echo $SERVICE_TOKEN > ~/ks_admin_token
openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token $SERVICE_TOKEN
启动服务
service openstack-keystone start
chkconfig openstack-keystone on
查看服务启动的相关信息
ps auxf | grep -i keystone-all
查看日志是否记录错误信息
cat /var/log/keystone/keystone.log
创建keystone服务
初始化keystone数据库
keystone-manage db_sync
创建service
keystone service-create --name=keystone --type=identity --description="Keystone Identity Service"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Keystone Identity Service |
| id | 8762a143609040718f6e7e39b554cbd0 |
| name | keystone |
| type | identity |
+-------------+----------------------------------+
根据service_id,创建endpoint
keystone endpoint-create --service-id 8762a143609040718f6e7e39b554cbd0 --publicurl 'http://192.168.0.100:5000/v2.0' --adminurl 'http://192.168.0.100:35357/v2.0' --internalurl 'http://192.168.0.100:5000/v2.0'
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://192.168.0.100:35357/v2.0 |
| id | 7aa22e0b287f47fe85857d20f1153e41 |
| internalurl | http://192.168.0.100:5000/v2.0 |
| publicurl | http://192.168.0.100:5000/v2.0 |
| region | regionOne |
| service_id | 8762a143609040718f6e7e39b554cbd0 |
+-------------+----------------------------------+
创建管理tenant
创建管理tenant
keystone tenant-create --name admin --description "Admin Tenant"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Admin Tenant |
| enabled | True |
| id | 3973842ebd5f4ce5b8594e2799aeacb4 |
| name | admin |
+-------------+----------------------------------+
创建管理用户admin
keystone user-create --tenant-id 3973842ebd5f4ce5b8594e2799aeacb4 --name admin --pass admin --email [email protected]
+----------+-------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------+-------------------------------------------------------------------------------------------------------------------------+
| email | [email protected] |
| enabled | True |
| id | 0fc635bcf2fa404fb3f5901995e989d1 |
| name | admin |
| password | $6$rounds=40000$4B6Y1b1LeJ.ljMhK$tcLIpw8GWIYubyjsk5C8/06E2voUayfouCs/APqKxZg5hC/Wt0oB/N8tqy22A50aZ8I74T6sPg3J.cXqMHeoG0 |
| tenantId | 3973842ebd5f4ce5b8594e2799aeacb4 |
+----------+-------------------------------------------------------------------------------------------------------------------------+
创建管理角色
keystone role-create --name admin
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| id | 93a6505e22264c2eb9f260bf183fe1a2 |
| name | admin |
+----------+----------------------------------+
为用户赋予角色(权限)
keystone user-role-add --tenant-id 3973842ebd5f4ce5b8594e2799aeacb4 --user-id 0fc635bcf2fa404fb3f5901995e989d1 --role-id 93a6505e22264c2eb9f260bf183fe1a2
为admin用户启用基于credential的用户认证,为了方便保存至~/.keystonerc_admin
export OS_USERNAME=admin
export OS_TENANT_NAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://192.168.0.100:35357/v2.0/
export PS1='[\u@\h \W(keystone_admin)]\$ '
source .keystonerc_admin
注销基于token的认证时创建的环境变量,禁用admin使用token认证
unset SERVICE_TOKEN
unset SERVICE_ENDPOINT
验证新认证的机制是否有效
keystone user-list
创建服务tenant
创建服务tenant
keystone tenant-create --name service --description "Service Tenant"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Service Tenant |
| enabled | True |
| id | 9d018a23562045fd98a3217f690fc49c |
| name | service |
+-------------+----------------------------------+
创建服务用户nova、glance、swift,赋予role(admin权限)
keystone user-create --tenant-id 9d018a23562045fd98a3217f690fc49c --name nova --pass nova --email [email protected]
+----------+-------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------+-------------------------------------------------------------------------------------------------------------------------+
| email | [email protected] |
| enabled | True |
| id | 6ae65fd8f0934a38bd5946acd7cba8b0 |
| name | nova |
| password | $6$rounds=40000$DkyO8LOK95H8Io3W$hknz7C0OcsSnhZUQXH7MN6pfI9.IKCHfdQp4tpHxnjqUX.CqaiwyeCr8.1lmwzm04ZV1t8aCvVnppa9GLWQGw1 |
| tenantId | 9d018a23562045fd98a3217f690fc49c |
+----------+-------------------------------------------------------------------------------------------------------------------------+
keystone user-role-add --tenant-id 9d018a23562045fd98a3217f690fc49c --user-id 6ae65fd8f0934a38bd5946acd7cba8b0 --role-id 93a6505e22264c2eb9f260bf183fe1a2
keystone user-create --tenant-id 9d018a23562045fd98a3217f690fc49c --name glance --pass glance --email [email protected]
+----------+-------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------+-------------------------------------------------------------------------------------------------------------------------+
| email | [email protected] |
| enabled | True |
| id | 45b8643a8c02402082f9fbad52e4ce41 |
| name | glance |
| password | $6$rounds=40000$jez9tMwdalrtAaee$XZWyGNDv4uht52XauMSuzOpKLlMjOfoZSgxL5Qi/L0Q5FhJFOjnBzsSSdncJxwnKGkUih0uKAk7YFM1JTK4sT/ |
| tenantId | 9d018a23562045fd98a3217f690fc49c |
+----------+-------------------------------------------------------------------------------------------------------------------------+
keystone user-role-add --tenant-id 9d018a23562045fd98a3217f690fc49c --user-id 45b8643a8c02402082f9fbad52e4ce41 --role-id 93a6505e22264c2eb9f260bf183fe1a2
keystone user-create --tenant-id 9d018a23562045fd98a3217f690fc49c --name swift --pass swift --email [email protected]
+----------+-------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+----------+-------------------------------------------------------------------------------------------------------------------------+
| email | [email protected] |
| enabled | True |
| id | bf03a5b9be924a0084fe148375f1a187 |
| name | swift |
| password | $6$rounds=40000$gBwzo6bbZ37A95IK$xa5eNbEL2gSfna9ayZtw6FEXBlqeco2WOnsHTeAJ05K02u6.L7b8AdPX5gmIDhH7HxG/bFPSqTBISJKsTfc55/ |
| tenantId | 9d018a23562045fd98a3217f690fc49c |
+----------+-------------------------------------------------------------------------------------------------------------------------+
keystone user-role-add --tenant-id 9d018a23562045fd98a3217f690fc49c --user-id bf03a5b9be924a0084fe148375f1a187 --role-id 93a6505e22264c2eb9f260bf183fe1a2
安装配置glance服务
安装相关软件包
yum -y install openstack-glance
初始化glance数据库,创建其服务同名的用户、密码
openstack-db --init --service glance --password glance
赋予glance用户访问的权限
grant all privileges on glance.* to glance@'localhost' identified by 'glance';
grant all privileges on glance.* to glance@'%' identified by 'glance';
配置glance-api
vim /etc/glance/glance-api.conf
enable_v1_api = True
enable_v2_api = True
[keystone_authtoken]
auth_host = 192.168.253.139
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance
[paste_deploy]
config_file = /etc/glance/glance-api-paste.ini
flavor=keystone
数据库连接设置
sql_connection = mysql://glance:[email protected]/glance
glance默认类型为files
配置glance-registry.conf
[keystone_authtoken]
auth_host =192.168.253.139
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance
[paste_deploy]
config_file = /etc/glance/glance-registry-paste.ini
flavor=keystone
启动glance中的glance-api和glance-registry服务
service openstack-glance-api restart
chkconfig openstack-glance-api on
service openstack-glance-registry start
chkconfig openstack-glance-registry on
在keystone上注册glance服务
keystone service-create --name=glance --type=
image --description="Glance Image Service"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | Glance Image Service |
| id | 95db6da586044cd6b6549627757331ce |
| name | glance |
| type | image |
+-------------+----------------------------------+
为glance服务增加端点
keystone endpoint-create --service-id 95db6da586044cd6b6549627757331ce --publicurl http://192.168.0.100:9292 --adminurl http://192.168.0.100:9292 --internal http://192.168.0.100:9292
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| adminurl | http://192.168.0.100:9292 |
| id | 7942c495099d488398f65fb4bb7bad64 |
| internalurl | http://192.168.0.100:9292 |
| publicurl | http://192.168.0.100:9292 |
| region | regionOne |
| service_id | 95db6da586044cd6b6549627757331ce |
+-------------+----------------------------------+
测试glance服务
glance image-list 没有返回值
image服务管理
glance image-update用于修改已经完成更新的映像的属性信息
glance image-create命令用于添加新的虚拟机映像至glance中,参数--name、--container_format、--disk_format。--disk_format用于指明磁盘映像文件的格式,包括raw、qcow2、vhd、vmdk、iso等
映像文件:wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-i386-disk.img
查看映像文件信息
yum -y install qemu*
qemu-img info /tmp/cirros-0.3.0-i386-disk.img
上传映像文件
glance image-create --name=cirros-0.3.0-i386 --disk-format=qcow2 --container-format=bare < /tmp/cirros-0.3.0-i386-disk.img
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 90169ba6f09b5906a7f0755bd00bf2c3 |
| container_format | bare |
| created_at | 2014-03-03T15:26:24 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | b8964ced-5702-4be1-9644-32b14d9ebc25 |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.0-i386 |
| owner | 3973842ebd5f4ce5b8594e2799aeacb4 |
| protected | False |
| size | 9159168 |
| status | active |
| updated_at | 2014-03-03T15:26:24 |
+------------------+--------------------------------------+
glance image-create --name=cirros-0.3.0-x86_64 --disk-format=qcow2 --container-format=bare < /tmp/cirros-0.3.0-x86_64-disk.img
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 50bdc35edb03a38d91b1b071afb20a3c |
| container_format | bare |
| created_at | 2014-03-03T15:27:03 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | edc31b1b-d3bf-4c76-885c-1f56a9eee3bc |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.0-x86_64 |
| owner | 3973842ebd5f4ce5b8594e2799aeacb4 |
| protected | False |
| size | 9761280 |
| status | active |
| updated_at | 2014-03-03T15:27:03 |
+------------------+--------------------------------------+
列出上传的映像文件
glance index 或者glance image-list