ranger启动报错SQLException : SQL state: 08001 java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed ErrorCode: 0
时间: 2023-12-18 14:28:26 浏览: 245
ApacheRanger剖析:Hadoop生态圈的安全管家
ranger启动报错SQLException : SQL state: 08001 java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed ErrorCode: 0,这是因为使用mysql8数据库时,ranger-admin初始化时会抛出异常,提示Public Key Retrieval is not allowed。这是因为mysql8默认情况下不允许从不加密的连接中检索公钥,需要手动设置allowPublicKeyRetrieval=true。
解决方法如下:
1.在ranger-admin的安装目录下找到install.properties文件,添加以下配置:
```shell
SQL_CONNECTOR_JAR=/path/to/mysql-connector-java-5.1.47.jar
SQL_CONNECTOR_DOWNLOAD_URL=https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.47.tar.gz
```
其中,SQL_CONNECTOR_JAR为mysql-connector-java-5.1.47.jar的路径,SQL_CONNECTOR_DOWNLOAD_URL为下载地址。
2.在ranger-admin的安装目录下找到db_setup.py文件,将以下代码:
```python
if db_flavor == "mysql":
jdbc_url = "jdbc:mysql://" + db_host + "/" + db_name
elif db_flavor == "oracle":
jdbc_url = "jdbc:oracle:thin:@" + db_host + ":" + db_port + ":" + db_name
elif db_flavor == "postgres":
jdbc_url = "jdbc:postgresql://" + db_host + ":" + db_port + "/" + db_name
elif db_flavor == "mssql":
jdbc_url = "jdbc:sqlserver://" + db_host + ":" + db_port + ";databaseName=" + db_name
else:
print("ERROR: Unsupported database flavor: " + db_flavor)
sys.exit(1)
```
修改为:
```python
if db_flavor == "mysql":
jdbc_url = "jdbc:mysql://" + db_host + "/" + db_name + "?useSSL=false&allowPublicKeyRetrieval=true"
elif db_flavor == "oracle":
jdbc_url = "jdbc:oracle:thin:@" + db_host + ":" + db_port + ":" + db_name
elif db_flavor == "postgres":
jdbc_url = "jdbc:postgresql://" + db_host + ":" + db_port + "/" + db_name
elif db_flavor == "mssql":
jdbc_url = "jdbc:sqlserver://" + db_host + ":" + db_port + ";databaseName=" + db_name
else:
print("ERROR: Unsupported database flavor: " + db_flavor)
sys.exit(1)
```
3.重新执行ranger-admin的初始化命令即可。
阅读全文