当前位置:网站首页>Sqoop I have everything you want
Sqoop I have everything you want
2022-07-06 17:40:00 【Bald Second Senior brother】
Catalog
Sqoop brief introduction :
sqoop yes apache One of its “Hadoop And the relational database server ” Tools for .
Data import :
MySQL,Oracle Import data to Hadoop Of HDFS、HIVE、HBASE And other data storage systems
Export data :
from Hadoop Export data to relational database from the file system of mysql etc.
The configuration file :
1. Environment variable configuration
export SQOOP_HOME=/opt/module/ha/sqoop export PATH=$PATH:$SQOOP_HOME/bin
2. To configure sqoop Medium
file
hadoop,hive,hbase You can configure it if you need it
Sqoop Use
codegen
effect :
Generate code to interact with database records , Map tables in a relational database to a Java class , There are fields corresponding to each column in this class .
Example :
bin/sqoop codegen \ --connect jdbc:mysql://ljx:3306/company \ --username root \ --password 123456 \ --table staff \ --bindir /opt/module/sqoop/staff \ ### Folder needs to exist --class-name Staff \ --fields-terminated-by "\t" --outdir /opt/module/sqoop/staff ### Folder needs to exist
create-hive-table
effect :
Import table definitions Hive, Generate the... Corresponding to the table structure of the relational database hive Table structure
Example :
sqoop create-hive-table --connect jdbc:mysql://ljx:3306/sample --username root --password 123456 --table student --hive-table hive-student
eval
effect :
assessment SQL Statement and display the results , Often used in import Before the data , Get to know SQL Is the statement correct , Is the data normal , And the results can be displayed on the console .
Example :
sqoop eval --connect jdbc:mysql://ljx:3306/mysql --username root --password 123456 --query "select * from user"
export( Very important )
effect :
from HDFS( Include Hive and HBase) Export data to a relational database .
Example :
sqoop export --connect jdbc:mysql://ljx:3306/sample --username root --password 123456 --table student --export-dir /user/hive/warehous/jjj --input-fields-terminated-by "\t" -m 1
import( important )
effect :
Import tables from the database HDFS,( Include Hive,HBase) in , If the import is Hive, So when Hive When there is no corresponding table in , Automatically create .
Example : take mysql in user Import table data to hdfs in
sqoop import --connect jdbc:mysql://ljx:3306/mysql --username root --password 123456 --table user
import-all-tables
effect :
Can be RDBMS All tables in are imported into HDFS in , Each table corresponds to a HDFS Catalog
Limiting conditions :
Each table must have a single column primary key , Or designate --autoreset-to-one-mapper Parameters .
Each table can only import All columns , That is, columns cannot be specified import.
Example :
sqoop import-all-tables --connect jdbc:mysql://ljx:3306/sample --username root --password 123456 --warehouse-dir /all_table
import-mainframe
effect :
direct import host , This order is too violent , and import-all-tables Not much difference , Wait until you need to study .
job
effect :
Used to generate a sqoop Mission , It will not be executed immediately after generation , It needs to be done manually .
Example :
establish job
qoop job --create myjob -- import-all-tables --connect jdbc:mysql://ljx:3006/mysql --username root --password 123456 --warehouse-dir /user/all_user
Be careful : In the use of job To perform sqoop The instruction of needs to be in -- Add a space after
list-databases
effect :
List the available databases on the server
Example :
sqoop list-databases --connect jdbc:mysql://ljx:3306 --username root --password 123456
list-tables
effect :
List the available tables in the database
Example :
sqoop list-tables --connect jdbc:mysql://ljx:3306/mysql --username root --password 123456
merge
effect :
take HDFS The data under different directories in is merged and put into the specified directory
Example :
[[email protected] sqoop-1.4.7]$ bin/sqoop merge \ --new-data /tdata/newdata/ \ --onto /tdata/olddata/ \ --target-dir /tdata/merged \ --jar-file /opt/module/sqoop/staff/Staff.jar \ --class-name Staff \ --merge-key id
metastore
effect :
Recorded Sqoop job Metadata information , If the service is not started , So default job The storage directory of metadata is ~/.sqoop, Can be found in sqoop-site.xml Revision in China .
Example :
start-up sqoop Of metastore service
sqoop metastore
version
effect :
Display version information
Example :
sqoop version
The same thing sqoop take mysql Data transmission hive
sqoop import --connect jdbc:mysql://ljx:3306/sample --username root --password 123456 --table student --hive-import -m 1
And use import Import to hdfs Only more than --hive-import , If you want to specify hive Database and tables of can be used --hive-database And --hive-table To specify the
The same thing sqoop take mysql Data transmission hbase
sqoop import --connect jdbc:mysql://ljx:3306/mysql --username root --password 123456 --table help_keyword --hbase-table new_help_keyword --column-family person --hbase-row-key help_keyword_id
Be careful : Import time hbase The specified table should exist in
边栏推荐
- TCP connection is more than communicating with TCP protocol
- The problem of "syntax error" when uipath executes insert statement is solved
- 07个人研发的产品及推广-人力资源信息管理系统
- 04 products and promotion developed by individuals - data push tool
- OpenCV中如何使用滚动条动态调整参数
- CTF逆向入门题——掷骰子
- 02个人研发的产品及推广-短信平台
- mysql高級(索引,視圖,存儲過程,函數,修改密碼)
- Debug and run the first xv6 program
- BearPi-HM_ Nano development environment
猜你喜欢
List set data removal (list.sublist.clear)
网络分层概念及基本知识
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
Application service configurator (regular, database backup, file backup, remote backup)
About selenium starting Chrome browser flash back
Grafana 9 is officially released, which is easier to use and more cool!
04个人研发的产品及推广-数据推送工具
EasyRE WriteUp
02个人研发的产品及推广-短信平台
Vscode replaces commas, or specific characters with newlines
随机推荐
The art of Engineering (3): do not rely on each other between functions of code robustness
Connect to LAN MySQL
Grafana 9 正式发布,更易用,更酷炫了!
[ciscn 2021 South China]rsa writeup
PyTorch 提取中间层特征?
connection reset by peer
Junit单元测试
[mmdetection] solves the installation problem
mysql高級(索引,視圖,存儲過程,函數,修改密碼)
Openharmony developer documentation open source project
Detailed explanation of data types of MySQL columns
Kernel link script parsing
connection reset by peer
Hongmeng introduction and development environment construction
Flink parsing (III): memory management
【逆向】脱壳后修复IAT并关闭ASLR
Interpretation of Flink source code (I): Interpretation of streamgraph source code
Flink analysis (I): basic concept analysis
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
Redis quick start