sqoop的安裝

條件  1.啓動mysql   service mysqld start     2.啓動hadoop集羣  start-all.shjava

1.下載jar包(http://mirrors.hust.edu.cn/apache/sqoop/1.4.6/mysql

2.上傳安裝包sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz到/root/目錄下sql

3.解壓數據庫

tar -zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz -C /usr/local/

3.重命名配置文件apache

在/usr/local/sqoop-1.4.6.bin__hadoop-2.0.4-alpha/conf/oop

template表明臨時文件測試

mv sqoop-env-template.sh sqoop-env.sh
mv sqoop-site-template.xml sqoop-site.xml (sqoop-site.xml若是存在的話就不用修改了)

 4.修改配置文件 (根據本身狀況進行修改)lua

vi sqoop-env.shspa

export HADOOP_COMMON_HOME= /usr/local/hadoop-2.7.3
export HADOOP_MAPRED_HOME= /usr/local/hadoop-2.7.3
export HIVE_HOME= /usr/local/hive-2.3.4
export ZOOKEEPER_HOME= /usr/local/zookeeper-3.4.10
export ZOOCFGDIR= /usr/local/zookeeper-3.4.10/conf

5.拷貝jdbc驅動code

將 mysql-connector-java-5.1.37/mysql-connector-java-8.0.11.jar 放到 sqoop的lib目錄下哦

6.配置sqoop的環境變量

vi /etc/profile

記得更新 source /etc/profile

7.驗證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
  version            Display version information
·····

8.測試sqoop是否可以成功鏈接數據庫

mysql-connector-java-5.1.37

192.168.159.110 寫本身的ip  test1 寫本身的鏈接
sqoop-list-database 
  -connect jdbc:mysql://192.168.159.110:3306/test1 --username root --password 12345

mysql-connector-java-8.0.11.jar

sqoop-list-database --connect jdbc:mysql://192.168.150.110:3306/test1?serverTimezone=Asia/Shanghai --username root --password 123456

界面

出現以下輸出:
information_schema
metastore
mysql
performance_schema

 

錯誤:

 

 

 

 

錯誤緣由:mysql沒有受權登陸

解決方法:

1.登陸mysql  mysql -uroot -p

2.use mysql;

3.更新域屬性 

update user set host='%' where user='root';

4.執行以上語句後在進行更新語句

FLUSH PRIVILEGES;

5.執行受權語句

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;

6.退出 exit;

7.再次登陸 mysql -uroot -p

相關文章
相關標籤/搜索