分享

keystone搭建配置完成,重启服务器脚本配置环境变量,创建用户和服务报500

xxhong 发表于 2017-9-6 17:54:47 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 6 12806
1.    Mariadb设置1)   登陆数据库
使用mysql登陆数据库,如下所示:
  
[root@controller  ~]# mysql -u root -p
  
Enter password:
  
Welcome to the  MariaDB monitor.  Commands end with ;  or \g.
  
Your MariaDB  connection id is 10
  
Server version:  10.1.20-MariaDB MariaDB Server
  
  
Copyright (c)  2000, 2016, Oracle, MariaDB Corporation Ab and others.
  
  
Type 'help;' or  '\h' for help. Type '\c' to clear the current input statement.
  
2)   创建数据库实例
在mariadb中创建库实例 ,名为keystone的数据库库,如下所示:
  
MariaDB  [(none)]> CREATE DATABASE keystone;
  
Query OK, 1 row  affected (0.00 sec)
  
3)   创建用户
建用户keystone,密码zhitu2017,然后退出,如下所示:
  
MariaDB  [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost'  IDENTIFIED BY 'zhitu2017';
  
Query OK, 0 rows  affected (0.09 sec)
  
  
MariaDB [(none)]>  GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY  'zhitu2017';
  
Query OK, 0 rows  affected (0.00 sec)
  
MariaDB  [(none)]> exit;
  
Bye
  
2.    安装openstack-keystone1)   生成随机数
生成随机数作为管理用户Token,如下所示:
  
[root@controller  ~]# openssl rand -hex 10
  
4f0b0f958218b53ec9b1
  
2)   安装openstack-keystone
使用yum安装,如下所示:
  
[root@controller  ~]# yum install openstack-keystone httpd mod_wsgi -y
  
3)   更改keystone.conf配置
编辑keystone.conf文件,如下所示:
  
[root@controller  ~]# vi /etc/keystone/keystone.conf
  
修改内容如下:
  
[DEFAULT]
  
admin_token =  4f0b0f958218b53ec9b1
  
[database]
  
connection =  mysql+pymysql://keystone:zhitu2017@controller/keystone
  
[token]
  
provider =  fernet
  
4)   同步配置到数据库
  
[root@controller  ~]# su -s /bin/sh -c \
  
>  "keystone-manage db_sync" keystone
  
初始化
  
[root@controller  ~]# keystone-manage fernet_setup \
  
>  --keystone-user keystone \
  
>  --keystone-group keystone
  
3.    配置apache1)   更改httpd.conf配置
编辑httpd.conf,如下所示:
  
[root@controller  ~]# vi /etc/httpd/conf/httpd.conf
  
设置ServerName,如下所示 :
  
ServerName  controller
  
2)   更改wsgi-keystone.conf配置
编辑wsgi-keystone.conf,如下所示:
  
[root@controller  ~]# vi /etc/httpd/conf.d/wsgi-keystone.conf
  
编辑内容如下:
  
Listen 5000
  
Listen 35357
  
<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
  
     ErrorLogFormat "%{cu}t %M"
  
     ErrorLog /var/log/httpd/keystone-error.log
  
     CustomLog /var/log/httpd/keystone-access.log combined
  
  
     <Directory /usr/bin>
  
        Require all granted
  
     </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
  
     ErrorLogFormat "%{cu}t %M"
  
     ErrorLog /var/log/httpd/keystone-error.log
  
     CustomLog /var/log/httpd/keystone-access.log combined
  
  
     <Directory /usr/bin>
  
        Require all granted
  
     </Directory>
  
</VirtualHost>
  
3)   启动httpd服务
启动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
  
4.    创建服务1)   配置临时环境变量
配置环境变量OS_TOKEN、OS_URL、OS_IDENTITY_API_VERSION,如下所示:
  
[root@controller  ~]# export OS_TOKEN=4f0b0f958218b53ec9b1
  
[root@controller  ~]# export OS_URL=http://controller:35357/v3
  
[root@controller  ~]# export OS_IDENTITY_API_VERSION=3
  
2)   创建服务
创建keystone服务,如下所示:
  
[root@controller  ~]# openstack service create  --name  keystone --description "OpenStack Identity" identity
  
