运行环境,hadoop2.6.0-cdh5.5.2
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、虚拟空间、营销软件、网站建设、隆化网站维护、网站推广。
所以,下载的sqoop1.4.6也是5.5.2的版本,与之相对。
文件安装在了/usr/local/中
[root@fa01 hadoop]# tar -zxvf /home/hadoop/sqoop-1.4.6-cdh6.5.2.tar.gz -C /usr/local/
[root@fa01 hadoop]# mv ./sqoop-1.4.6-cdh6.5.2 ./sqoop-1.4.6
[root@fa01 hadoop]# chown -Rhadoop:hadoop ./sqoop-1.4.6
下载JDBC,放到sqoop-1.4.6/lib目录下
[hadoop@fa01 lib]$ mv MySQL-connector-java-5.1.43-bin.jar /usr/local/sqoop-1.4.6/lib
修改配置文件,拷贝一份
[hadoop@fa01 conf]$ cp sqoop-env-template.sh sqoop-env.sh
[hadoop@fa01 conf]$ vi sqoop-env.sh
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/home/hadoop/hadoop-2.6.0-cdh6.5.2
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/home/hadoop/hadoop-2.6.0-cdh6.5.2
配置环境变量,添加
[hadoop@fa01 bin]$ vi /home/hadoop/.bash_profile
export SQOOP_HOME=/usr/local/sqoop-1.4.6
出现警告:
[hadoop@fa01 bin]$ ./sqoop
Warning: /home/hadoop/sqoopsqoop-1.99.7/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /home/hadoop/sqoopsqoop-1.99.7/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/hadoop/sqoopsqoop-1.99.7/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/hadoop/sqoopsqoop-1.99.7/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
Error:Could not find or load main class org.apache.sqoop.Sqoop
解决方式:
[hadoop@fa01 bin]$ vi configure-sqoop
把上面的四个内容都给#注释掉了,就只剩下最后的报错了。
第一步,拷贝jar包
[hadoop@fa01 sqoop-1.4.6]$ cp sqoop-1.4.6-cdh6.5.2.jar ./lib/
会依旧报错。
第二步,修改启动的配置文件
[hadoop@fa01 bin]$ cd /usr/local/sqoop-1.4.6/bin
先给sqoop做个备份。
[hadoop@fa01 bin]$ cp sqoop sqoop.bak
修改
[hadoop@fa01 bin]$ vi sqoop
添加了一段的内容
exec ${HADOOP_COMMON_HOME}/bin/hadoop jar $SQOOP_HOME/sqoop-1.4.6-cdh6.5.2.jarorg.apache.sqoop.Sqoop "$@"
我到这里已经好用。
如果还报错,就把$SQOOP_HOME/下的sqoop-1.4.6-cdh6.5.2.jar放到$SQOOP_HOME/lib目录下。
连接测试:
[hadoop@fa01 bin]$ ./sqoop list-tables --connect jdbc:mysql://192.111.111.111:3306/dasename --username mysqlname --password mysqlmima