天天看點

Sqoop的安裝*

前提

安裝Sqoop的前提是已經具備Java和Hadoop的環境。

準備安裝包

  1. 下載下傳位址:http://mirrors.hust.edu.cn/apache/sqoop/1.4.6/

    或者​

  2. 上傳安裝包sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz到虛拟機中
  3. 解壓sqoop安裝包到指定目錄,

我解壓到/root/soft目錄下面了 ,解壓指令

[root@zjj101 soft]# tar -zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz      

重命名配置檔案

Sqoop的配置檔案與大多數大資料架構類似,在sqoop根目錄下的conf目錄中。

cd 到 /sqoop-1.4.6.bin__hadoop-2.0.4-alpha/conf 目錄下面,重命名一下配置檔案

mv sqoop-env-template.sh sqoop-env.sh      

修改sqoop-env.sh配置檔案

export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HIVE_HOME=$HIVE_HOME
export ZOOKEEPER_HOME=/opt/module/zookeeper-3.4.10
export ZOOCFGDIR=/opt/module/zookeeper-3.4.10/conf
export HBASE_HOME=/opt/module/hbase-1.3.1      

拷貝JDBC驅動

準備mysql-connector-java-5.1.27-bin.jar 拷貝到

sqoop-1.4.6.bin__hadoop-2.0.4-alpha/lib/ ,具體jar版本看你要連接配接的MySQL的版本是多少.

​​jar包下載下傳位址1積分

驗證Sqoop

在Sqoop安裝的根目錄執行 bin/sqoop help 指令驗證一下 , 出現警告資訊不要緊,隻要不是error就行.

[root@zjj101 sqoop-1.4.6.bin__hadoop-2.0.4-alpha]#  bin/sqoop help
# 這個意思是$HBASE_HOME沒配置好,我本機沒HBase,是以沒配置這個
Warning: /opt/module/hbase-1.3.1 does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
# 這個也是一樣
Warning: /root/soft/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/bin/../../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
# 這個和HBase一樣
Warning: /root/soft/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/bin/../../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /opt/module/zookeeper-3.4.10 does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
20/10/29 13:47:45 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
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.      

測試能否連接配接MySQL資料庫

[root@zjj101 sqoop-1.4.6.bin__hadoop-2.0.4-alpha]# bin/sqoop list-databases --connect jdbc:mysql://zjj101:3306/ --username root --password root
Warning: /opt/module/hbase-1.3.1 does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /root/soft/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/bin/../../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /root/soft/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/bin/../../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /opt/module/zookeeper-3.4.10 does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
20/10/29 13:51:31 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
20/10/29 13:51:31 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
# 說明連接配接MySQL了
20/10/29 13:51:32 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
hive
mysql
performance_schema
[root@zjj101 sqoop-1.4.6.bin__hadoop-2.0.4-alpha]#      

繼續閱讀