+-------------+----------------------------------+
  
| Field       | Value                            |
  
+-------------+----------------------------------+
  
| description | OpenStack  Identity               |
  
| enabled     | True                              |
  
| id          | 8c0682b22b47478b82c7d55293b1476e  |
  
| name        | keystone                         |
  
| type        | identity                         |
  
+-------------+----------------------------------+
  
3)   创建服务端点
创建public、internal、admin服务端点,如下所示:
  
[root@controller  ~]# openstack endpoint create --region RegionOne identity public  http://controller:5000/v3
  
+--------------+----------------------------------+
  
| Field        | Value                            |
  
+--------------+----------------------------------+
  
| enabled      | True                             |
  
| id           | b4dec4702b6849bb999d6f9d65d64d2e  |
  
| interface    | public                           |
  
| region       | RegionOne                        |
  
| region_id    | RegionOne                        |
  
| service_id   | 8c0682b22b47478b82c7d55293b1476e |
  
| service_name | keystone                         |
  
| service_type | identity                         |
  
| url          | http://controller:5000/v3        |
  
+--------------+----------------------------------+
  
[root@controller  ~]# openstack endpoint create --region RegionOne identity internal  http://controller:5000/v3
  
+--------------+----------------------------------+
  
| Field        | Value                            |
  
+--------------+----------------------------------+
  
| enabled      | True                             |
  
| id           | 4b477477580f4087a0082a848a672c04  |
  
| interface    | internal                         |
  
| region       | RegionOne                        |
  
| region_id    | RegionOne                        |
  
| service_id   | 8c0682b22b47478b82c7d55293b1476e |
  
| service_name | keystone                         |
  
| service_type | identity                         |
  
| url          | http://controller:5000/v3        |
  
+--------------+----------------------------------+
  
[root@controller  ~]# openstack endpoint create --region RegionOne identity admin  http://controller:35357/v3
  
+--------------+----------------------------------+
  
| Field        | Value                            |
  
+--------------+----------------------------------+
  
| enabled      | True                             |
  
| id           | 9bb7c8527c7147fe9eb2af866b7de15d  |
  
| interface    | admin                            |
  
| region       | RegionOne                        |
  
| region_id    | RegionOne                        |
  
| service_id   | 8c0682b22b47478b82c7d55293b1476e |
  
| service_name | keystone                         |
  
| service_type | identity                         |
  
| url          | http://controller:35357/v3       |
  
+--------------+----------------------------------+
  
4)   创建域名default
创建域名default,如下所示:
  
[root@controller  ~]# openstack domain create --description "Default Domain" default
  
+-------------+----------------------------------+
  
| Field       | Value                            |
  
+-------------+----------------------------------+
  
| description | Default Domain                   |
  
| enabled     | True                             |
  
| id          | c75d59a59e844792abf6891e51ce687c  |
  
| name        | default                          |
  
+-------------+----------------------------------+
  
5)   创建项目admin及service
基于域default,创建项目admin及service,如下所示:
  
[root@controller  ~]# openstack project create --domain default --description "Admin  Project" admin
  
+-------------+----------------------------------+
  
| Field       | Value                            |
  
+-------------+----------------------------------+
  
| description | Admin Project                    |
  
| domain_id   | c75d59a59e844792abf6891e51ce687c |
  
| enabled     | True                             |
  
| id          | faec61286eb94fe5b25d7026e357ae1e  |
  
| is_domain   | False                            |
  
| name        | admin                            |
  
| parent_id   | c75d59a59e844792abf6891e51ce687c |
  
+-------------+----------------------------------+
  
[root@controller  ~]# openstack project create --domain default --description "Service  Project" service
  
+-------------+----------------------------------+
  
| Field       | Value                            |
  
+-------------+----------------------------------+
  
| description | Service Project                  |
  
| domain_id   | c75d59a59e844792abf6891e51ce687c |
  
| enabled     | True                             |
  
| id          | 33eb6980dfed4e7f98c33715cedd127a  |
  
| is_domain   | False                            |
  
| name        | service                          |
  
| parent_id   | c75d59a59e844792abf6891e51ce687c |
  
+-------------+----------------------------------+
  
