Sqoop安装及操作
一、集群环境:
Hostname |
IP |
Hadoop版本 |
Hadoop |
功能 |
系统 |
node1 |
192.168.1.151 |
0.20.0 |
namenode |
hive+sqoop |
rhel5.4X86 |
node2 |
192.168.1.152 |
0.20.0 |
datanode |
mysql |
rhel5.4X86 |
node3 |
192.168.1.153 |
0.20.0 |
datanode |
rhel5.4X86 |
二、安装sqoop
1、下载sqoop压缩包,并解压
压缩包分别是:sqoop-1.2.0-CDH3B4.tar.gz,hadoop-0.20.2-CDH3B4.tar.gz, Mysql JDBC驱动包mysql-connector-java-5.1.10-bin.jar
[root@node1 ~]# ll
drwxr-xr-x 15 root root 4096 Feb 22 2011 hadoop-0.20.2-CDH3B4
-rw-r--r-- 1 root root 724225 Sep 15 06:46 mysql-connector-java-5.1.10-bin.jar
drwxr-xr-x 11 root root 4096 Feb 22 2011 sqoop-1.2.0-CDH3B4
2、将sqoop-1.2.0-CDH3B4拷贝到/home/hadoop目录下,并将Mysql JDBC驱动包和hadoop-0.20.2-CDH3B4下的hadoop-core-0.20.2-CDH3B4.jar至sqoop-1.2.0-CDH3B4/lib下,最后修改一下属主。
[root@node1 ~]# cp mysql-connector-java-5.1.10-bin.jar sqoop-1.2.0-CDH3B4/lib
[root@node1 ~]# cp hadoop-0.20.2-CDH3B4/hadoop-core-0.20.2-CDH3B4.jar sqoop-1.2.0-CDH3B4/lib
[root@node1 ~]# chown -R hadoop:hadoop sqoop-1.2.0-CDH3B4
[root@node1 ~]# mv sqoop-1.2.0-CDH3B4 /home/hadoop
[root@node1 ~]# ll /home/hadoop
total 35748
-rw-rw-r-- 1 hadoop hadoop 343 Sep 15 05:13 derby.log
drwxr-xr-x 13 hadoop hadoop 4096 Sep 14 16:16 hadoop-0.20.2
drwxr-xr-x 9 hadoop hadoop 4096 Sep 14 20:21 hive-0.10.0
-rw-r--r-- 1 hadoop hadoop 36524032 Sep 14 20:20 hive-0.10.0.tar.gz
drwxr-xr-x 8 hadoop hadoop 4096 Sep 25 2012 jdk1.7
drwxr-xr-x 12 hadoop hadoop 4096 Sep 15 00:25 mahout-distribution-0.7
drwxrwxr-x 5 hadoop hadoop 4096 Sep 15 05:13 metastore_db
-rw-rw-r-- 1 hadoop hadoop 406 Sep 14 16:02 scp.sh
drwxr-xr-x 11 hadoop hadoop 4096 Feb 22 2011 sqoop-1.2.0-CDH3B4
drwxrwxr-x 3 hadoop hadoop 4096 Sep 14 16:17 temp
drwxrwxr-x 3 hadoop hadoop 4096 Sep 14 15:59 user
3、配置configure-sqoop,注释掉对于HBase和ZooKeeper的检查
[root@node1 bin]# pwd
/home/hadoop/sqoop-1.2.0-CDH3B4/bin
[root@node1 bin]# vi configure-sqoop #!/bin/bash
#
# Licensed to Cloudera, Inc. under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
.
.
.
# Check: If we can't find our dependencies, give up here.
if [ ! -d "${HADOOP_HOME}" ]; then
echo "Error: $HADOOP_HOME does not exist!"
echo 'Please set $HADOOP_HOME to the root of your Hadoop installation.'
exit 1
fi
#if [ ! -d "${HBASE_HOME}" ]; then
# echo "Error: $HBASE_HOME does not exist!"
# echo 'Please set $HBASE_HOME to the root of your HBase installation.'
# exit 1
#fi
#if [ ! -d "${ZOOKEEPER_HOME}" ]; then
# echo "Error: $ZOOKEEPER_HOME does not exist!"
# echo 'Please set $ZOOKEEPER_HOME to the root of your ZooKeeper installation.'
# exit 1
#fi
4、修改/etc/profile和.bash_profile文件,添加Hadoop_Home,调整PATH
[hadoop@node1 ~]$ vi .bash_profile # .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs HADOOP_HOME=/home/hadoop/hadoop-0.20.2
PATH=$HADOOP_HOME/bin:$PATH:$HOME/bin
export HIVE_HOME=/home/hadoop/hive-0.10.0
export MAHOUT_HOME=/home/hadoop/mahout-distribution-0.7
export PATH HADOOP_HOME
三、测试Sqoop
1、查看mysql中的数据库:
[hadoop@node1 bin]$ ./sqoop list-databases --connect jdbc:mysql://192.168.1.152:3306/ --username sqoop --password sqoop
13/09/15 07:17:16 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
13/09/15 07:17:17 INFO manager.MySQLManager: Executing SQL statement: SHOW DATABASES
information_schema
mysql
performance_schema
sqoop
test
2、将mysql的表导入到hive中:
[hadoop@node1 bin]$ ./sqoop import --connect jdbc:mysql://192.168.1.152:3306/sqoop --username sqoop --password sqoop --table test --hive-import -m 1
13/09/15 08:15:01 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
13/09/15 08:15:01 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
13/09/15 08:15:01 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
13/09/15 08:15:01 INFO tool.CodeGenTool: Beginning code generation
13/09/15 08:15:01 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `test` AS t LIMIT 1
13/09/15 08:15:02 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `test` AS t LIMIT 1
13/09/15 08:15:02 INFO orm.CompilationManager: HADOOP_HOME is /home/hadoop/hadoop-0.20.2/bin/..
13/09/15 08:15:02 INFO orm.CompilationManager: Found hadoop core jar at: /home/hadoop/hadoop-0.20.2/bin/../hadoop-0.20.2-core.jar
13/09/15 08:15:03 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-hadoop/compile/a71936fd2bb45ea6757df22751a320e3/test.jar
13/09/15 08:15:03 WARN manager.MySQLManager: It looks like you are importing from mysql.
13/09/15 08:15:03 WARN manager.MySQLManager: This transfer can be faster! Use the --direct
13/09/15 08:15:03 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.
13/09/15 08:15:03 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)
13/09/15 08:15:03 INFO mapreduce.ImportJobBase: Beginning import of test
13/09/15 08:15:04 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `test` AS t LIMIT 1
13/09/15 08:15:05 INFO mapred.JobClient: Running job: job_201309150505_0009
13/09/15 08:15:06 INFO mapred.JobClient: map 0% reduce 0%
13/09/15 08:15:34 INFO mapred.JobClient: map 100% reduce 0%
13/09/15 08:15:36 INFO mapred.JobClient: Job complete: job_201309150505_0009
13/09/15 08:15:36 INFO mapred.JobClient: Counters: 5
13/09/15 08:15:36 INFO mapred.JobClient: Job Counters
13/09/15 08:15:36 INFO mapred.JobClient: Launched map tasks=1
13/09/15 08:15:36 INFO mapred.JobClient: FileSystemCounters
13/09/15 08:15:36 INFO mapred.JobClient: HDFS_BYTES_WRITTEN=583323
13/09/15 08:15:36 INFO mapred.JobClient: Map-Reduce Framework
13/09/15 08:15:36 INFO mapred.JobClient: Map input records=65536
13/09/15 08:15:36 INFO mapred.JobClient: Spilled Records=0
13/09/15 08:15:36 INFO mapred.JobClient: Map output records=65536
13/09/15 08:15:36 INFO mapreduce.ImportJobBase: Transferred 569.6514 KB in 32.0312 seconds (17.7842 KB/sec)
13/09/15 08:15:36 INFO mapreduce.ImportJobBase: Retrieved 65536 records.
13/09/15 08:15:36 INFO hive.HiveImport: Removing temporary files from import process: test/_logs
13/09/15 08:15:36 INFO hive.HiveImport: Loading uploaded data into Hive
13/09/15 08:15:36 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `test` AS t LIMIT 1
13/09/15 08:15:36 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `test` AS t LIMIT 1
13/09/15 08:15:41 INFO hive.HiveImport: Logging initialized using configuration in jar:file:/home/hadoop/hive-0.10.0/lib/hive-common-0.10.0.jar!/hive-log4j.properties
13/09/15 08:15:41 INFO hive.HiveImport: Hive history file=/tmp/hadoop/hive_job_log_hadoop_201309150815_1877092059.txt
13/09/15 08:16:10 INFO hive.HiveImport: OK
13/09/15 08:16:10 INFO hive.HiveImport: Time taken: 28.791 seconds
13/09/15 08:16:11 INFO hive.HiveImport: Loading data to table default.test
13/09/15 08:16:12 INFO hive.HiveImport: Table default.test stats: [num_partitions: 0, num_files: 1, num_rows: 0, total_size: 583323, raw_data_size: 0]
13/09/15 08:16:12 INFO hive.HiveImport: OK
13/09/15 08:16:12 INFO hive.HiveImport: Time taken: 1.704 seconds
13/09/15 08:16:12 INFO hive.HiveImport: Hive import complete.
Sqoop安装及操作的更多相关文章
- sqoop安装与简单实用
一,sqoop安装 1.解压源码包 2.配置环境变量 3.在bin目录下的 /bin/configsqoop 注释掉check报错信息 4.配置conf目录下 /conf/sqoop-env.sh 配 ...
- [mysql]brew 安装 配置 操作 mysql(中文问题)
mac 下卸载mysqldmg mac下mysql的DMG格式安装内有安装文件,却没有卸载文件--很郁闷的事. 网上搜了一下,发现给的方法原来得手动去删. 很多文章记述要删的文件不完整,后来在stac ...
- 如何将mysql数据导入Hadoop之Sqoop安装
Sqoop是一款开源的工具,主要用于在Hadoop(Hive)与传统的数据库(mysql.postgresql...)间进行数据的传递,可以将一个关系型数据库(例如 : MySQL ,Oracle , ...
- 开发工具IntelliJ IDEA的安装与操作
开发工具IntelliJ IDEA的安装与操作 1.1 开发工具概述 IDEA是一个专门针对Java的集成开发工具(IDE),它可以极大地提升我们的开发效率.可以自动编译,检查错误.在公司中,使用的就 ...
- python操作三大主流数据库(1)python操作mysql①windows环境中安装python操作mysql数据库的MySQLdb模块mysql-client
windows安装python操作mysql数据库的MySQLdb模块mysql-client 正常情况下应该是cmd下直接运行 pip install mysql-client 命令即可,试了很多台 ...
- 安装MACOS操作步骤详解
安装MACOS操作步骤详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 关于安装MAC的操作系统其实大家都知道可以让客服帮忙提供软件上的支持,而且苹果客服都很有礼貌呢,而且非常的 ...
- pycharm 安装激活操作
pycharm 安装激活操作 什么是 PyCharm PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试.语法高亮.Project管 ...
- Sqoop安装与应用过程
1. 参考说明 参考文档: http://sqoop.apache.org/ http://sqoop.apache.org/docs/1.99.7/admin/Installation.html ...
- sqoop安装部署(笔记)
sqoop是一个把关系型数据库数据抽向hadoop的工具.同时,也支持将hive.pig等查询的结果导入关系型数据库中存储.由于,笔者部署的hadoop版本是2.2.0,所以sqoop的版本是:sqo ...
随机推荐
- 将hadoop源代码导入eclipse
1. 安装JDK,eclipse,下载hadoop源代码并解压到某一个目录. 2. 安装maven,将bin目录添加到PATH环境变量中. 3. 安装protobuf2.5.0,将protoc-2.5 ...
- SQL exist
EXISTS = IN,意思相同不过语法上有点点区别,好像使用IN效率要差点,应该是不会执行索引的原因SELECT ID,NAME FROM A WHERE ID IN (SELECT AID FRO ...
- ORACLE数据库用户账号处于expired状态如何处理
账户过期,必须要用户更改密码, 账户才能重新使用. 但有些时候, 因为各种原因, 我们并不知道原密码的明文是什么,但很多时候又不能修改已有密码,好在可以用原密码来更改密码. 在11G中,dba_use ...
- 详细讲解Quartz.NET
Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中.它提供了巨大的灵活性而不牺牲 ...
- 二分多重匹配(HDU5093)
Battle ships Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- 解决 Xamarin 拖拽Plain Text 于Layout上时 出现 “The layout could not be loaded:java.lang.System.arraycopy([CI[CII)V” 错误
右键项目属性
- C++之路进阶——bzoj2199(奶牛议会)
F.A.Qs Home Discuss ProblemSet Status Ranklist Contest ModifyUser gryz2016 Logout 捐赠本站 Notice:由于本OJ ...
- JAVA面试题之实现字符串的倒序输出
package shb.java.demo; public class MyTest { public static void main(String[] args) { String string ...
- 04---Net基础加强
字符串常用方法: 属性: Length获取字符串中字符的个数 IsNullOrEmpty() 静态方法,判断为null或者为“” ToCharArray() 将string转换为char[] To ...
- 记centos7中的network.service启动失败
查看启动失败的服务: systemctl --failed 然后就发现了一个叫network.service 的服务启动失败了. 后来找到了原因, 是因为配置文件中没有写上网卡的硬件地址 配置文件所在 ...