更新时间:2024-12-11 GMT+08:00

连接postgresql或者gaussdb时报错

问题

连接postgresql或者gaussdb时报错。

回答

场景一:(import场景)使用sqoop import命令抽取开源Postgre到MRS HDFS或Hive等。
  • 问题现象:

    使用sqoop命令查询postgre表可以,但是执行sqoop import命令倒数时报错:

    The authentication type 5 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it
    The authentication type 12 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it
  • 问题根因:
    • 报错中type为5时:在执行sqoop import命令时,会启动MapReduce任务,由于MRS Hadoop安装目录(${BIGDATA_HOME}/FusionInsight_HD_*/1_*_NodeManager/install/hadoop/share/hadoop/common/lib)下自带了postgre驱动包gsjdbc4-*.jar,与开源Postgre服务不兼容导致报错。
    • 报错中type为12时:数据库的pg_hba.conf文件配置有误。
  • 解决方案:
    • 报错中type为5时:在每台MRS NodeManager实例所在节点上移动驱动包“gsjdbc4-*.jar”到“tmp”目录下。

      mv ${BIGDATA_HOME}/FusionInsight_HD_*/1_*_NodeManager/install/hadoop/share/hadoop/common/lib/gsjdbc4-*.jar /tmp

    • 报错中type为12时:调整数据库的pg_hba.conf文件,将address改成Sqoop所在节点的IP。

场景二:(export场景)使用sqoop export命令抽取开源Postgre到MRS HDFS或Hive等。
  • 问题现象:

    使用sqoop命令查询postgre表可以,但是执行sqoop export命令倒数时报错:

    The authentication type 5 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it
  • 问题根因:

    在执行sqoop export命令时,会启动MapReduce任务,由于MRS Hadoop安装目录(${BIGDATA_HOME}/FusionInsight_HD_*/1_*_NodeManager/install/hadoop/share/hadoop/common/lib)下自带了postgre驱动包“gsjdbc4-*.jar”,与开源Postgre服务不兼容导致报错。

  • 解决方案:
    1. 在每台MRS NodeManager实例所在节点上移动驱动包“gsjdbc4-*.jar”到“tmp”目录下。

      mv ${BIGDATA_HOME}/FusionInsight_HD_*/1_*_NodeManager/install/hadoop/share/hadoop/common/lib/gsjdbc4-*.jar /tmp

    1. 将“/opt/client/Hive/Beeline/lib/gsjdbc4-*.jar”删除 。