Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Ranger configuration: ERROR: Unable to connect to the DB

Ranger configuration: ERROR: Unable to connect to the DB

Contributor

Ranger configuration failing with :

stdout:

DB connection check started. WARNING: File /var/lib/ambari-agent/cache/DBConnectionVerification.jar already exists, assuming it was downloaded before WARNING: File /var/lib/ambari-agent/cache/mysql-jdbc-driver.jar already exists, assuming it was downloaded before 2017-01-15 16:35:10,695 - call['/usr/jdk64/jdk1.8.0_40/bin/java -cp /var/lib/ambari-agent/cache/DBConnectionVerification.jar:/var/lib/ambari-agent/cache/mysql-jdbc-driver.jar -Djava.library.path=/var/lib/ambari-agent/cache org.apache.ambari.server.DBConnectionVerification "jdbc:mysql://ambari.localdomain/ranger" root [PROTECTED] com.mysql.jdbc.Driver'] {} 2017-01-15 16:35:11,408 - call returned (1, "ERROR: Unable to connect to the DB. Please check DB connection properties.\njava.sql.SQLException: Access denied for user 'root'@'datanode3.localdomain' (using password: YES)")

structured_out:

ERROR: Unable to connect to the DB. Please check DB connection properties. java.sql.SQLException: Access denied for user 'root'@'datanode3.localdomain' (using password: YES)

Ranger Installation Steps:

Ranger Admin Server: datanode3.localdomain

Ranger Usersync: datanode3.localdomain

Database: mysql

Database Server : ambari.localdomain

create database for ranger in mysql

mysql> create database ranger;

Query OK, 1 row affected (0.01 sec)

mysql> create user ranger identified by '<password>';

Query OK, 0 rows affected (0.02 sec)

mysql> grant all on ranger.* to ranger;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

[root@ambari ~]# mysql -u ranger -p

Enter password:

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

|ranger |

+--------------------+

2 rows in set (0.00 sec)

[root@ambari ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

Using python /usr/bin/python2.6

Setup ambari-server

Copying /usr/share/java/mysql-connector-java.jar to /var/lib/ambari-server/resources

JDBC driver was successfully initialized.

Ambari Server 'setup' completed successfully.

Please advise.

Thank you,

Sachin A

5 REPLIES 5
Highlighted

Re: Ranger configuration: ERROR: Unable to connect to the DB

Rising Star

Hi @Sachin Ambardekar, could you please let us know if the password for root user is set in MYSQL, since till mysql 5.6, there is no default password for root user

Set the password and then try to setup Ranger :

MySQL 5.7.5 and earlier: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass'); MySQL 5.7.6 and later: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

Re: Ranger configuration: ERROR: Unable to connect to the DB

Contributor

@Sachin Ambardekar

1. Login to MySQL as root or admin account. 

From the command line run:
#mysql -u root

2. Check user table to see if user exists in MySQL. While in MySQL shell run:
mysql> use mysql;
mysql> select User,Host,Password from user where user ='root';

3. make sure 'root'@'datanode3.localdomain' combination exists in your DB.

- To create user run following commands:

create user 'root'@'datanode3.localdomain' identified by 'hadoop'; 
grant all privileges on *.* to 'root'@'datanode3.localdomain'; 
flush privileges;

- If user exist and you need to add grants from the command line run:
grant all privileges on *.* to 'root'@'datanode3.localdomain';
flush privileges;  

Re: Ranger configuration: ERROR: Unable to connect to the DB

Contributor

Below is the error I am getting while login as root

[root@ambari etc]# mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Where as if I use -p with login and then I provide the password, I am able to login.

[root@ambari etc]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 245 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

Please advise.

Thank you,

Sachin A

Re: Ranger configuration: ERROR: Unable to connect to the DB

Contributor
@Sachin Ambardekar

Can you run "select User,Host,Passwordfrom user where user ='root';" when you log in after using "mysql -u root -p"

?

Re: Ranger configuration: ERROR: Unable to connect to the DB

Contributor

As per the previous post performed below steps and retried the ranger installation :

mysql> use mysql;

mysql> select User,Host,Password from user where user ='root';

+------+-----------+-------------------------------------------+

| User | Host | Password |

+------+-----------+-------------------------------------------+

| root | localhost | *3C636F43ED0ECE3F2C179E89F83D78F3642172BE |

| root | 127.0.0.1 | *3C636F43ED0ECE3F2C179E89F83D78F3642172BE

| +------+-----------+-------------------------------------------+

2 rows in set (0.00 sec)

mysql> create user 'root'@'datanode3.localdomain' identified by '<password>';

Query OK, 0 rows affected (0.00 sec)

mysql> select User,Host,Password from user where user ='root';

+------+-----------------------+-------------------------------------------+

| User | Host | Password |

+------+-----------------------+-------------------------------------------+

| root | localhost | *3C636F43ED0ECE3F2C179E89F83D78F3642172BE |

| root | 127.0.0.1 | *3C636F43ED0ECE3F2C179E89F83D78F3642172BE |

| root | datanode3.localdomain | *3C636F43ED0ECE3F2C179E89F83D78F3642172BE |

+------+-----------------------+-------------------------------------------+

3 rows in set (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'datanode3.localdomain';

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Ranger Error:

stdout:

DB connection check started. WARNING: File /var/lib/ambari-agent/cache/DBConnectionVerification.jar already exists, assuming it was downloaded before WARNING: File /var/lib/ambari-agent/cache/mysql-jdbc-driver.jar already exists, assuming it was downloaded before 2017-01-16 10:24:10,065 - call['/usr/jdk64/jdk1.8.0_40/bin/java -cp /var/lib/ambari-agent/cache/DBConnectionVerification.jar:/var/lib/ambari-agent/cache/mysql-jdbc-driver.jar -Djava.library.path=/var/lib/ambari-agent/cache org.apache.ambari.server.DBConnectionVerification "jdbc:mysql://datanode3.localdomain/rangerdb" root [PROTECTED] com.mysql.jdbc.Driver'] {} 2017-01-16 10:24:10,673 - call returned (1, 'ERROR: Unable to connect to the DB. Please check DB connection properties.\ncom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.')

structured_out: ERROR: Unable to connect to the DB. Please check DB connection properties. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Please advise.

Thank you,

Sachin A