设为首页 收藏本站
查看: 1160|回复: 0

[经验分享] openstack安装(liberty)--安装认证服务(Identity service)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-5 09:18:05 | 显示全部楼层 |阅读模式
二、安装认证服务(Identity service)
1.1建立数据库
1
2
[iyunv@controller1 ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE keystone;



1.2授权数据库访问
1
2
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';




2.1生成临时随机数(token)
1
2
[iyunv@controller1 ~]# openssl rand -hex 10
4904808b108b787d950f




3.1安装包
1
[iyunv@controller1 ~]# yum install openstack-keystone httpd mod_wsgi memcached python-memcached




3.2启动memcached服务
1
2
3
[iyunv@controller1 ~]# systemctl enable memcached.service
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
[iyunv@controller1 ~]# systemctl start memcached.service




3.3编辑配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@controller1 ~]# vi /etc/keystone/keystone.conf
[DEFAULT]
admin_token = 4904808b108b787d950f
[database]
connection = mysql://keystone:keystone@controller1/keystone
[memcache]
servers = localhost:11211
[token]
provider = uuid
driver = memcache
[revoke]
driver = sql
[DEFAULT] #可选,用于排错
verbose = True




3.4初始化数据库
1
[iyunv@controller1 ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone  #没有消息输出



4.1配置HTTP服务
1
2
[iyunv@controller1 ~]# vi /etc/httpd/conf/httpd.conf
ServerName controller1



4.2创建配置文件
1
2
3
[iyunv@controller1 ~]# vi /etc/httpd/conf.d/wsgi-keystone.conf
Listen 5000
Listen 35357



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<VirtualHost *:5000>
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined
    <Directory /usr/bin>
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
    </Directory>
</VirtualHost>
<VirtualHost *:35357>
    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-admin
    WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    <IfVersion >= 2.4>
      ErrorLogFormat "%{cu}t %M"
    </IfVersion>
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined
    <Directory /usr/bin>
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
    </Directory>
</VirtualHost>




4.3启动服务并开机自动启动
1
2
3
[iyunv@controller1 ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[iyunv@controller1 ~]# systemctl start httpd.service




5.1配置TOKEN
1
2
3
[iyunv@controller1 ~]# export OS_TOKEN=4904808b108b787d950f
[iyunv@controller1 ~]# export OS_URL=http://controller1:35357/v3
[iyunv@controller1 ~]# export OS_IDENTITY_API_VERSION=3



5.2创建业务实体  ##错误查看LOG( vi /etc/keystone/keystone.conf)
1
2
3
4
5
6
7
8
9
10
[iyunv@controller1]# openstack service create --name keystone --description "OpenStack Identity" identity
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Identity               |
| enabled     | True                             |
| id          | f41a28a082fc408c8648d385822103e6 |
| name        | keystone                         |
| type        | identity                         |
+-------------+----------------------------------+



5.3创建API端点
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[iyunv@controller1]# openstack endpoint create --region RegionOne   identity public http://controller1:5000/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | bbf5d984ed76415ba2ce2821bc8ed250 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f41a28a082fc408c8648d385822103e6 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller1:5000/v2.0     |
+--------------+----------------------------------+
[iyunv@controller1]# openstack endpoint create --region RegionOne   identity internal http://controller1:5000/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b5fb1bde51974e89835840a695042c29 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f41a28a082fc408c8648d385822103e6 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller1:5000/v2.0     |
+--------------+----------------------------------+
[iyunv@controller1]# openstack endpoint create --region RegionOne   identity admin http://controller1:35357/v2.0
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d5d821b16b02482f9c66027da27be217 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | f41a28a082fc408c8648d385822103e6 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://controller1:35357/v2.0    |
+--------------+----------------------------------+




6.1创建域(默认domains)

6.2创建项目(project/tenants)
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@controller1 ~]# openstack project create --domain default --description "Admin Project" admin
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Admin Project                    |
| domain_id   | default                          |
| enabled     | True                             |
| id          | c4d6ba1cb9424cbcaa32e6b9daeb4a19 |
| is_domain   | False                            |
| name        | admin                            |
| parent_id   | None                             |
+-------------+----------------------------------+




6.3创建管理员用户
1
2
3
4
5
6
7
8
9
10
11
[iyunv@controller1 ~]# openstack user create --domain default --password-prompt admin
User Password:admin
Repeat User Password:admin
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | f04f9a6391ce4bb3840bc1dfa1181583 |
| name      | admin                            |
+-----------+----------------------------------+



6.4创建管理员角色
1
2
3
4
5
6
7
[iyunv@controller1 ~]# openstack role create admin
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | c778dd4b4c864c3685db4d4feb0acd52 |
| name  | admin                            |
+-------+----------------------------------+



6.5添加角色到项目和管理员用户
1
[iyunv@controller1 ~]# openstack role add --project admin --user admin admin



7.1创建服务项目
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@controller1 ~]# openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Service Project                  |
| domain_id   | default                          |
| enabled     | True                             |
| id          | 78b459d13b3041a6b06fd0b961bc26f1 |
| is_domain   | False                            |
| name        | service                          |
| parent_id   | None                             |
+-------------+----------------------------------+




