Cluster MySQL Project1.1 2011
Cluster MySQL Project1.1 2011
(2) UB MySQL Cluster Configuration Type Management Node SQL Node Data Node Client Node Hostname ps3cluster1 ps3cluster2 ps3cluster3 ps3cluster4 ps3cluster5 ps3cluster6 Oxford IP 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5 192.168.1.6 192.168.1.21
Managing MySQL cluster Connecting MySQL cluster Storing data/index Storing data/index Storing data/index Storing data/index Client
(3) Login - Connect to Oxford (Front node) from UB network # ssh [USER_Name]@216.87.XXX.XXX [USER_Name]@216.87.XXX.XXX's password: [USER_Name@oxford ~]$ - Connect to SQL node (ps3cluster2) from the front node # mysql -h 192.168.1.2 -u [YOUR_DB_USER_NAME] p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version: 5.1.41-ndb-7.0.13 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> - Your DB_USER_NAME and default password is: Name Alcide, Jovenky Ali, Muhammad Chen, Yue Elleithy, Yasser K. Elmannai, Wafa M. Goldschmidt, Kathleen O. Lang, Yufei Li, Bo Patel, Hardik A. Patel, Hiren R. Sharma, Malabika Zhu, Yong DB USER NAME jalcide muhammaa chenyue yelleith welmanna kgoldsch ylang boli patel93 patel85 malabiks yongzhu DB PASSWORD jalcide muhammaa chenyue yelleith welmanna kgoldsch ylang boli patel93 patel85 malabiks yongzhu Database db_ db_ db_ db_ jalcide muhammaa chenyue yelleith Tablespace ddb_ts1 ddb_ts2 ddb_ts3 ddb_ts4 ddb_ts5 ddb_ts6 ddb_ts7 ddb_ts8 ddb_ts9 ddb_ts10 ddb_ts11 ddb_ts12
db_ welmanna db_ kgoldsch db_ ylang db_boli db_patel93 db_patel85 db_malabiks db_ yongzhu
(4) Connect to Database db_[USER NAME] - replace [USER NAME] by your user name, i.e., db_jelee for jelee, db_jalcide for jalcide, and so on mysql> use db_ [USER_NAME]; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed (5) Basic Commends; mysql> show databases; mysql> show tables; To get more information about MySQL commends; 1. MySQL reference manual at http://www.mysql.com
2. Googling 3. Book I suggest number 2. (6) Creating Table - Create City table for ndbcluster mysql> create table city ( -> id int(11) not null auto_increment, -> name char(35) not null, -> countrycode char(3), -> district char(20), -> population int(11), -> primary key (id)) -> engine=ndbcluster; - Insert sample data into City table mysql> INSERT INTO city VALUES (1,'Kabul','AFG','Kabol',1780000); mysql> INSERT INTO city VALUES (2,'Qandahar','AFG','Qandahar',237500); mysql> INSERT INTO city VALUES (3,'Herat','AFG','Herat',186800); mysql> commit; - To run SQL script # vi cr_city.sql -- Add the following SQL DROP TABLE IF EXISTS city; create table city ( id int(11) not null auto_increment, name char(35) not null, countrycode char(3), district char(20), population int(11), primary key (id)) engine=ndbcluster; INSERT INTO city VALUES (1,'Kabul','AFG','Kabol',1780000); INSERT INTO city VALUES (2,'Qandahar','AFG','Qandahar',237500); INSERT INTO city VALUES (3,'Herat','AFG','Herat',186800); commit; mysql> source cr_city.sql OR mysql> \. cr_city.sql OR # mysql u [DB_USER_NAME] p db_[USER NAME] < cr_city.sql (7) Create Disk Data Tables - Basically, MySQL cluster creates both index and table in MEMORY. However, since MySQL 5.1.6 support Disk Data Tables. - Create Disk Data Table dt_[USER NAME] on Tablespace ddb_ts#
- Each user account has own Tablespace name, i.e., db_ts1 ~ 12. Check the table above. mysql> -> -> -> -> -> -> -> -> create table dt_[USER NAME] ( member_id int not null auto_increment primary key, last_name varchar(50), first_name varchar(50), dob date, joined date, index(last_name, first_name)) tablespace ddb_ts# storage disk engine ndbcluster;
(8) Partitioning - Create Partitioned Table in NDBCLUSTER mysql> -> -> -> -> mysql> -> -> -> -> create table ti_[USER NAME] (id int not null primary key, name varchar(20)) ENGINE=NDBCLUSTER PARTITION BY KEY() PARTITIONS 4; insert into ti_[USER NAME] values (1,'a'), (2,'b'), (3,'c'), (4,'d');
mysql> commit; mysql> EXPLAIN PARTITIONS SELECT * FROM ti_[USER NAME]; +----+-------------+-------+-------------+------+---------------+-----+---------+------+------+-------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------------+------+---------------+-----+---------+------+------+-------+ | 1 | SIMPLE | ti | p0,p1,p2,p3 | ALL | NULL | NULL | NULL | NULL | 4 | | +----+-------------+-------+-------------+------+---------------+-----+---------+------+------+-------+
For more information about Partitioning at Page 578 (Reference manual 5.5.2) Your project 2 mission is the next page:
db_ welmanna db_ kgoldsch db_ ylang db_boli db_patel93 db_patel85 db_malabiks db_ yongzhu
(2) Create Partitioning Tables for Company Database and Inserting sample data. Primary key is underlined.
Submit your SQL files (zipped or tar archived) to submission directory, i.e., /nfs4exports/submission. # cp jelee_P2.tar /nfs4exports/submission/