sqoop使用mysql做爲metastore

<property>
    <name>sqoop.metastore.client.enable.autoconnect</name>
    <value>false</value>
    <description>If true, Sqoop will connect to a local metastore
      for job management when no other metastore arguments are
      provided.
    </description>
  </property>
  <property>
    <name>sqoop.metastore.client.autoconnect.url</name>
    <value>jdbc:mysql://<mysql-Server-IP>:<mysql-port>/sqoop?createDatabaseIfNotExist=true</value>
  </property>
  <property>
    <name>sqoop.metastore.client.autoconnect.username</name>
    <value>sqoop</value>
  </property>
  <property>
    <name>sqoop.metastore.client.autoconnect.password</name>
    <value>sqoop</value>
  </property>

CREATE TABLE SQOOP_ROOT (
    version INT, 
    propname VARCHAR(128) NOT NULL,
    propval VARCHAR(256),
    CONSTRAINT SQOOP_ROOT_unq UNIQUE (version, propname)
);
-- Inserted the following row (** this did the trick)
INSERT INTO 
    SQOOP_ROOT 
VALUES(
    NULL,
    'sqoop.hsqldb.job.storage.version',
    '0'
);


#增量導入


sqoop job --create job3 --meta-connect 'jdbc:mysql://172.18.1.1:3306/sqoop?user=root&password=test' -- import  --connect 'jdbc:mysql://172.18.1.1:3306/test' --username 'root' --password 'test'  --table 'test1' --columns 'id,name,age'  --hive-import  --hive-table default.jnincr1   --incremental append --check-column 'id' --last-value 0


sqoop job --meta-connect 'jdbc:mysql://172.18.1.1:3306/sqoop?user=root&password=test'  --list


sqoop job --meta-connect 'jdbc:mysql://172.18.1.1:3306/sqoop?user=root&password=test' --exec job3   --  --username root --password test --append 


sqoop job --create job3 --meta-connect 'jdbc:hsqldb:hsql://172.18.1.1:16000/sqoop' -- import  --connect 'jdbc:mysql://172.18.1.1:3306/test' --username 'root' --password '123456'  --table 'test_001' --columns 'id,name'  --hive-import  --hive-table default.a3   --incremental append --check-column 'id' --last-value 0


sqoop job --meta-connect 'jdbc:hsqldb:hsql://172.18.1.1:16000/sqoop'  --exec job3  -verbose


此方法需要修改sqoop源碼,解決事務鎖表問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章