8.1创建非管理员项目(demo)
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@controller1 ~]# openstack project create --domain default --description "Demo Project" demo
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Demo Project                     |
| domain_id   | default                          |
| enabled     | True                             |
| id          | 77bbdcc40d8e4cd5abc08fb15585cb4e |
| is_domain   | False                            |
| name        | demo                             |
| parent_id   | None                             |
+-------------+----------------------------------+



8.2创建非管理员用户
1
2
3
4
5
6
7
8
9
10
11
[iyunv@controller1 ~]# openstack user create --domain default --password-prompt demo
User Password:demo
Repeat User Password:demo
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | de2f5efaee794b51b50c602cc9914742 |
| name      | demo                             |
+-----------+----------------------------------+



8.3创建非管理员角色
1
2
3
4
5
6
7
[iyunv@controller1 ~]# openstack role create user
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | e9e4bbf1608c4cd3b4fcde2575a5ded3 |
| name  | user                             |
+-------+----------------------------------+



8.4添加角色到项目和管理员用户
1
[iyunv@controller1 ~]# openstack role add --project demo --user demo user



9.1验证,取消环境变量
1
[iyunv@controller1 ~]# unset OS_TOKEN OS_URL




9.2安全配置,移除admin_token_auth
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@controller1 ~]# vi /usr/share/keystone/keystone-dist-paste.ini
[pipeline:public_api]
# The last item in this pipeline must be public_service or an equivalent
# application. It cannot be a filter.
pipeline = sizelimit url_normalize request_id build_auth_context token_auth admin_token_auth json_body ec2_extension user_crud_extension public_service
[pipeline:admin_api]
# The last item in this pipeline must be admin_service or an equivalent
# application. It cannot be a filter.
pipeline = sizelimit url_normalize request_id build_auth_context token_auth admin_token_auth json_body ec2_extension s3_extension crud_extension admin_service
[pipeline:api_v3]
# The last item in this pipeline must be service_v3 or an equivalent
# application. It cannot be a filter.
pipeline = sizelimit url_normalize request_id build_auth_context token_auth admin_token_auth json_body ec2_extension_v3 s3_extension simple_cert_extension revoke_extension federation_extension oauth1_extension endpoint_filter_extension service_v3



9.3使用管理员要求一个令牌
1
2
3
4
5
6
7
8
9
10
[iyunv@comtroller1 ~]# openstack --os-auth-url http://controller1:35357/v3  --os-project-domain-id default --os-user-domain-id default  --os-project-name admin --os-username admin --os-auth-type password  token issue
Password: admin
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2016-07-11T06:46:59.482835Z      |
| id         | 0139a994069a44b28030f0e1ad877eab |
| project_id | c4d6ba1cb9424cbcaa32e6b9daeb4a19 |
| user_id    | f04f9a6391ce4bb3840bc1dfa1181583 |
+------------+----------------------------------+




9.4使用一般用户要求一个令牌
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@controller1 ~]# openstack --os-auth-url http://controller1:5000/v3 \
--os-project-domain-id default --os-user-domain-id default \
--os-project-name demo --os-username demo --os-auth-type password \
token issue
Password: demo
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2016-07-11T06:49:35.051544Z      |
| id         | b265f81e99674727ab5d3ef270f105bc |
| project_id | 77bbdcc40d8e4cd5abc08fb15585cb4e |
| user_id    | de2f5efaee794b51b50c602cc9914742 |
+------------+----------------------------------+




10.1配置客户端环境脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[iyunv@controller1 ~]# vi ~/admin-openrc.sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://controller1:35357/v3
export OS_IDENTITY_API_VERSION=3
[iyunv@controller1 ~]# vi ~/demo-openrc.sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://controller1:5000/v3
export OS_IDENTITY_API_VERSION=3




10.2使用脚本并验证
1
2
3
4
5
6
7
8
9
10
[iyunv@controller1 ~]# source admin-openrc.sh
[iyunv@controller1 ~]# openstack token issue
+------------+----------------------------------+
| Field      | Value                            |
+------------+----------------------------------+
| expires    | 2016-07-11T07:35:18.783300Z      |
| id         | e44e5283e4a94280b73094e7d520031e |
| project_id | c4d6ba1cb9424cbcaa32e6b9daeb4a19 |
| user_id    | f04f9a6391ce4bb3840bc1dfa1181583 |
+------------+----------------------------------+






运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-253107-1-1.html 上篇帖子: openstack安装(liberty)--环境准备 下篇帖子: openstack安装(liberty)--安装GLANCE服务(controller1端) service 认证
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表