Consistency checking
Learn about consistency checking.
nz_md5_qsum data checksum utility
The nz_md5_qsum command computes a unique checksum for a query against a
table. The command provides a convenient way to compare data across nodes to determine whether the
contents of the tables are in sync. Use the utility when the _v_replication_sync
view shows that the subordinate applied all committed transactions from the primary, indicating that
the nodes are in sync.
SYSTEM
database. The input for the utility is a SELECT
statement.SELECT <col_list> FROM <database>..<user_table>[WHERE ...]
The
WHERE
clause is optional. The user table that you supply to the
SELECT
query might have a maximum of 64 columns.Example:
SELECT nz_md5_qsum ('SELECT * FROM test..table1');
Column name | Data type | Value |
---|---|---|
DATASUM | char(32) | 32-hex-digit checksum of the table data. |
SCHEMASUM | char(32) | 32-hex-digit checksum of the table layout. |
NUMROWS | bigint | Number of rows. |
NUMCOLS | int | Number of columns. |
Installing the nz_md5_qsum utility
You must install the nz_md5_qsum utility on both the primary and subordinates. The installer is in the following location: /nz/kit/bin/adm/tools/nzqsum.
- Run the following command:
tar xvf nz_md5_qsum.tar
- As
admin
run the installQsum.pl script with a valid user name and password. If you want to install the nz_md5_qsum utility as a non-admin user, use one extra flag-fenced=1
.Example:$ ./installQsum.pl -u testuser -pw password@123 -fenced=1 Installing QSUM to database system Done
To install this utility successfully as a non-admin user, you must have the following minimum permissions.
Use this SQL commands to grant all these permissions:YSTEM.ADMIN(ADMIN)=> \dpu testuser User object permissions for user 'TESTUSER' Database Name | Schema Name | Object Name | L S I U D T L A D B L G O E C R X A | D G U S T E X Q Y V M I B R C S H F A L P N S R ---------------+-------------+-------------+-------------------------------------+------------------------------------------------- GLOBAL | GLOBAL | TABLE | X X | GLOBAL | GLOBAL | PROCEDURE | X | GLOBAL | GLOBAL | GLOBAL | | X X X X X X (3 rows) Object Privileges (L)ist (S)elect (I)nsert (U)pdate (D)elete (T)runcate (L)ock (A)lter (D)rop a(B)ort (L)oad (G)enstats Gr(O)om (E)xecute Label-A(C)cess Label-(R)estrict Label-E(X)pand Execute-(A)s Administration Privilege (D)atabase (G)roup/Role (U)ser (S)chema (T)able T(E)mp E(X)ternal Se(Q)uence S(Y)nonym (V)iew (M)aterialized View (I)ndex (B)ackup (R)estore va(C)uum (S)ystem (H)ardware (F)unction (A)ggregate (L)ibrary (P)rocedure U(N)fence (S)ecurity Scheduler (R)ule
\c drop user testuser; create user testuser with password 'password1'; grant create table to testuser; grant create function to testuser; grant create procedure to testuser; grant create temp table to testuser; grant create view to testuser; grant create aggregate to testuser; grant execute on procedure to testuser; grant list, select on table to testuser;
installQsum.pl script usage
Input | Description |
---|---|
-u | Specifies the user ID that is used to connect to the SYSTEM database. The default user is NZ_USER. |
-pw | Specifies the password that is used to connect to the SYSTEM database. The default password is NZ_PASSWORD. |
-uninstall | Uninstalls the utility. |
-fenced=1 | -f=1 | Installs the intermediate functions, aggregates in fenced mode. |
\c
drop database db1;
create database db1;
\c db1
create table table1(c1 int, c2 varchar(10));
insert into table1 values(1, 'asdf');
\c system testuser password1
SELECT NZ_MD5_QSUM('SELECT * FROM db1..table1');
Output:SYSTEM.ADMIN(TESTUSER)=> SELECT NZ_MD5_QSUM('SELECT * FROM db1..table1');
DATASUM | SCHEMASUM | NUMROWS | NUMCOLS
----------------------------------+----------------------------------+---------+---------
0D030E080C00090104080D0605040D0E | 060E0D09090000000808070D0A070303 | 1 | 2
(1 row)