The Ambari-Ranger component modified the MySQL default port and caused the startup failure to solve the problem (Communications link failure)

table of Contents

1. Problem scenario

Two, the solution

Problem solving process one

Problem solving process two


1. Problem scenario

       Install the Ambari + HDP cluster, modify the default port of MySQL, there is no problem during installation, ranger Admin reports the following error when starting:

Problem description:  On the Ambari page, when installing the Ranger component, the port of the MySQL database used in the background was modified to: non-default port 3306. An  error was reported when starting and restarting the Ranger component:
/usr/jdk64/java/bin/java -cp /usr/hdp/current/... jdbc:mysql://namenode/ranger -u 'ranger' -p '******' -noheader ......
missing port number: 3906, which should actually be:...... jdbc:mysql://namenode:3906/ranger ......

The final error is as follows:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure According to this information to solve the problem, the root cause of the problem was not found after a detour.


Two, the solution

Problem solving process one

At first I really thought it was the reason for the MySQL connection timeout, but I was still not sure, because there was no problem with the default port of MySQL before.

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

When the database restarts or the database idle connection exceeds the set maximum timemout time , the database will forcibly disconnect the existing link. The maximum timeout time can be show global variables like "wait_timeout";queried through the command :

mysql> show global variables like "wait_timeout";
+---------------+-------+
| VARIABLE_NAME | VALUE |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

But after doing the above configuration, I changed it back without me, and ruled out this possibility, so I thought it was a pit of Ranger, so I searched the Internet and someone encountered it.

Problem solving process two

a mbari's big pit on ranger----The port default is 3306, which needs to be modified manually

When ambari installs the ranger, you need to connect to the database. The mysql database is used. At this time, you need to enter the database root user name and password, because you need to connect to the root user to create a new user and database

The problem lies here, because the production environment has changed the default port of MySQL, but the start script of the ranger uses the default MySQL port.

/usr/jdk64/java/bin/java -cp /usr/hdp/current/... jdbc:mysql://namenode/ranger -u 'ranger' -p '******' -noheader ......
Missing port number: 33066, which is actually:...... jdbc:mysql://namenode:33066/ranger ......

So I entered the startup script: vim /usr/hdp/current/ranger-admin/db_setup.py    search for the location of jisql_cmd and find the place of jdbc:mysql:// and manually modify it. The version of Ambari is different, and the location of jdbc:myql It may be different.

Remember: It is the modified MySQL port after the first %s

 Possible problem : vim /usr/hdp/current/ranger-admin/db_setup.py can not save after editing the file, it is readonly, you can try sudo vim to enter the file with root privileges.

Guess you like

Origin blog.csdn.net/qq_35995514/article/details/108253976