mysql資料匯入到hbase

來源:互聯網
上載者:User

標籤:info   oop   name   font   schema   資料庫   test   trend   type   

思路:讀取到一個資料庫裡所有的表名,然後通過sqoop迴圈匯入到hbase實現過程中發現 不會寫shell是個硬傷最後只能分兩步進行操作1.sel_tabs.sh
/usr/bin/mysql -hIp地址 -u使用者名稱 -p密碼 -D資料庫名<<EOFuse select table_name from information_schema.tables where table_schema=‘資料庫名‘ and table_type=‘base table‘;EOF

運行 bash sel_tabs.sh>tbsnam.dat

將結果寫入tbsname.dat

2.readdat.sh

#!/bin/sh    cat tbsnam.dat |while read LINEdoecho $LINEif [ "$LINE" = "table_name" ]; thenecho "table_name test"elseecho $LINEstr="/opt/dtma/sqoop/bin/sqoop import --connect jdbc:mysql://Ip地址:連接埠號碼/資料庫名稱 --username ‘使用者名稱‘ --password ‘密碼‘ --table AA --hbase-table AA --column-family f1 --hbase-row-key  id --hbase-create-table --m 1 --incremental append --check-column ‘id‘ --last-value 0"            strend=${str//"AA"/$LINE}echo $strend             $strend        fidone

str是sqoop 增量匯入單個表的 語句

上面sql語句查詢結果 第一行出現 table_name,所以把table_name 剔除掉

最後運行

bash readdat.sh

 

mysql資料匯入到hbase

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.