Distributed Database Implementation with MySQL and DB2 as its underlying DBMS
Instance ID | OS | DBMS | Number |
---|---|---|---|
MySQL # | Red Hat 4.1.2 | MySQL 5.0.45 | 4 |
DB2 # | openSUSE 4.1.2 | DB2 Express-C 9.7.1 | 4 |
# useradd <user name>
# usermod -d /mnt/home/<user name> -m <user name>
/mnt
directory
Stop MySQL
# service mysqld stopChange the
/etc/my.cnf
configuration file: datadir=/var/lib/mysql => /mnt/var/lib/mysql :Regenerate the system tables
# mysql_install_dbRestart MySQL
# service mysqld start
mysql> create user <user name>
mysql-connector-java-5.1.12-bin.jar
node1
with the connectorcreate database
command
node1
is used as both the catalog node and a data node
mysql> create database <database name>
mysql> grant all on <database name>.* to <user name>
config.txt:
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421 numnodes=4 node1.driver=com.mysql.jdbc.Driver node1.hostname=jdbc:mysql://localhost:3306/mydb1 node1.username=mysqlinst1 node1.passwd=ics421 node2.driver=com.mysql.jdbc.Driver node2.hostname=jdbc:mysql://10.212.133.242:3306/mydb2 node2.username=mysqlinst2 node2.passwd=ics421 node3.driver=com.mysql.jdbc.Driver node3.hostname=jdbc:mysql://10.245.210.70:3306/mydb3 node3.username=mysqlinst3 node3.passwd=ics421 node4.driver=com.mysql.jdbc.Driver node4.hostname=jdbc:mysql://10.245.221.220:3306/mydb4 node4.username=mysqlinst4 node4.passwd=ics421sql.txt:
CREATE TABLE Detection ( objID BIGINT NOT NULL, detectID BIGINT NOT NULL, filterID SMALLINT NOT NULL, imageID BIGINT NOT NULL, obsTime FLOAT NOT NULL DEFAULT -999, raObs FLOAT NOT NULL DEFAULT -999, decObs FLOAT NOT NULL DEFAULT -999, mag REAL NOT NULL DEFAULT -999, sky REAL NOT NULL DEFAULT -999, sgSep REAL NOT NULL DEFAULT -999 ) ; CREATE TABLE Object ( objID BIGINT NOT NULL, htmID BIGINT NOT NULL, zoneID INT NOT NULL, ra FLOAT NOT NULL, de FLOAT NOT NULL, cx FLOAT NOT NULL, cy FLOAT NOT NULL, cz FLOAT NOT NULL, lambda FLOAT NOT NULL DEFAULT -999, beta FLOAT NOT NULL DEFAULT -999, l FLOAT NOT NULL DEFAULT -999, b FLOAT NOT NULL DEFAULT -999, lsg FLOAT NOT NULL DEFAULT -999, bsg FLOAT NOT NULL DEFAULT -999, gMagBest REAL NOT NULL DEFAULT -999, rMagBest REAL NOT NULL DEFAULT -999, iMagBest REAL NOT NULL DEFAULT -999, zMagBest REAL NOT NULL DEFAULT -999, yMagBest REAL NOT NULL DEFAULT -999, grColor REAL NOT NULL DEFAULT -999, riColor REAL NOT NULL DEFAULT -999, izColor REAL NOT NULL DEFAULT -999, zyColor REAL NOT NULL DEFAULT -999, sgSep REAL NOT NULL DEFAULT -999 )
# sshfs db2inst1@ip-10-245-189-242:/mnt/astronomy </path/to/a/local/directory>
for every .gz file f in directory gunzip f load_into_target_table(f) gzip f end for load_into_target_table(file f): load data local infile '/path/to/the/file/0000001.obj.csv' into table Object fields terminated by ',' optionally enclosed by '"' lines terminated by '\n';
db2inst1
is already createddb2inst1
is already created
db2 => create database <database name> on path/to/the/100GB/directory/datadir
db2-jcc.jar
node1
with the connectorcreate database
command
node1
is used as both the catalog node and a data node
config.txt:
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=mysqlinst1 catalog.passwd=ics421 numnodes=4 node1.driver=com.ibm.db2.jcc.DB2Driver node1.hostname=jdbc:db2://localhost:50001/mydb1 node1.username=db2inst1 node1.passwd=ics421 node2.driver=com.ibm.db2.jcc.DB2Driver node2.hostname=jdbc:db2://10.195.47.21:50001/mydb2 node2.username=db2inst1 node2.passwd=ics421 node3.driver=com.ibm.db2.jcc.DB2Driver node3.hostname=jdbc:db2://10.195.11.198:50001/mydb3 node3.username=db2inst1 node3.passwd=ics421 node4.driver=com.ibm.db2.jcc.DB2Driver node4.hostname=jdbc:db2://10.195.11.193:50001/mydb4 node4.username=db2inst1 node4.passwd=ics421sql.txt:
CREATE TABLE Detection ( objID BIGINT NOT NULL, detectID BIGINT NOT NULL, filterID SMALLINT NOT NULL, imageID BIGINT NOT NULL, obsTime FLOAT NOT NULL DEFAULT -999, raObs FLOAT NOT NULL DEFAULT -999, decObs FLOAT NOT NULL DEFAULT -999, mag REAL NOT NULL DEFAULT -999, sky REAL NOT NULL DEFAULT -999, sgSep REAL NOT NULL DEFAULT -999 ) COMPRESS YES NOT LOGGED INITIALLY; CREATE TABLE Object ( objID BIGINT NOT NULL PRIMARY KEY, htmID BIGINT NOT NULL, zoneID INT NOT NULL, ra DOUBLE NOT NULL, de DOUBLE NOT NULL, cx DOUBLE NOT NULL, cy DOUBLE NOT NULL, cz DOUBLE NOT NULL, lambda FLOAT NOT NULL DEFAULT -999, beta FLOAT NOT NULL DEFAULT -999, l FLOAT NOT NULL DEFAULT -999, b FLOAT NOT NULL DEFAULT -999, lsg FLOAT NOT NULL DEFAULT -999, bsg FLOAT NOT NULL DEFAULT -999, gMagBest REAL NOT NULL DEFAULT -999, rMagBest REAL NOT NULL DEFAULT -999, iMagBest REAL NOT NULL DEFAULT -999, zMagBest REAL NOT NULL DEFAULT -999, yMagBest REAL NOT NULL DEFAULT -999, grColor REAL NOT NULL DEFAULT -999, riColor REAL NOT NULL DEFAULT -999, izColor REAL NOT NULL DEFAULT -999, zyColor REAL NOT NULL DEFAULT -999, sgSep REAL NOT NULL DEFAULT -999 ) COMPRESS YES NOT LOGGED INITIALLY;
# scp db2inst1@10.245.189.242:path/on/the/remote/drive path/to/the/local/folder
for every .gz file f in directory gunzip f db2 connect to <database name> user <user name> using <password> load_into_target_table(f) gzip f end for load_into_target_table(file f): db2 load from <file path> of del insert into <table name>
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
select count(*) from object;
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE (O.zoneid BETWEEN FLOOR((90.0 + ( +0.5) - ( 1.0/60.0))/0.008333) AND FLOOR((90.0 + ( +0.5) + ( 1.0/60.0))/0.008333)) AND ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE (O.zoneid BETWEEN FLOOR((90.0 + ( +0.5) - ( 1.0/60.0))/0.008333) AND FLOOR((90.0 + ( +0.5) + ( 1.0/60.0))/0.008333)) AND ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
for i from 0 to 99 execute: (time ./run.sh config.txt sql.txt > /dev/null) 2>&1 | grep real
MySQL (s) DB2 (s) 0 45.558 56.925 1 45.876 59.460 2 45.936 58.074 3 46.024 54.029 4 48.336 56.999 5 48.636 52.168 : : : <snip> <snip> <snip> : : : 96 47.516 52.349 97 48.452 55.929 98 49.485 58.173 99 49.520 59.229 Average 48.647 56.490 Minimum 45.558 51.870 Maximum 51.432 59.779
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE (O.zoneid BETWEEN FLOOR((90.0 + ( +0.5) - ( 1.0/60.0))/0.008333) AND FLOOR((90.0 + ( +0.5) + ( 1.0/60.0))/0.008333)) AND ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
for i from 0 to 99 execute: (time ./run.sh config.txt sql.txt > /dev/null) 2>&1 | grep real
MySQL (s) DB2 (s) 0 3.338 13.809 1 3.310 13.029 2 3.234 13.269 3 3.402 14.131 4 3.233 13.164 5 3.054 12.551 : : : <snip> <snip> <snip> : : : 96 3.254 13.134 97 3.089 12.991 98 3.238 13.052 99 3.134 13.146 Average 3.252 13.287 Minimum 3.053 11.936 Maximum 3.402 13.871
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT O.objID, O.ra, O.de, O.htmid, O.zoneid FROM Object O WHERE (O.ra BETWEEN ((67.5)-( 1.0/60.0)) AND ((67.5)+( 1.0/60.0))) AND (O.de BETWEEN (( +0.5)-( 1.0/60.0)) AND (( +0.5)+( 1.0/60.0))) AND ( SIN(RADIANS(O.de)) * SIN(RADIANS( +0.5)) + COS(RADIANS(O.de)) * COS(RADIANS( +0.5)) * COS(RADIANS((O.ra) - (67.5))) ) >= COS(RADIANS( 1.0/60.0));
for i from 0 to 99 execute: (time ./run.sh config.txt sql.txt > /dev/null) 2>&1 | grep real
MySQL (s) DB2 (s) 0 1.296 5.750 1 1.354 5.540 2 1.337 5.624 3 1.354 5.683 4 1.317 5.349 5 1.354 5.729 : : : <snip> <snip> <snip> : : : 96 1.334 6.167 97 1.365 5.856 98 1.380 6.563 99 1.372 5.661 Average 1.296 5.534 Minimum 1.059 4.778 Maximum 1.410 6.827
catalog.driver=com.mysql.jdbc.Driver catalog.hostname=jdbc:mysql://localhost:3306/catalog catalog.username=mysqlinst1 catalog.passwd=ics421
catalog.driver=com.ibm.db2.jcc.DB2Driver catalog.hostname=jdbc:db2://localhost:50001/catalog catalog.username=db2inst1 catalog.passwd=ics421
SELECT count (*) from Object;
for i from 0 to 99 execute: (time ./run.sh config.txt sql.txt > /dev/null) 2>&1 | grep real
MySQL (s) DB2 (s) 0 1.324 9.057 1 1.218 9.917 2 1.206 9.253 3 1.209 9.608 4 1.081 9.790 5 1.258 9.624 : : : <snip> <snip> <snip> : : : 96 1.306 9.224 97 1.206 9.409 98 1.269 9.345 99 1.282 9.745 Average 1.195 9.420 Minimum 0.978 8.957 Maximum 1.333 10.317