关闭

sqoop连接mysql的一些错误

标签: mysqlhadoopsqoop
896人阅读 评论(0) 收藏 举报

版本说明:
hadoop 2.2.0
sqoop 1.4.4
mysql 5.1.73
jdk 1.8.0
连接工具:mysql-connector-java-5.1.26-bin.jar
安装完sqoop时运行:
sqoop-list-databases –connectjdbc:mysql://localhost:3306/ –username root -P 连接mysql时出现如下问题:
[hadoop2@master1]$

sqoop-list-tables –connectjdbc:mysql://127.0.0.1/test –username root -P
Enter password:
Exception in thread “main” java.lang.NoSuchMethodError: org.apache.hadoop.conf.Configuration.addDeprecations([Lorg/a
pache/hadoop/conf/Configuration$DeprecationDelta;)V

at org.apache.hadoop.mapreduce.util.ConfigUtil.addDeprecatedKeys(ConfigUtil.java:54)
at org.apache.hadoop.mapreduce.util.ConfigUtil.loadResources(ConfigUtil.java:42)
at org.apache.hadoop.mapred.JobConf.(JobConf.java:119)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:1659)
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:91)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
at org.apache.sqoop.ConnFactory.instantiateFactories(ConnFactory.java:92)
at org.apache.sqoop.ConnFactory.(ConnFactory.java:62)
at com.cloudera.sqoop.ConnFactory.(ConnFactory.java:36)
at org.apache.sqoop.tool.BaseSqoopTool.init(BaseSqoopTool.java:225)
at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:44)
at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
提示找不到mapreduce。。。
查看配置文件: cat /etc/profile 发现有个配置错误,多打了一个A,⊙﹏⊙b汗…..修正如下:
export HADOOP_MAPRED_HOME=$HADOOP_HOME

通过 source /etc/profile 使修改生效再次运行,发现错误依旧存在。查看/sqoop/conf目录下的sqoop-env.sh发现有这么一句:
export HADOOP_MAPRED_HOME=/home/hadoop2/softwares/hadoop2.2.0/share/hadoop/mapreduce

这与我们/etc/profile 配置的环境变量相冲突。
我们把hadoop下mapreduce中的jar包拷贝到sqoop的lib库中
cp /home/hadoop2/softwares/hadoop-2.2.0/share/hadoop/mapreduce/*.jar /home/hadoop2/softwares/sqoop/lib
这时运行sqoop连接mysql,输入mysql密码发现成功。
sqoop-list-databases –connect jdbc:mysql://localhost:3306/ –username root -P
Enter password:
15/11/17 09:16:45 INFO manager.MySQLManager;Preparing to use aMySQL straming resultset.
information schema
linktest
mysql
test

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2017次
    • 积分:49
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档