1 keystone-manage db_sync 这个已经是最全面的了。

Solution MySQL ERROR 1045 Access denied for 'user'@'localhost' - breaks OpenStack

# mysql -u root -p
. . .
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
. . .

mysql> SELECT user,host,password FROM mysql.user;
+------------------+------------+-------------------------+
| user             | host       | password                |
+------------------+------------+-------------------------+
| root             | localhost  | *77B48D6366D102139D3719 |
| root             | mysqltests | *77B48D6366D102139D3719 |
| root             | 127.0.0.1  | *77B48D6366D102139D3719 |
| root             | ::1        | *77B48D6366D102139D3719 |
|                  | localhost  |                         |
|                  | mysqltests |                         |
| debian-sys-maint | localhost  | *04D30B480932109EFD77E1 |
+------------------+------------+-------------------------+
7 rows in set (0.00 sec)

mysql> show grants;
+---------------------------------------------------------+
| Grants for root@localhost                               |
+---------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'       |

|       IDENTIFIED BY PASSWORD '*77B48D6366D102139D3719'  |

|       WITH GRANT OPTION                                 |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT   |

|                                       OPTION            |
+---------------------------------------------------------+
2 rows in set (0.00 sec)

The mysql.user Table

At first glance, we have 2 users (root and debian-sys-maint). That's wrong, because mysql's "user" is a 'user'@'host' pair association. So we have 7 in total: 'root' is defined (with the same password) for any combination of 'localhost' (the first 4 lines), then we have 2 strange lines with empty username, and finally the debian backdoor 'debian-sys-maint'.

The grants

The 'show grants' above shows only grants for 'root'. But if we run the next staement, we see what access is provided to any user connecting from 'localhost':

mysql> show grants for ''@'localhost';
+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+

Which (indirectly) explains why running this command (as Linux user 'ori') doesn't require a password:

[16:16:57]ori@mysqltests[~]

$ mysqladmin ping
mysqld is alive

Where this one fails:

[16:14:59]ori@mysqltests[~]
$ mysqladmin -uroot ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Honestly, in the beginning i thought there's some balck magic here related to the user ('ori', in this case) defined during ubuntu installation, or a special Linux group memebership, or some apparmor profile or god-knows what else.

But there's no black magic after all, and it's all inside mysql:

The first thing to bear in mind is that the empty USER field '' is a wildcard, same as '%' for host.

The second is that mysql prefers the explicit match over the wildcard. For example, user 'root' can match either [1] the explicit 'root'@localhost' row or [2] the wildcard ''@'localhost' row. Since there's an explicit entry for [1] in the table mysql.user, it'll be used. This in turn requires a password so when i try to connect as 'root' without a password i'm rejected.

When i connect as 'ori' - which isn't even a mysql user, there's only one possible match - ''@'localhost' and this line in the table doesn't have a password.

This nicely explains why the above mysqladmin command works for 'ori' and fails for 'root'.

To sum it up: mysql controls access (or connection request) based on the USER table. Which user, from which host and whether a password is required.

Once connected, the GRANTS determine what the user is allowed to do. When connected as 'ori' i'm limited to "USAGE" (e.g. check if server is up, what version and the like of inoffensive commands).

So far so good - but why 'glance'@'localhost' is denied access on the OpenStack controller?

When the static IP address of the conroller wasn't in /etc/hosts (or after it was commented-out), there was only one match for 'glance' = 'glance'@'%'

This, in turn, comes from the connection string (in /etc/glance/glance-registry.conf) which is:

sql_connection = mysql://glance:openstack@10.0.0.40/glance

It specifies user, password and host.

The line I've added for 10.0.0.40 in /etc/hosts, told mysql (indirectly) that host 'ostk-controller1' is actually 'localhsot'. From now on, there are 2 possible matches for 'glance', and the one picked by mysql is ''@'localhost'. This row, however, doesn't require a password - which the sql_connection string provide.

And that's why all OpenStack services couldn't connect to mysql.

Check against the USER table below, this was taken from ostk-controller (not the test VM):

mysql> SELECT user,host,password FROM mysql.user;
+------------------+------------------+-------------------------+
| user | host             | password |

+------------------+------------------+-------------------------+
| root | localhost        | *3A4A03AC22526F6B591010 |

| root | ostk-controller1 | *3A4A03AC22526F6B591010 |

| root | 127.0.0.1        | *3A4A03AC22526F6B591010 |

| root             | ::1              | *3A4A03AC22526F6B591010 |
|                  | localhost        | |

|                  | ostk-controller1 |                         |
| debian-sys-maint | localhost        | *F714636CE8A7836873F7C8 |
| nova             | %                | *3A4A03AC22526F6B591010 |
| glance           | %                | *3A4A03AC22526F6B591010 |
| keystone         | %                | *3A4A03AC22526F6B591010 |
+------------------+------------------+-------------------------+
10 rows in set (0.00 sec)

Solution for ERROR 1045

After understanding why, let's improve on the poor workaround.

I'd like to credit an answer by Paul DuBois from 2004 for this solution(it's worth noting that the subject was "Re: Any way to make anyhost '%' include localhost").

Borrowing from there, here's the remedy:

in MySQL:

mysql -uroot -p

DELETE FROM mysql.user WHERE Host='localhost' AND User='';

DELETE FROM mysql.user WHERE Host='ostk-controller1' AND User='';

FLUSH PRIVILEGES;

in /etc/hosts:

Replace the line

127.0.1.1ostk-controller1

by this one:

10.0.0.40 ostk-controller1

Quoting from Debian's reference manual:

For a system with a permanent IP address, that permanent IP address should be used here instead of 127.0.1.1

finally restart networking and mysqld - or simply reboot.

A Second Solution

Months after going through the above study, i found out why some OpenStack installations don't hit this issue; The keystone installation instructions (from Ubuntu, for Essex, can be found here) create each OSTK user in mysql twice, as in:

mysql> CREATE DATABASE keystone;
CREATE USER ‘keystone’@’localhost’ IDENTIFIED BY ‘Secret_pass’;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone’@’localhost’
WITH GRANT OPTION;
CREATE USER ‘keystone’@’%’ IDENTIFIED BY ‘Secret_pass’;
GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@’%’
IDENTIFIED BY ‘Secret_pass’;
FLUSH PRIVILEGES;

openstack 遇到的问题一相关推荐

  1. [网摘学习]在Ubuntu上安装和配置OpenStack Nova之二

    再收藏一份Openstack的文章,这两天的操作与此相同.但其中出现的问题还需要查找原因.待个人继续学习研究. 原文参考:http://www.linuxde.net/2011/11/1599.htm ...

  2. 末学者笔记--openstack共享组件:rabbitmq(3)

    openstack共享组件:消息队列rabbitmq 一.MQ 全称为 Message Queue, 消息队列( MQ )                       是一种应用程序对应用程序的通信方 ...

  3. OpenStack之虚拟机热迁移

    这里的环境是centos7版本,openstack K版 1.在各个计算节点设置权限 chmod 755 /var/lib/nova/instances 2.修改各个节点的nova.conf(/etc ...

  4. linux镜像修改密码,OpenStack 镜像修改密码方案

    现在各大linux厂商,其实已经有专门给openStack提供的镜像,不过国内的朋友,不太习惯老外做镜像的方式,经常问密码是多少.本博客提供几种修改密码方案,仅供参考. 前言 对OpenStack云主 ...

  5. devstack —— 单机部署 OpenStack 体验

    2019独角兽企业重金招聘Python工程师标准>>> devstack 是一个用来快速部署 OpenStack 的脚本. 使用非常简单,执行 ./stack.sh 即可,但是在安装 ...

  6. 《OpenStack实战》——第1章 介绍OpenStack 1.1OpenStack是什么

    本节书摘来自异步社区<OpenStack实战>一书中的第1章,第1.1节,作者: [美]V. K. Cody Bumgardner(V. K. 科迪•布姆加德纳)著,更多章节内容可以访问云 ...

  7. CHUCK手把手带你搞定OPENSTACK

    以下是原文链接:http://blog.oldboyedu.com/openstack/ 转载于:https://blog.51cto.com/bovin/1858198

  8. Openstack组件实现原理 — Keystone认证功能

    前言 Keystone实现始终围绕着Keystone所实现的功能来展开,所以在理解其实现之前,建议大家尝试通过安装Keystone这一个过程来感受Keystone在Openstack架构中所充当的角色 ...

  9. Restore Volume 操作 - 每天5分钟玩转 OpenStack(60)

    前面我们 backup 了 voluem,今天我们将讨论如何 restore volume. restore 的过程其实很简单,两步走: 在存储节点上创建一个空白 volume. 将 backup 的 ...

  10. 《理解 OpenStack + Ceph》---来自-[爱.知识]-推荐

    企业IT技术分享(2016-06-29) 来自(QQ群:企业私有云平台实战 454544014-推荐)! 理解 OpenStack + Ceph (1):Ceph + OpenStack 集群部署和配 ...

最新文章

  1. 强强联合!Papers with Code携手arXiv,上传论文、提交代码一步到位
  2. ***必备兵器与技能
  3. python调用通达信函数_python获取通达信基本数据源码
  4. 分类素材(part5)--大话Python机器学习(中)
  5. web开发移动端准备工作
  6. Linux的watch命令 -- 实时监测命令的运行结果
  7. 流程DEMO-费用报销
  8. visionpro图片读取、写入
  9. windos下编译ffmpeg生成dll、lib库(开启265)
  10. S2D_基于深度学习的视觉稠密建图和定位_相关文章
  11. git bash提交代码步骤
  12. java 员工管理系统
  13. ssdp协议 upnp_SSDP协议编程 upnp设备查找方法
  14. Unity获取安卓手机运营商,电量,wifi信号强度,本地Toast,获取已安装apk,调用第三方应用,强制自动重启本应用...
  15. Let's encrypt 通配域名(二级, 三级)
  16. 51单片机 外部中断
  17. 高德地图接口申请 地图接口集成 高德地图API文档
  18. pythonfor循环文件写入失败_Python:使用for循环写入文件
  19. react+antd搭建后台管理系统
  20. 51单片机 普中V2 数字时钟 电子时钟 万年历 DS1302 LCD1602 AT24C02

热门文章

  1. Word2016如何取消宏已被禁用的提示
  2. GT Transceiver中的重要时钟及其关系(5)QPLL的工作原理介绍
  3. Matlab画图时的线型、标记以及颜色简记
  4. 高速串行总线系列(1)8B/10B编码技术
  5. 【 FPGA/IC 】addsub 的实现
  6. 如何搭建基于容器的工业互联网PaaS平台
  7. 可以把阿里云上面的一些介绍和视频都看看
  8. iOS开发-关于自定义控件很值得一看的文章(一)
  9. Zabbix,Nagios,OneAPM Servers 安装部署
  10. 实现JDK没有提供的AtomicFloat