6)   创建用户admin
基于域default,创建用户admin,密码zhitu2017,如下所示:
  
[root@controller  ~]# openstack user create --domain default --password-prompt admin
  
User Password:
  
Repeat User  Password:
  
+---------------------+----------------------------------+
  
| Field               | Value                            |
  
+---------------------+----------------------------------+
  
| domain_id           | c75d59a59e844792abf6891e51ce687c  |
  
| enabled             | True                             |
  
| id                  | 4d83124e21d544d897486ae84d829d19  |
  
| name                | admin                            |
  
| options             | {}                               |
  
| password_expires_at | None                             |
  
+---------------------+----------------------------------+
  
7)    创建角色admin
创建角色admin,关联角色到项目及用户,如下所示:
  
[root@controller  ~]# openstack role create admin
  
+-----------+----------------------------------+
  
| Field     | Value                            |
  
+-----------+----------------------------------+
  
| domain_id | None                             |
  
| id        | d57dcabdb8fb4f9c9fe6a532b2a1f877 |
  
| name      | admin                            |
  
+-----------+----------------------------------+
  
[root@controller  ~]# openstack role add --project admin --user admin admin
  
5.    验证1)    更改keystone-paste.ini配置
编辑keystone-paste.ini,去除临时认证,基于安全考虑(admin_token_auth删除,其它不动),如下所示:
  
[root@controller  ~]# vi /etc/keystone/keystone-paste.ini
  
编辑内容如下:
  
[pipeline:public_api]
  
pipeline = cors  sizelimit url_normalize request_id admin_token_auth build_auth_context …
  
[pipeline:admin_api]
  
pipeline = cors  sizelimit url_normalize request_id admin_token_auth build_auth_context …
  
[pipeline:api_v3]
  
pipeline = cors  sizelimit url_normalize request_id admin_token_auth build_auth_context …
  
2)   验证
去除环境变量,如下所示:
  
[root@controller  ~]# unset OS_TOKEN OS_URL
  
请求验证,输入密码后(zhitu2017),得到期望结果,如下所示:
  
[root@controller  ~]# openstack --os-auth-url http://controller:35357/v3 \
  
>  --os-project-domain-name default --os-user-domain-name default \
  
>  --os-project-name admin --os-username admin token issue
  
Password:
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
| Field      | Value                                                                                                                 |
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
| expires    | 2017-04-11T07:09:32+0000                                                                                              |
  
| id         |  gAAAAABY7HMgv3NApsg3tkXzOulquh8zmsg1MPkJmMaFlOAre3zRthCCUxkg1hlDxRDPaINZ2MzmvRE7envgyAzPSkhtNbjkbiqvD0g22_oEy5qKlmT_  |
  
|            |  21lR2UpFukqihQuL4sbsJTppGnwCSIpdEqpAna-5D4USVFgt9m3wrWSmQNVjtw-4vuo                                                   |
  
| project_id |  faec61286eb94fe5b25d7026e357ae1e                                                                                      |
  
| user_id    | 4d83124e21d544d897486ae84d829d19                                                                                     |
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
创建脚本,如下所示:
  
[root@controller  ~]# vi ~/admin-openrc
  
增加以下内容
  
export  OS_PROJECT_DOMAIN_NAME=default
  
export  OS_USER_DOMAIN_NAME=default
  
export  OS_PROJECT_NAME=admin
  
export  OS_USERNAME=admin
  
export  OS_PASSWORD=zhitu2017
  
export  OS_AUTH_URL=http://controller:35357/v3
  
export  OS_IDENTITY_API_VERSION=3
  
export OS_IMAGE_API_VERSION=2
  
验证结果:未出错,并显示提示,如失效日期等。
下次如果想用此环境变量,可以先执行: . ~/admin-openrc
  
[root@controller  ~]# . ~/admin-openrc
  
[root@controller  ~]# openstack token issue
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
| Field      | Value                                                                                                                 |
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
| expires    | 2017-04-11T07:20:38+0000                                                                                              |
  
| id         |  gAAAAABY7HXAUxV6aWkVlDDybzuKumqCwhCiN2oAe1XHh4ZnrUXzpiM-korb8p3gUeLP5JrFf4acSvi3Sd_8us6rYIAXBkMV5A2KYKL5BnhDLQ28PULi  |
  
