前期准备
1、 进入客户端sqoop目录
cd /mnt/disk1/softwares/TDH-Client/sqoop
2、 拷贝ngdbc.jar包到TDH-Client/sqoop/libs目录下(ngdbc.jar可以在hana官网下载)
cp ngdbc.jar TDH-Client/sqoop/libs
Sqoop获取Hana数据命令
parameter:
hana_ip : hana数据库IP地址
hana_port : hana数据库端口
hana_users : hana数据库用户名
hana_password : hana数据库密码
-
列出表格 ./bin/sqoop list-tables –username $hana_users –password $hana_password –connect jdbc:sap://$hana_ip:hana_port/ –driver com.sap.db.jdbc.Driver
-
把数据从hana导入hdfs ./bin/sqoop import –username $name –password $pwd –connect jdbc:sap://$hana_ip:hana_port?currentschema=SYS –driver com.sap.db.jdbc.Driver –query ‘select USER_ID,USER_NAME,USER_MODE from SYS.USERS WHERE $CONDITIONS’ –delete-target-dir –target-dir=/user/sqoop/USERS –split-by USER_ID –num-mappers 1
inceptor 建立外表验证抽取到hadoop数据
1、在inceptor里建立外表 create external table hana_users ( USER_ID string, USER_NAME string, USER_MODE string ) row format delimited fields terminated by ‘,’ location ‘/user/sqoop/USERS’
通过beeline验证查询
select * from hana_users;