作者:许冠中一亦 | 来源:互联网 | 2023-05-18 11:45
转载请注明出处:http:blog.csdn.netl1028386804articledetails51594008sqoop是一个把关系型数据库数据抽向hadoop的工具。同时,也支持
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/51594008
sqoop是一个把关系型数据库数据抽向hadoop的工具。同时,也支持将hive、pig等查询的结果导入关系型数据库中存储。由于,本人部署的hadoop版本是2.2.0,所以sqoop的版本是:sqoop-1.99.3-bin-hadoop200
1、下载sqoop
wget https://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.99.6/sqoop-1.99.6-bin-hadoop200.tar.gz
2、解压sqoop安装文件
tar -zxvf sqoop-1.99.3-bin-hadoop200.tar.gz
3、配置sqoop环境变量
export SQOOP_HOME=/home/liuyazhuang/sqoop/sqoop
export PATH = $SQOOP_HOME/bin:$PATH
修改sqoop——server关于hadoop共享jar的引用
vi server/conf/catalina.properties
找到common.loader行,把/usr/lib/hadoop/lib/*.jar改成你的hadoop jar 包目录
例如:/home/hadoop/hadoop/share/hadoop/yarn/lib/*.jar,
/home/hadoop/hadoop/share/hadoop/yarn/*.jar,
/home/hadoop/hadoop/share/hadoop/hdfs/*.jar,
/home/hadoop/hadoop/share/hadoop/hdfs/lib/*.jar,
/home/hadoop/hadoop/share/hadoop/mapreduce/*.jar,
/home/hadoop/hadoop/share/hadoop/mapreduce/lib/*.jar,
/home/hadoop/hadoop/share/hadoop/common/lib/*.jar,
/home/hadoop/hadoop/share/hadoop/common/*.jar
vi server/conf/sqoop.properties
找到:mapreduce.configuration.directory行,修改值为你的hadoop配置文件目录
如:/home/liuyazhuang/hadoop/hadoop/etc/hadoop
并且替换@LOGDIR@ 和@BASEDIR@ :
0,$ s/@LOGDIR@/logs/g
0,$ s/@BASEDIR@/base/g
然后找到你的数据库jdbc驱动复制到sqoop/lib目录下,如果不存在则创建.
vi /etc/profile
增加以下内容:
export SQOOP_HOME=/home/hadoop/sqoop
export PATH=$PATH:$SQOOP_HOME/bin
export CATALINA_BASE=$SQOOP_HOME/server
export LOGDIR=$SQOOP_HOME/logs/
启动 [root@liuyazhuang sqoop]# ./bin/sqoop.sh server startSqoop home directory: /home/liuyazhuang/sqoop/sqoopSetting SQOOP_HTTP_PORT: 12000Setting SQOOP_ADMIN_PORT: 12001Using CATALINA_OPTS:Adding to CATALINA_OPTS: -Dsqoop.http.port=12000 -Dsqoop.admin.port=12001Using CATALINA_BASE: /home/liuyazhuang/sqoop/sqoop/serverUsing CATALINA_HOME: /home/liuyazhuang/sqoop/sqoop/serverUsing CATALINA_TMPDIR: /home/liuyazhuang/sqoop/sqoop/server/tempUsing JRE_HOME: /usr/local/jdk1.7.0Using CLASSPATH: /home/liuyazhuang/sqoop/sqoop/server/bin/bootstrap.jar(sqoop服务端是一个跑在tomcat上的服务程序)关闭 sqoop server :./bin/sqoop.sh server stop使用sqoop客户端:[root@liuyazhuang sqoop]# bin/sqoop.sh clientSqoop home directory: /home/liuyazhuang/sqoop/sqoopSqoop Shell: Type 'help' or '\h' for help.sqoop:000> show version --all#显示版本:show version --all显示连接器:show connector --all创建连接:create connection --cid 1client version: Sqoop 1.99.3 revision 2404393160301df16a94716a3034e31b03e27b0b Compiled by mengweid on Fri Oct 18 14:15:53 EDT 2013server version: Sqoop 1.99.3 revision 2404393160301df16a94716a3034e31b03e27b0b Compiled by mengweid on Fri Oct 18 14:15:53 EDT 2013Protocol version: [1]sqoop:000>