phoenix and hbase table migration

Sometimes due to communication problems during work, the names of newly-created tables in phoenix and hbase import data to the table are not the same, and it is necessary to change the name of the table with data to the name of the online table.

Idea: Use snapshots to migrate tables with data to phoenix tables for online use in hbase

Disable the old table first, and
disable 'temp:old_table'
then back up the old table as a snapshot.
snapshot 'temp:old_table', 'tableSnapshot'
Clone the snapshot data to the new table (note: the new table cannot be created first, if it already exists, an error will be reported).
clone_snapshot 'tableSnapshot', 'temp:new_table'
Check whether the new table data is the same as the old table data (the number of records) and
count 'temp:old_table'
scan 'temp:old_table'
then delete it. Snapshot
delete_snapshot 'tableSnapshot'
Delete the old table data
drop 'temp:old_table'
and create a new table with the same name as hbase in phoenix (note: you must first migrate the hbase table and then create a new phoenix to map, otherwise an error will be reported when you do aggregation)

CREATE TABLE IF NOT EXISTS temp:new_table (
      error_code VARCHAR NOT NULL,
      error_name VARCHAR NOT NULL,
      error_type VARCHAR NOT NULL,
      content VARCHAR NOT NULL
      CONSTRAINT my_pk PRIMARY KEY (error_code, error_name,error_type,content));

Guess you like

Origin blog.csdn.net/lz6363/article/details/105962422