search

sqoop使用

Jun 07, 2016 pm 03:54 PM
hadoopusetoolimportant

sqoop 是进出hadoop的重要工具。 用sqoop从RDBMS中导入数据 sqoop import \ -D oozie.job.id=$wf_job_id \ -- 自定义参数 oozie 相关 -D mapred.job.queue.name=$mapred_job_queue_name \ -- 自定义参数 oozie 相关 --connect $data_db_url \ --RDMS jdbc地

sqoop 是进出hadoop的重要工具。

用sqoop从RDBMS中导入数据

sqoop import \
-D oozie.job.id=$wf_job_id \ -- 自定义参数 oozie 相关

-D mapred.job.queue.name=$mapred_job_queue_name \ -- 自定义参数 oozie 相关

--connect $data_db_url \ --RDMS jdbc地址
--username $data_db_username \ -RDBMS用户名
--password $data_db_password \ -RDBMS密码
--table $db_table \ -- RDBMS 表名
--columns $db_columns \ --导入字段,及其顺序
--verbose \
--target-dir $hdfs_target_dir \ ---HDFS目标文件夹
--fields-terminated-by '\001' \ ---字段分隔字符
--lines-terminated-by '\n' \ --- 行分隔字符
--hive-table $data_db_name.$hive_table \ --- hive表名
-m $parallel_count \ ---使用并发
--hive-import \ -- 使用hive开关
--hive-overwrite \ -- 是否覆盖写
--null-string '\\N' \ --空字段表示
--null-non-string '\\N' \
--hive-drop-import-delims

用sqoop 从 hadoop向RDBMS推送数据

使用 insert overwrite directory OOOO select * from XXXX; 将表XXXX 转换格式并导入HDFS中,准备推送

sqoop export \
-D oozie.job.id=$wf_job_id \
-D mapred.job.queue.name=$mapred_job_queue_name \
-D mapred.task.timeout=0 \
--connect $data_db_url \
--username $data_db_username \
--password $data_db_password \
--table ${table_name}_insert \
--export-dir $insert_dir \ --目标文件夹

--columns $db_columns \ --输出字段顺序(用于数据对其,非常重要)
--input-null-string '\\N' \
--input-null-non-string '\\N' \
--input-fields-terminated-by '\001' \ -- 字段隔离符号
-m ${parallel_count} \ 并发数量

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools