分享

sqoop2系统入门之9之管理员指南篇:Spoop Tool使用介绍

oover 2017-9-12 17:03:23 发表于 连载型 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 1 10849
问题导读
1.Sqoop校验工具如何使用?
2.Sqoop Upgrade工具的用法?
3.Sqoop RepositoryDump工具的用法?
4. Sqoop RepositoryLoad 的应用场景?
5. Sqoop RepositoryEncryption 如何对数据进行加密?





1.概述
        Sqoop tool提供了一些供管理员在Sqoop Server上执行的管理命令,使用这些命令,管理员可以完成一些维护工作。 这些工具命令会根据相应的参数执行不同的维护操作,并且在一定的时间内执行完,而不是以服务的形式长期运行。               为了成功执行每个工具所支持的维护任务,这些工具需要在与Sqoop Server相同的环境下执行。此外,需要设置CLASSPATH和其它所需的环境变量,才能正确的执行Sqoop tool对应的可执行文件。这些配置在不同的Hadoop发型版本中,一般都是自动配置好的(比如: Apache Bigtop) 。执行Sqoop tool命令时,需要用运行Sqoop Server服务所对应的系统用户执行。
       可用的Sqoop工具包括:
  • verify
  • upgrade
       执行时,需要在参数中指定使用的工具名称,来执行不同的工具命令,如要使用Sqoop verify工具,可以使用如下命令:      [mw_shl_code=shell,true]sqoop2-tool verify[/mw_shl_code]
      注意: 如果Sqoop Server服务正在运行的时候,使用Sqoop tool相关的命令,可能会导致数据冲突或者服务挂掉,因此使用Sqoop tool之前最好先停掉Sqoop Server服务。

2. Sqoop Verify验证工具
        Sqoop verify验证工具会通过启动所有的子系统来验证Sqoop Server配置的正确性,并将异常的配置项标注出来。                使用验证工具的命令为:
       [mw_shl_code=bash,true]sqoop2-tool verify[/mw_shl_code]
       如果验证进程执行成功了,用户将会看到类似下面的信息:
Verification was successful.
Tool class org.apache.sqoop.tools.tool.VerifyTool has finished correctly

      如果验证进程发现任何有问题的配置项,就会输出如下信息:
Verification has failed, please check Server logs for further details.
Tool class org.apache.sqoop.tools.tool.VerifyTool has failed.

     验证失败的详细信息通过日志记录在了Sqoop server服务的log中。

3. Sqoop Upgrade升级工具
        Sqoop 升级工具可以将Sqoop2的所有内部组件都升级,包括了库中数据结构和存储元数据,都会一并升级。在刚升级的Sqoop部署环境中进行升级操作,将不会有任何影响(因为已经是最新版本了)。
       运行升级工具的命令为:
[mw_shl_code=bash,true]sqoop2-tool upgrade[/mw_shl_code]
       升级成功后,会看到下面的信息:
Tool class org.apache.sqoop.tools.tool.UpgradeTool has finished correctly.

      若升级失败,会看到:
Tool class org.apache.sqoop.tools.tool.UpgradeTool has failed.

     升级失败更详细的信息可以查看Sqoop Server日志。

4. Sqoop RepositoryDump导出工具
       Sqoop ReposityDump工具可以将用户创建的Sqoop 仓储元数据导出成Json格式,包括 连接信息,job信息以及job的提交信息。
       使用repositorydump工具的命令为:
   [mw_shl_code=bash,true]sqoop2-tool repositorydump -o repository.json[/mw_shl_code]
        数据库的连接密码等敏感信息,也可以由用户选择是否导出,导出命令为:
[mw_shl_code=bash,true]sqoop2-tool repositorydump -o repository.json --include-sensitive[/mw_shl_code]
       上述命令执行成功后,将会看到如下输出:
Tool class org.apache.sqoop.tools.tool.RepositoryDumpTool has finished correctly.

     如果上面的命令执行失败,将会输出:
Tool class org.apache.sqoop.tools.tool.RepositoryDumpTool has failed.

     更加详细的错误信息记录在了Sqoop Server日志里。

5. Sqoop RepositoryLoad导入工具
       RepositoryLoad工具与RepositoryDump相反,它可以将RepositoryDump导出的Json文件信息重新导入到Sqoop 仓储元数据中。
       RepositoryLoad使用命令为:
        [mw_shl_code=bash,true]sqoop2-tool repositoryload -i repository.json[/mw_shl_code]
       上述命令导入成功后,可以看到如下输出信息:
Tool class org.apache.sqoop.tools.tool.RepositoryLoadTool has finished correctly.

     若导入失败,则会看到如下输出:
