bilelmsekni / OpenStack-Grizzly-Install-Guide

A full install guide for OpenStack Grizzly
352 stars 218 forks source link

Keystone + mySQL connection problems #73

Closed aosi87 closed 11 years ago

aosi87 commented 11 years ago

I was following the OpenStack-Grizzly-Install-Guide and i found some problems doing the connection to the mysql:

How i got here:

3. Keystone

Start by the keystone packages:

apt-get install -y keystone

Verify your keystone is running:

service keystone status

Create a new MySQL database for keystone:

mysql -u root -p CREATE DATABASE keystone; GRANT ALL ON keystone.* TO 'keystoneUser'@'%' IDENTIFIED BY 'keystonePass'; quit;

Adapt the connection attribute in the /etc/keystone/keystone.conf to the new database:

connection = mysql://keystoneUser:keystonePass@10.10.100.51/keystone

Restart the identity service then synchronize the database:

service keystone restart keystone-manage db_sync

after using the sync command i got a tracktrace from python telling me that i cant do a connection with 'root'@'localhost' well this is the terminal log:

root@cloud:~# keystone-manage db_sync Traceback (most recent call last): File "/usr/bin/keystone-manage", line 28, in cli.main(argv=sys.argv, config_files=config_files) File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 175, in main CONF.command.cmd_class.main() File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 54, in main driver.db_sync() File "/usr/lib/python2.7/dist-packages/keystone/identity/backends/sql.py", line 156, in db_sync migration.db_sync() File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 49, in db_sync current_version = db_version() File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 63, in db_version return db_version_control(0) File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 68, in db_version_control versioning_api.version_control(CONF.sql.connection, repo_path, version) File "", line 2, in version_control File "/usr/lib/python2.7/dist-packages/migrate/versioning/util/init.py", line 159, in with_engine return f(_a, *_kw) File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 250, in version_control ControlledSchema.create(engine, repository, version) File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 139, in create table = cls._create_table_version(engine, repository, version) File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 180, in _create_table_version if not table.exists(): File "/usr/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 578, in exists self.name, schema=self.schema) File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2423, in run_callable conn = self.contextual_connect() File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2489, in contextual_connect self.pool.connect(), File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 236, in connect return _ConnectionFairy(self).checkout() File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 401, in init rec = self._connection_record = pool._do_get() File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 746, in _do_get con = self._create_connection() File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 189, in _create_connection return _ConnectionRecord(self) File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 282, in init self.connection = self.connect() File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 344, in connect connection = self.pool._creator() File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 80, in connect return dialect.connect(_cargs, _cparams) File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 281, in connect return self.dbapi.connect(_cargs, _cparams) File "/usr/lib/python2.7/dist-packages/MySQLdb/__init.py", line 81, in Connect return Connection(_args, _kwargs) File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in init super(Connection, self).init(_args, _kwargs2) sqlalchemy.exc.OperationalError: (OperationalError) (1045, "Access denied for user 'root'@'localhost' (using password: NO)") None None

And this is my user table in MySQL

mysql> SELECT user, host, password FROM mysql.user -> ; +------------------+--------------+-------------------------------------------+ | user | host | password | +------------------+--------------+-------------------------------------------+ | root | localhost | E3667A513AA157512F78FC507DB717552F6F795D | | root | fmat-cloud | E3667A513AA157512F78FC507DB717552F6F795D | | root | 127.0.0.1 | E3667A513AA157512F78FC507DB717552F6F795D | | root | ::1 | E3667A513AA157512F78FC507DB717552F6F795D | | | localhost | | | | fmat-cloud | | | debian-sys-maint | localhost | FEE4A81C373BC4141F7F24A26315FEB4F71531AE | | keystoneUSER | 10.10.100.51 | 0099864D549EE2F75140CF9D4E855E69526E6134 | | keystoneUSER | % | 0099864D549EE2F75140CF9D4E855E69526E6134 | | keystoneUSER | localhost | 0099864D549EE2F75140CF9D4E855E69526E6134 | | keystoneUSER | 127.0.0.1 | 0099864D549EE2F75140CF9D4E855E69526E6134 | | keystoneUSER | fmat-cloud | 0099864D549EE2F75140CF9D4E855E69526E6134 | +------------------+--------------+-------------------------------------------+ 12 rows in set (0.00 sec)

as u can see i already try all kind of connections, one by one, and some of them like this, this is cause the way MySQL use the match, in this '%' contains all the other options, but the python scripts still trys to use root@localhost, so i was wondering if ensure that the proper service token is used in the keystone.conf file should one way to solve this.

The version programs:

root@fmat-cloud:~# mysql --version mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline 6.2 root@fmat-cloud:~# keystone --version Unknown, couldn't find versioninfo file at /usr/lib/python2.7/dist- packages/keystoneclient/versioninfo root@fmat-cloud:~# keystone-manage --version 2013.1.1 root@fmat-cloud:~# uname -a Linux fmat-cloud 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

so if anyone can helpme here =D it will be thankfull

UPDATE #1 .-

One way to solve this its add a new user:

mysql> GRANT ALL ON keystone.* TO 'root'@'%' IDENTIFIED BY 'toor'; mysql> SELECT user, host, password FROM mysql.user -> ; +------------------+--------------+-------------------------------------------+ | user | host | password | +------------------+--------------+-------------------------------------------+ | root | localhost | E3667A513AA157512F78FC507DB717552F6F795D | | root | fmat-cloud | E3667A513AA157512F78FC507DB717552F6F795D | | root | 127.0.0.1 | E3667A513AA157512F78FC507DB717552F6F795D | | root | ::1 | E3667A513AA157512F78FC507DB717552F6F795D | | | localhost | | | | fmat-cloud | | | debian-sys-maint | localhost | FEE4A81C373BC4141F7F24A26315FEB4F71531AE | | root | % | E3667A513AA157512F78FC507DB717552F6F795D | +------------------+--------------+-------------------------------------------+ 8 rows in set (0.00 sec)

now in /etc/keystone/keystone.conf add the connection:

[sql] connection = mysql://root:toor@localhost/keystone?charset=utf8

and in this time i use "admin_token = toor" this option its commented. everything works now =D so i dunno if its the way python scripts use sql, i guess it use the local user (root) and localhost, and its not taking the keystone.conf options to create a socket.

Cheers. =D