|            |  cPZ0mRfLFymWsxRuGDEdjTQGdMqyJjxDq20eS24s1rM208bo0zXVDRD6H8c_pm7FoHk                                                  |
  
| project_id |  faec61286eb94fe5b25d7026e357ae1e                                                                                      |
  
| user_id    | 4d83124e21d544d897486ae84d829d19                                                                                     |
  
+------------+----------------------------------------------------------------------------------------------------------------------+
  
接下来问题:
重启服务器后
1)   登陆数据库使用mysql登陆数据库,如下所示:
  [root@controller  ~]# mysql -u root -p  Enter password:  Welcome to the  MariaDB monitor.  Commands end with ;  or \g.  Your MariaDB  connection id is 10  Server version:  10.1.20-MariaDB MariaDB Server     Copyright (c)  2000, 2016, Oracle, MariaDB Corporation Ab and others.     Type 'help;' or  '\h' for help. Type '\c' to clear the current input statement.  
2)   创建数据库实例在mariadb中创建库实例 ,名为glance的数据库库,如下所示:
  MariaDB  [(none)]> CREATE DATABASE glance;  Query OK, 1 row  affected (0.11 sec)  
3)   创建用户建用户glance,密码zhitu2017,然后退出,如下所示:
  MariaDB  [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost'  IDENTIFIED BY 'zhitu2017';  Query OK, 0 rows  affected (0.14 sec)     MariaDB  [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY  'zhitu2017';  Query OK, 0 rows  affected (0.00 sec)     MariaDB  [(none)]> exit;  Bye  
1.    创建服务1)   配置临时环境变量利用脚本设置环境变量,如下所示:
  [root@controller  ~]# . ~/admin-openrc  
2)    创建用户glance创建用户glance,基于域default,并交admin角色关联用户glance,项目service  密码:zhitu2017,如下所示:
[root@controller~]# openstack user create --domain default --password-prompt glance      Discovering versions from the identity service failed when creating the password plugin. Attempting to determine version from URL.
        Internal Server Error (HTTP 500)
求帮忙解决

已有(6)人评论

跳转到指定楼层
starrycheng 发表于 2017-9-6 19:22:18
[mw_shl_code=bash,true]openstack user create --password-prompt glance[/mw_shl_code]
用这个命令试试
回复

使用道具 举报

xxhong 发表于 2017-9-6 19:26:57
starrycheng 发表于 2017-9-6 19:22
[mw_shl_code=bash,true]openstack user create --password-prompt glance[/mw_shl_code]
用这个命令试试
...

但是我觉得可能哪儿配置出了问题,不是命令问题
回复

使用道具 举报

feng32 发表于 2017-9-7 09:34:41
看看LOG里有什么错
回复

使用道具 举报

xxhong 发表于 2017-9-7 09:39:10
本帖最后由 xxhong 于 2017-9-7 09:41 编辑
feng32 发表于 2017-9-7 09:34
看看LOG里有什么错
[root@controller log]# ls
anaconda       cron-20170815  grubby_prune_debug  maillog-20170907   ppp              spooler           yum.log
audit          cron-20170830  httpd               mariadb            rabbitmq         spooler-20170815
boot.log       cron-20170907  keystone            messages           rhsm             spooler-20170830
btmp           dmesg          lastlog             messages-20170815  secure           spooler-20170907
btmp-20170901  dmesg.old      maillog             messages-20170830  secure-20170815  tallylog
chrony         firewalld      maillog-20170815    messages-20170907  secure-20170830  tuned
cron           grubby         maillog-20170830    mongodb            secure-20170907  wtmp
log里面是这样的,还请大神帮忙看看
回复

使用道具 举报

zjnbb 发表于 2017-10-31 12:56:28
您好,请问解决此问题了么?再keystone里面有对应的日志。我在后面的操作中遇见了类似的问题:openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
HTTPInternalServerError (HTTP 500)
回复

使用道具 举报

yushulinfeng 发表于 2017-11-3 12:18:58
贴出下面日志看看
tail -f /var/log/httpd/keystone-error.log

tail -f /var/log/httpd/error_log

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条