当前位置:网站首页>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
边栏推荐
- Redis快速入门
- Kernel link script parsing
- Interpretation of Flink source code (II): Interpretation of jobgraph source code
- 【ASM】字节码操作 ClassWriter 类介绍与使用
- [introduction to MySQL] third, common data types in MySQL
- MySQL Advanced (index, view, stored procedures, functions, Change password)
- Openharmony developer documentation open source project
- Xin'an Second Edition: Chapter 12 network security audit technology principle and application learning notes
- [getting started with MySQL] fourth, explore operators in MySQL with Kiko
- Development and practice of lightweight planning service tools
猜你喜欢
How does wechat prevent withdrawal come true?
Uipath browser performs actions in the new tab
C# WinForm系列-Button简单使用
网络分层概念及基本知识
Huawei certified cloud computing hica
05 personal R & D products and promotion - data synchronization tool
Case: check the empty field [annotation + reflection + custom exception]
Deploy flask project based on LNMP
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias
Spark calculation operator and some small details in liunx
随机推荐
应用服务配置器(定时,数据库备份,文件备份,异地备份)
Final review of information and network security (based on the key points given by the teacher)
02个人研发的产品及推广-短信平台
C # nanoframework lighting and key esp32
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
[CISCN 2021 华南赛区]rsa Writeup
基于LNMP部署flask项目
轻量级计划服务工具研发与实践
[ASM] introduction and use of bytecode operation classwriter class
MySQL advanced (index, view, stored procedure, function, password modification)
自动化运维利器-Ansible-Playbook
February database ranking: how long can Oracle remain the first?
[VNCTF 2022]ezmath wp
【MMdetection】一文解决安装问题
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
OpenCV中如何使用滚动条动态调整参数
How uipath determines that an object is null
The art of Engineering
BearPi-HM_ Nano development environment
Vscode replaces commas, or specific characters with newlines