Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Error when trying to install Apache Ranger through Ambari

avatar
Explorer

This error shows up when installing Apache Ranger service:

stderr: /var/lib/ambari-agent/data/errors-21.txt
Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py", line 124, in <module>
    RangerAdmin().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 216, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/ranger_admin.py", line 43, in install
    setup_ranger_db()
  File "/var/lib/ambari-agent/cache/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py", line 199, in setup_ranger_db
    user=params.unix_user,
  File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 154, in __init__
    self.env.run()
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 152, in run
    self.run_action(resource, action)
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 118, in run_action
    provider_action()
  File "/usr/lib/python2.6/site-packages/resource_management/core/providers/system.py", line 260, 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 70, in inner
    result = function(command, **kwargs)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 92, in checked_call
    tries=tries, try_sleep=try_sleep)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 140, in _call_wrapper
    result = _call(command, **kwargs_copy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 291, in _call
    raise Fail(err_msg)
resource_management.core.exceptions.Fail: Execution of 'python /usr/hdp/current/ranger-admin/dba_script.py -q' returned 1. 2016-10-21 10:22:39,275  [I] Running DBA setup script. QuiteMode:True
2016-10-21 10:22:39,276  [I] Using Java:/usr/jdk64/jdk1.8.0_40/bin/java
2016-10-21 10:22:39,276  [I] DB FLAVOR:MYSQL
2016-10-21 10:22:39,276  [I] DB Host:hadoop
2016-10-21 10:22:39,276  [I] ---------- Verifing DB root password ---------- 
2016-10-21 10:22:39,276  [I] DBA root user password validated
2016-10-21 10:22:39,276  [I] ---------- Verifing Ranger Admin db user password ---------- 
2016-10-21 10:22:39,276  [I] admin user password validated
2016-10-21 10:22:39,276  [I] ---------- Creating Ranger Admin db user ---------- 
2016-10-21 10:22:39,276  [JISQL] /usr/jdk64/jdk1.8.0_40/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/hdp/current/ranger-admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://hadoop/mysql -u root -p '********' -noheader -trim -c \; -query "SELECT version();"
SQLException : SQL state: 08S01 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. ErrorCode: 0
2016-10-21 10:22:39,697  [E] Can't establish db connection.. Exiting..
stdout: /var/lib/ambari-agent/data/output-21.txt
2016-10-21 10:22:00,249 - Group['ranger'] {}
2016-10-21 10:22:00,250 - Adding group Group['ranger']
2016-10-21 10:22:00,271 - Group['hadoop'] {}
2016-10-21 10:22:00,271 - Group['users'] {}
2016-10-21 10:22:00,271 - User['zookeeper'] {'gid': 'hadoop', 'groups': [u'hadoop']}
2016-10-21 10:22:00,272 - User['ams'] {'gid': 'hadoop', 'groups': [u'hadoop']}
2016-10-21 10:22:00,272 - User['ambari-qa'] {'gid': 'hadoop', 'groups': [u'users']}
2016-10-21 10:22:00,273 - User['ranger'] {'gid': 'hadoop', 'groups': [u'ranger']}
2016-10-21 10:22:00,273 - Adding user User['ranger']
2016-10-21 10:22:00,312 - User['hdfs'] {'gid': 'hadoop', 'groups': [u'hadoop']}
2016-10-21 10:22:00,312 - File['/var/lib/ambari-agent/tmp/changeUid.sh'] {'content': StaticFile('changeToSecureUid.sh'), 'mode': 0555}
2016-10-21 10:22:00,314 - Execute['/var/lib/ambari-agent/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa'] {'not_if': '(test $(id -u ambari-qa) -gt 1000) || (false)'}
2016-10-21 10:22:00,324 - Skipping Execute['/var/lib/ambari-agent/tmp/changeUid.sh ambari-qa /tmp/hadoop-ambari-qa,/tmp/hsperfdata_ambari-qa,/home/ambari-qa,/tmp/ambari-qa,/tmp/sqoop-ambari-qa'] due to not_if
2016-10-21 10:22:00,324 - Group['hdfs'] {'ignore_failures': False}
2016-10-21 10:22:00,325 - User['hdfs'] {'ignore_failures': False, 'groups': [u'hadoop', u'hdfs']}
2016-10-21 10:22:00,325 - Directory['/etc/hadoop'] {'mode': 0755}
2016-10-21 10:22:00,335 - File['/usr/hdp/current/hadoop-client/conf/hadoop-env.sh'] {'content': InlineTemplate(...), 'owner': 'hdfs', 'group': 'hadoop'}
2016-10-21 10:22:00,335 - Directory['/var/lib/ambari-agent/tmp/hadoop_java_io_tmpdir'] {'owner': 'hdfs', 'group': 'hadoop', 'mode': 0777}
2016-10-21 10:22:00,347 - Repository['HDP-2.3'] {'base_url': 'http://public-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.3.6.0', 'action': ['create'], 'components': [u'HDP', 'main'], 'repo_template': '{{package_type}} {{base_url}} {{components}}', 'repo_file_name': 'HDP', 'mirror_list': None}
2016-10-21 10:22:00,352 - File['/tmp/tmpQrknxr'] {'content': 'deb http://public-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.3.6.0 HDP main'}
2016-10-21 10:22:00,352 - Writing File['/tmp/tmpQrknxr'] because contents don't match
2016-10-21 10:22:00,353 - File['/tmp/tmpUyrxfk'] {'content': StaticFile('/etc/apt/sources.list.d/HDP.list')}
2016-10-21 10:22:00,353 - Writing File['/tmp/tmpUyrxfk'] because contents don't match
2016-10-21 10:22:00,356 - Repository['HDP-UTILS-1.1.0.20'] {'base_url': 'http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu12', 'action': ['create'], 'components': [u'HDP-UTILS', 'main'], 'repo_template': '{{package_type}} {{base_url}} {{components}}', 'repo_file_name': 'HDP-UTILS', 'mirror_list': None}
2016-10-21 10:22:00,358 - File['/tmp/tmpjnzowL'] {'content': 'deb http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu12 HDP-UTILS main'}
2016-10-21 10:22:00,358 - Writing File['/tmp/tmpjnzowL'] because contents don't match
2016-10-21 10:22:00,359 - File['/tmp/tmphZvLaq'] {'content': StaticFile('/etc/apt/sources.list.d/HDP-UTILS.list')}
2016-10-21 10:22:00,359 - Writing File['/tmp/tmphZvLaq'] because contents don't match
2016-10-21 10:22:00,360 - Package['unzip'] {}
2016-10-21 10:22:00,403 - Skipping installation of existing package unzip
2016-10-21 10:22:00,403 - Package['curl'] {}
2016-10-21 10:22:00,441 - Skipping installation of existing package curl
2016-10-21 10:22:00,441 - Package['hdp-select'] {}
2016-10-21 10:22:00,486 - Skipping installation of existing package hdp-select
2016-10-21 10:22:00,618 - Package['ranger-2-3-.*-admin'] {}
2016-10-21 10:22:00,655 - Installing package ranger-2-3-.*-admin ('/usr/bin/apt-get -q -o Dpkg::Options::=--force-confdef --allow-unauthenticated --assume-yes install 'ranger-2-3-.*-admin'')
2016-10-21 10:22:34,580 - Package['ranger-2-3-.*-usersync'] {}
2016-10-21 10:22:34,624 - Installing package ranger-2-3-.*-usersync ('/usr/bin/apt-get -q -o Dpkg::Options::=--force-confdef --allow-unauthenticated --assume-yes install 'ranger-2-3-.*-usersync'')
2016-10-21 10:22:39,188 - File['/var/lib/ambari-agent/tmp/mysql-connector-java.jar'] {'content': DownloadSource('http://hadoop:8080/resources//mysql-jdbc-driver.jar'), 'mode': 0644}
2016-10-21 10:22:39,189 - Downloading the file from http://hadoop:8080/resources//mysql-jdbc-driver.jar
2016-10-21 10:22:39,201 - Writing File['/var/lib/ambari-agent/tmp/mysql-connector-java.jar'] because it doesn't exist
2016-10-21 10:22:39,202 - Directory['/usr/share/java'] {'recursive': True, 'mode': 0755, 'cd_access': 'a'}
2016-10-21 10:22:39,203 - Execute[('cp', '--remove-destination', '/var/lib/ambari-agent/tmp/mysql-connector-java.jar', '/usr/share/java/mysql-connector-java.jar')] {'path': ['/bin', '/usr/bin/'], 'sudo': True}
2016-10-21 10:22:39,209 - File['/usr/share/java/mysql-connector-java.jar'] {'mode': 0644}
2016-10-21 10:22:39,209 - Execute[('cp', '--remove-destination', '/var/lib/ambari-agent/tmp/mysql-connector-java.jar', '/usr/hdp/current/ranger-admin/ews/lib')] {'path': ['/bin', '/usr/bin/'], 'sudo': True}
2016-10-21 10:22:39,217 - File['/usr/hdp/current/ranger-admin/ews/lib/mysql-connector-java.jar'] {'mode': 0644}
2016-10-21 10:22:39,218 - ModifyPropertiesFile['/usr/hdp/current/ranger-admin/install.properties'] {'owner': 'ranger', 'properties': ...}
2016-10-21 10:22:39,219 - Modifying existing properties file: /usr/hdp/current/ranger-admin/install.properties
2016-10-21 10:22:39,227 - File['/usr/hdp/current/ranger-admin/install.properties'] {'owner': 'ranger', 'content': ..., 'group': None, 'mode': None, 'encoding': 'utf-8'}
2016-10-21 10:22:39,227 - Writing File['/usr/hdp/current/ranger-admin/install.properties'] because contents don't match
2016-10-21 10:22:39,228 - Changing owner for /usr/hdp/current/ranger-admin/install.properties from 0 to ranger
2016-10-21 10:22:39,228 - Setting up Ranger DB and DB User
2016-10-21 10:22:39,229 - Execute['python /usr/hdp/current/ranger-admin/dba_script.py -q'] {'logoutput': True, 'environment': {'RANGER_ADMIN_HOME': '/usr/hdp/current/ranger-admin', 'JAVA_HOME': u'/usr/jdk64/jdk1.8.0_40'}, 'user': 'ranger'}
2016-10-21 10:22:39,275  [I] Running DBA setup script. QuiteMode:True
2016-10-21 10:22:39,276  [I] Using Java:/usr/jdk64/jdk1.8.0_40/bin/java
2016-10-21 10:22:39,276  [I] DB FLAVOR:MYSQL
2016-10-21 10:22:39,276  [I] DB Host:hadoop
2016-10-21 10:22:39,276  [I] ---------- Verifing DB root password ---------- 
2016-10-21 10:22:39,276  [I] DBA root user password validated
2016-10-21 10:22:39,276  [I] ---------- Verifing Ranger Admin db user password ---------- 
2016-10-21 10:22:39,276  [I] admin user password validated
2016-10-21 10:22:39,276  [I] ---------- Creating Ranger Admin db user ---------- 
2016-10-21 10:22:39,276  [JISQL] /usr/jdk64/jdk1.8.0_40/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/hdp/current/ranger-admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://hadoop/mysql -u root -p '********' -noheader -trim -c \; -query "SELECT version();"
SQLException : SQL state: 08S01 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. ErrorCode: 0
2016-10-21 10:22:39,697  [E] Can't establish db connection.. Exiting..
1 ACCEPTED SOLUTION

avatar
Contributor

@Aitor Osa

The error shows that Ranger install is failing due to ranger host not able to communicate to given db host

Need to check below properties: 1) Check the Ranger db host 2) Check whether db gets connected from host were Ranger is to be installed. If not, you will need to provide permissions.

View solution in original post

4 REPLIES 4

avatar
Contributor

@Aitor Osa

The error shows that Ranger install is failing due to ranger host not able to communicate to given db host

Need to check below properties: 1) Check the Ranger db host 2) Check whether db gets connected from host were Ranger is to be installed. If not, you will need to provide permissions.

avatar
Explorer

Thanks, the only thing I had to do is put localhost instead of my fqdn. Idk why it works this way but thx! 😄

avatar

here it seems some issue with db setting can you please ranger db config like ranger_jdbc_connection_url and all.

avatar
Cloudera Employee

I had this problem, I had Ranger DB set to c6402.ambari.apache.org:6080 and it needed to be c6402.ambari.apache.org. Just had to take the port # off.