Tool class org.apache.sqoop.tools.tool.RepositoryLoadTool has failed.

     或者是一些异常信息,更加详细的错误信息记录在Sqoop Server日志中。
       注意: 1. 如果Sqoop 导出的仓储数据创建的时候是没有设置密码的(默认是没有密码的),那么连接信息就不会包含密码,并且job提交的时候就会执行失败。这种情况下,需要用户手动更新连接信息并设置密码。
                2. RepositoryLoad 工具会覆盖掉原有的连接信息,Job信息以及提交信息。

6. Sqoop RepositoryEncryption 加密工具
        想进一步了解仓储元数据加密,请阅读Repository Encryption 。            
        有时,我们想要修改数据加密的密码,为已经存在的密码重新生成一个新的key,加密一个已经存在却没有加密的仓储数据,或者解密一个仓储数据,这些场景下,Sqoop2提供了Repository Encryption Tool可以帮助我们满足这些要求。
        在使用Sqoop加密工具前,需要先停掉Sqoop2 Server。
        加密工具做的所有操作都会当做一个事务来完成,避免仓储数据的不一致状态。
        Repository Encryption Tool加密工具会读取相关的加密配置文件,加密配置项中以 -F开头的选项,表示已经存在的仓储数据状态,以-T开头的配置项,为想要使用的新的仓储数据状态。如果这些参数其中的一个参数没有配置,就表示不加密。

6.1 修改密码
    如果要修改密码,用户需要指定当前的配置项,包括原密码以及新的配置项和新密码,参考命令如下:
[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption \
    -Forg.apache.sqoop.security.repo_encryption.password=old_password \
    -Forg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Forg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Forg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000 \
    -Torg.apache.sqoop.security.repo_encryption.password=new_password \
    -Torg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Torg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Torg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000[/mw_shl_code]
  
6.2 为已有的密码生成一个新的Key
    产生一个新key的命令跟修改密码类似,具体参考命令如下:
[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption \
    -Forg.apache.sqoop.security.repo_encryption.password=password \
    -Forg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Forg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Forg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000 \
    -Torg.apache.sqoop.security.repo_encryption.password=password \
    -Torg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Torg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Torg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000[/mw_shl_code]

       也可以使用更简洁的命令:
[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption -FuseConf -TuseConf[/mw_shl_code]

       上述命令中的 useConf选项会读取已经存在的Sqoop配置文件,并将这些配置项应用到这个命令当中。  

6.3 加密一个未经加密的仓储数据
      加密未经加密的仓储数据命令为:

[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption \
    -Torg.apache.sqoop.security.repo_encryption.password=password \
    -Torg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Torg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Torg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Torg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000[/mw_shl_code]

      如果加密相关的配置项已经在Sqoop配置文件中存在,则可以简化命令为:

[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption -TuseConf[/mw_shl_code]

6.4 解密一个已经加密的仓储数据
    在使用Sqoop加密工具前,需要先停掉Sqoop2 Server。解密命令为:

[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption \
    -Forg.apache.sqoop.security.repo_encryption.password=password \
    -Forg.apache.sqoop.security.repo_encryption.hmac_algorithm=HmacSHA256 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_algorithm=AES \
    -Forg.apache.sqoop.security.repo_encryption.cipher_key_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.cipher_spec=AES/CBC/PKCS5Padding \
    -Forg.apache.sqoop.security.repo_encryption.initialization_vector_size=16 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_algorithm=PBKDF2WithHmacSHA1 \
    -Forg.apache.sqoop.security.repo_encryption.pbkdf2_rounds=4000[/mw_shl_code]

       如果加密相关的参数配置存在于Sqoop配置文件中,则可简化命令为:
[mw_shl_code=bash,true]sqoop.sh tool repositoryencryption -FuseConf[/mw_shl_code]

7.结束语
   这篇博客简单介绍了Sqoop Tool的使用方法,如在使用和学子中遇到什么,欢迎留言沟通!


作者:Macor
英文出处:http://sqoop.apache.org/docs/1.99.7/admin/Tools.html





相关篇章


sqoop2系统入门之1:用户指南5分钟入门Demo
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22549


sqoop2系统入门之2汇总:用户指南shell命令【可收藏备查】
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22602



sqoop2系统入门之3:用户指南通用JDBC连接器
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22563


sqoop2系统入门之4:用户指南HDFS 连接器
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22564


sqoop2系统入门之5:用户指南Kafka 连接器
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22565


sqoop2系统入门之6之开发指南篇:Sqoop Java 客户端API指南
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22619


sqoop2系统入门之7之开发指南篇:编译Sqoop2源码
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22647


sqoop2系统入门之8之开发指南篇:Sqoop 2开发环境配置
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22659


sqoop2系统入门之9之管理员指南篇:Spoop Tool使用介绍
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22698


sqoop2系统入门之10之管理员指南篇:Spoop2升级
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22705


sqoop2系统入门之11之管理员指南篇:Sqoop安装
http://www.aboutyun.com/forum.php?mod=viewthread&tid=22709



本帖被以下淘专辑推荐:

已有(1)人评论

跳转到指定楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条