一、安装sqoop
1、解压
##解压 [root@hadoop-senior cdh]# tar zxf sqoop-1.4.5-cdh5.3.6.tar.gz -C /opt/cdh-5.3.6/
2、/opt/cdh-5.3.6/sqoop-1.4.5-cdh5.3.6/conf/sqoop-env.sh //先重命名
#Set path to where bin/hadoop is available export HADOOP_COMMON_HOME=/opt/cdh-5.3.6/hadoop-2.5.0-cdh5.3.6 #Set path to where hadoop-*-core.jar is available export HADOOP_MAPRED_HOME=/opt/cdh-5.3.6/hadoop-2.5.0-cdh5.3.6 #set the path to where bin/hbase is available #export HBASE_HOME= #Set the path to where bin/hive is available export HIVE_HOME=/opt/cdh-5.3.6/hive-0.13.1-cdh5.3.6
3、查看命令帮助
[root@hadoop-senior sqoop-1.4.5-cdh5.3.6]# bin/sqoop help usage: sqoop COMMAND [ARGS] 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 See 'sqoop help COMMAND' for information on a specific command.
4、拷贝mysql驱动,这里一mysql为例;
[root@hadoop-senior sqoop-1.4.5-cdh5.3.6]# cp /opt/softwares/mysql-libs/mysql-connector-java-5.1.27/mysql-connector-java-5.1.27-bin.jar ./lib/
5、sqoop使用要点
二、使用
[root@hadoop-senior sqoop-1.4.5-cdh5.3.6]# bin/sqoop list-databases \ > --connect jdbc:mysql://hadoop-senior.ibeifeng.com:3306 \ > --username root \ > --password 123456 Warning: /opt/cdh-5.3.6/sqoop-1.4.5-cdh5.3.6/bin/../../hbase does not exist! HBase imports will fail. Please set $HBASE_HOME to the root of your HBase installation. Warning: /opt/cdh-5.3.6/sqoop-1.4.5-cdh5.3.6/bin/../../hcatalog does not exist! HCatalog jobs will fail. Please set $HCAT_HOME to the root of your HCatalog installation. Warning: /opt/cdh-5.3.6/sqoop-1.4.5-cdh5.3.6/bin/../../accumulo does not exist! Accumulo imports will fail. Please set $ACCUMULO_HOME to the root of your Accumulo installation. Warning: /opt/cdh-5.3.6/sqoop-1.4.5-cdh5.3.6/bin/../../zookeeper does not exist! Accumulo imports will fail. Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation. 19/05/06 15:32:51 INFO sqoop.Sqoop: Running Sqoop version: 1.4.5-cdh5.3.6 19/05/06 15:32:51 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 19/05/06 15:32:51 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. information_schema metadata metastore mysql performance_schema test
转自:https://www.cnblogs.com/weiyiming007/p/10820005.html