Support Questions

Find answers, ask questions, and share your expertise

how to resolve Can't establish db connection.. Exiting.. when ranger service add on my machin

avatar
Explorer
Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py", line 225, in <module>
    RangerAdmin().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 329, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py", line 97, in start
    self.configure(env, upgrade_type=upgrade_type, setup_db=params.stack_supports_ranger_setup_db_on_start)
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 119, in locking_configure
    original_configure(obj, *args, **kw)
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py", line 139, in configure
    setup_ranger_db()
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py", line 258, in setup_ranger_db
    user=params.unix_user,
  File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 166, in __init__
    self.env.run()
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 160, in run
    self.run_action(resource, action)
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 124, in run_action
    provider_action()
  File "/usr/lib/python2.6/site-packages/resource_management/core/providers/system.py", line 262, in action_run
    tries=self.resource.tries, try_sleep=self.resource.try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 72, in inner
    result = function(command, **kwargs)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 102, in checked_call
    tries=tries, try_sleep=try_sleep, timeout_kill_strategy=timeout_kill_strategy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 150, in _call_wrapper
    result = _call(command, **kwargs_copy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 303, in _call
    raise ExecutionFailed(err_msg, code, out, err)
resource_management.core.exceptions.ExecutionFailed: Execution of 'ambari-python-wrap /usr/hdp/current/ranger-admin/dba_script.py -q' returned 1. 2020-02-12 12:05:38,812  [I] Running DBA setup script. QuiteMode:True
2020-02-12 12:05:38,812  [I] Using Java:/usr/jdk64/jdk1.8.0_112/bin/java
2020-02-12 12:05:38,812  [I] DB FLAVOR:MYSQL
2020-02-12 12:05:38,812  [I] DB Host:ip-172-31-27-99.ec2.internal
2020-02-12 12:05:38,813  [I] ---------- Verifying DB root password ---------- 
2020-02-12 12:05:38,813  [I] DBA root user password validated
2020-02-12 12:05:38,813  [I] ---------- Verifying Ranger Admin db user password ---------- 
2020-02-12 12:05:38,813  [I] admin user password validated
2020-02-12 12:05:38,813  [I] ---------- Creating Ranger Admin db user ---------- 
2020-02-12 12:05:38,813  [JISQL] /usr/jdk64/jdk1.8.0_112/bin/java  -cp /usr/hdp/2.6.1.0-129/ranger-admin/ews/lib/mysql-connector-java.jar:/usr/hdp/current/ranger-admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://ip-xxx-xx-xx-xx.ec2.internal/mysql -u ranger -p '********' -noheader -trim -c \; -query "SELECT version();"
SQLException : SQL state: 42000 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'ranger'@'ip-xxx-xx-xx-xx.ec2.internal' to database 'mysql' ErrorCode: 1044
2020-02-12 12:05:39,132  [E] Can't establish db connection.. Exiting..
1 ACCEPTED SOLUTION

avatar
Super Guru

@AarifAkhter 

 

You need to create permissions within mysql for your ranger user.

 

An example of this is:

 

CREATE DATABASE ranger;
CREATE USER 'ranger'@'hdp.cloudera.com' IDENTIFIED BY 'ranger';
GRANT ALL PRIVILEGES ON *.* TO 'ranger'@'hdp.cloudera.com' WITH GRANT OPTION;
FLUSH PRIVILEGES;

where you replace in your hostname for ranger in place of hdp.cloudera.com above:  

ip-xxx-xx-xx-xx.ec2.internal

 

I would also recommend to install using FQDNs (Fully Qualified Domain Names).

 

 

Please accept this answer as the solution to close the topic. 

View solution in original post

1 REPLY 1

avatar
Super Guru

@AarifAkhter 

 

You need to create permissions within mysql for your ranger user.

 

An example of this is:

 

CREATE DATABASE ranger;
CREATE USER 'ranger'@'hdp.cloudera.com' IDENTIFIED BY 'ranger';
GRANT ALL PRIVILEGES ON *.* TO 'ranger'@'hdp.cloudera.com' WITH GRANT OPTION;
FLUSH PRIVILEGES;

where you replace in your hostname for ranger in place of hdp.cloudera.com above:  

ip-xxx-xx-xx-xx.ec2.internal

 

I would also recommend to install using FQDNs (Fully Qualified Domain Names).

 

 

Please accept this answer as the solution to close the topic.