(十一)安装sqoop

下载并解压

1)下载地址:http://mirrors.hust.edu.cn/apache/sqoop/1.4.6/
2)上传安装包sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz到hadoop102的/opt/software路径中
3)解压sqoop安装包到指定目录,如:
tar -zxf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz -C /opt/module/
4)解压sqoop安装包到指定目录,如:
mv sqoop-1.4.6.bin__hadoop-2.0.4-alpha/ sqoop
5)递归修改目录所属用户
chown shsxt:shsxt sqoop/ -R

修改配置文件

  1. 进入到/opt/module/sqoop/conf目录,重命名配置文件
    mv sqoop-env-template.sh sqoop-env.sh
  2. 修改配置文件
    vim sqoop-env.sh
    增加如下内容:
    export HADOOP_COMMON_HOME=/opt/module/hadoop-2.7.2
    export HADOOP_MAPRED_HOME=/opt/module/hadoop-2.7.2
    export HIVE_HOME=/opt/module/hive
    export ZOOKEEPER_HOME=/opt/module/zookeeper-3.4.10
    export ZOOCFGDIR=/opt/module/zookeeper-3.4.10/conf
    export HBASE_HOME=/opt/module/hbase

拷贝JDBC驱动,让sqoop连接上mysql

1)进入到/opt/software/mysql-libs路径,解压mysql-connector-java-5.1.27.tar.gz到当前路径
tar -zxvf mysql-connector-java-5.1.27.tar.gz
2)进入到/opt/software/mysql-libs/mysql-connector-java-5.1.27路径,拷贝jdbc驱动到sqoop的lib目录下。
cp mysql-connector-java-5.1.27-bin.jar /opt/module/sqoop/lib/

验证Sqoop

我们可以通过某一个command来验证sqoop配置是否正确:
bin/sqoop help
出现一些Warning警告(警告信息已省略),并伴随着帮助命令的输出:
Available commands:
codegen Generate code to interact with database records
create-hive-table Import a table definition into Hive
eval Evaluate a SQL statement and display the results
export Export an HDFS directory to a database table
help List available commands
import Import a table from a database to HDFS
import-all-tables Import tables from a database to HDFS
import-mainframe Import datasets from a mainframe server to HDFS
job Work with saved jobs
list-databases List available databases on a server
list-tables List available tables in a database
merge Merge results of incremental imports
metastore Run a standalone Sqoop metastore
version Display version information

测试Sqoop是否能够成功连接数据库

bin/sqoop list-databases --connect jdbc:mysql://hadoop102:3306/ --username root --password xxxx
出现如下输出表示成功:
information_schema
mysql
performance_schema
test

你可能感兴趣的:((十一)安装sqoop)