MySql High Availability Class Part 2

14 5 0
  • Loading ...
1/14 trang

Thông tin tài liệu

Ngày đăng: 25/11/2016, 19:09

Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates Errata Sheet for MySQL High Availability (D61920GC10) Date Generated: 27-May-10 Lesson Page 03 Details Original Lab 3-A, Step Edit the configuration file to add the log-bin option under the [mysqld] heading Close and save the configuration file le b a fer ns a r t n o [mysqld] an s log-bin=mysql-bin de binlog_format=mixed ) i m u o c G 03 Original ngserver.dent i Lab 3-A, Step Restart the MySQL p p Stu o h s his @ Revision t g n e a s Details added: zh to u c a j ( mysql se restart shell> g n n e a Original lic 03 8h Z yn Lab 3-A, Step Locate the binary log files in the datadir l c Ja Revision Details added: Revision Details added: Locate the binary log files in the datadir (/usr/local/mysql/data) 03 Original Lab 3-A, Step Perform a data change operation on a table in your database Revision Details added: mysql> INSERT INTO City VALUES -> (4990,'Kolkata','IND','Howrah',100000); MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 Original Lab 3-A, Step Use mysqlbinlog to view the contents Display the command and some other information from your previous step Revision Details added: shell> mysqlbinlog mysql-bin.000001 > abcd.txt shell> vi abcd.txt 03 Original Lab 3-A, Step View the contents of the binary log index file and verify it matches the previous step Displays a list of the two files that have been created le b a fer ns a r t n o shell> vi mysql-bin.index an s 03 Original de ) m Lab 3-A, Step Issue a PURGE MASTER LOGS command ui to delete the first o c G binary log ng dent i p p Stu o h Revision s his Details added: g@ t n e a s h to u zPURGE c mysql> MASTER LOGS to 'mysql-bin.000002'; a j e ( s g cen 03 anOriginal li Step 10 Verify the log file has actually been deleted and view the h Z Lab 3-A, n ly binary log index again c a J Revision Details added: Revision Details added: shell> vi mysql-bin.index 03 12 Original Lab 3-B, Step Setup the master using the following steps: • • • • Turn on the binary log (for the master) Set the server-id to be a unique number Create a new user with the REPLICATION SLAVE privilege Create a backup of the master that contains binary log coordinates MySQL High Availability Revision Details added: Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates shell> /etc/init.d/mysql stop shell> vi /etc/my.cnf [mysqld] log-bin=mysql-bin server-id=123 binlog_format=mixed shell> /etc/init.d/mysql start le b a fer mysql> GRANT REPLICATION SLAVE ON *.* TO -> slave @ slave_machine_ip_address IDENTIFIED -> BY sakila ; ns a r t n o mysql> QUIT; an s de ) i shell> mysqldump -uroot -p o add-drop-database m u c G lock-all-tables master-data world > t ng den databases i /tmp/dumpfile.sql p p Stu o h s his 03 12 Original @ t using the following steps: g Lab 3-B, Step 2.nSetup thee slave a s zh to u c a j (• Turnnon sethe binary log (for the slave) g n e • Set the server-id to be a unique number a c i l h • Load in the backup from the master nZ y l • Setup the binary log coordinates using the CHANGE MASTER TO Jac command • • Tell the slave where the master resides using the CHANGE MASTER TO command Start replication with SLAVE START Revision Details added: shell> /etc/init.d/mysql stop shell> vi /etc/my.cnf [mysqld] log-bin=mysql-bin server-id=200 binlog_format=mixed MySQL High Availability shell> /etc/init.d/mysql start Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates shell> scp root@master_machine_ip_address:/tmp/dumpfile.sql /tmp shell> mysql -uroot –p mysql> CHANGE MASTER TO MASTER_LOG_FILE= -> 'mysql-bin.000006', MASTER_LOG_POS=250; [Get the details for this command from the dump file above] mysql> CHANGE MASTER TO MASTER_HOST= -> master_ip_address , MASTER_USER= slave , -> MASTER_PASSWORD= sakila ; le b a fer ns a r t n o an shell> START SLAVE s de 03 12 Original ) ommasterGui Lab 3-B, Step Perform an INSERT oncthe ng dent i p p Stu Revision o h s his Details added: @ t g n e a s h toINTO u City VALUES mysql> zINSERT c a j ( -> n(5000,'Bangalore','IND','Bangalore',100000); se g n e 03 12 lic Original Z Lab 3-B, Step Verify the row was received by the slave with a SELECT yn l c Ja mysql> source /tmp/dumpfile.sql Revision Details added: mysql> SELECT * FROM City WHERE Name=’Bangalore’; 03 17 Original Lab 3-C, Step Perform an INSERT on the master server again Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('MySQL_land','AUS'); MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 17 Original Lab 3-C, Step Verify the row is not added on the slave Revision Details added: mysql> SELECT * FROM City WHERE Name=’MySQL_land’; 03 17 Original Lab 3-C, Step 13 Perform an INSERT on the master server again Revision Details added: ns a r t n 03 17 Original o n Lab 3-C, Step 14 Verify the row is added on the slave a s de ) Revision m ui o c G Details added: ng dent i p u Name=’IO_land’; tWHERE mysql> SELECT * s FROM hopCity S s @ thi g 03 18 Original n a22 Create saetable called break on the slave h u Lab 3-C, z Step ac se to j ( g cen nRevision a h Z Detailsli added: n ly c a J mysql> CREATE TABLE break (ID INT NOT NULL le b a fer mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('IO_land','USA'); -> AUTO_INCREMENT PRIMARY KEY); 03 18 Original Lab 3-C, Step 23 Create the same table on the master Revision Details added: mysql> CREATE TABLE break (ID INT NOT NULL -> AUTO_INCREMENT PRIMARY KEY); MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 18 Original Lab 3-C, Step 36 Perform an INSERT on the master Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('Bin_land','CAN'); Verify that the new record was added to the slave also: mysql> SELECT * FROM City WHERE Name=’Bin_land’; 03 19 Original Lab 3-C, Step 39 As the root user, attempt to insert a row on the slave le b a fer ns a r t Revision n o Details added: an s CountryCode) ) mysql> INSERT INTO world.City (Name, de i m u o -> VALUES ('Root_land','GBR'); g c ent G n i p tud 03 19 Original p o delete Lab 3-C, Step 39 As thesroot h user, S the row s i @ h g se t Revision han u z o c t Details added: a j ( se g n n e lic DELETE FROM world.City WHERE Name='Root_land'; mysql> Z yn 19 Original 03 l c Ja Lab 3-C, Step 41 As a non-super user, attempt to insert a row on the slave Revision Details added: As root user logged into the slave server, create the following non-super user: mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO -> 'superuser'@'localhost' IDENTIFIED BY 'abcd' -> WITH GRANT OPTION; Attempt to insert the following record: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('Root_land','GBR'); MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 22 Original Lab 3-D, Step Setup the slave as a master to the original master following the original instructions Revision Details added: ON THE CURRENT MASTER (WILL BE IDENTIFIED AS SYSTEM B) mysql> GRANT REPLICATION SLAVE ON *.* TO -> slave @ slave_machine_ip_address IDENTIFIED -> BY sakila ; le b a fer mysql> QUIT; ns a r t n o an s a e h ) ON THE CURRENT SLAVE (WILL BE IDENTIFIED uid A) om AS SYSTEM c G ng dent i shell> scp p p Stu o root@master_machine_ip_address:/tmp/dumpfile.sql /tmp h s s i @ th g–uroot n e –p shell> mysql a s h u toMASTER TO MASTER_LOG_FILE= aczCHANGE j e ( mysql> g ->ce'mysql-bin.000006', ns n a li position from the dumpfile] MASTER_LOG_POS=250; h [Get this Z n shell> mysqldump -uroot -p add-drop-database lock-all-tables master-data databases world > /tmp/dumpfile.sql ly c a J mysql> CHANGE MASTER TO -> MASTER_HOST= master_ip_address , -> MASTER_USER= slave , MASTER_PASSWORD= sakila ; mysql> START SLAVE; 03 22 Original Lab 3-D, Step Perform an INSERT on the first system, which we will call system “A” Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('OU_land','IND'); MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 22 Original Lab 3-D, Step Perform an INSERT on the second system, which we will call system “B” Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('Tin_land','CHN'); 03 22 Original Lab 3-D, Step Verify both INSERTs were successful on both systems (“A” and “B”) le b a fer ns a r t n o Perform the following SQL statement on both systems: a n s a h mysql> SELECT * FROM City WHERE )Name=’OU_land’ OR de i m u o -> Name=’Tin_land’; g c ent G n i p tud 03 22 Original p o Lab 3-D, Step Insert asnew h rowisintoS City on system “B” @ g se th n a Revision h u z o c t Details added: a j ( se g n n e lic INSERT INTO world.City (Name, CountryCode) mysql> Z -> VALUES ('BNG_land','BNG'); yn l c Ja 03 22 Original Revision Details added: Lab 3-D, Step Perform an INSERT on system “A” with the LOCK’d table Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('Col_land','SLK'); 03 22 Original Lab 3-D, Step 14 14 Delete the newly added row on system “A” Revision Details added: mysql> DELETE FROM world.City WHERE Name=’Col_land’; MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 03 23 Original Lab 3-D, Step 24 Insert a new row into City on system “A” Revision Details added: mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('CHN_land','IND'); 03 23 Original Lab 3-D, Step 26 Perform an INSERT on the system “B” with the LOCK’d table Revision Details added: le b a fer ns a r t n o 04 an Original s Lab 4-B, Step Create a new file named /var/lib/mysqlcluster/config.ini de ) i m u o c G Revision t n ngit is crucial i e p In the Oracle University classrooms, d to remain a network connection p u t o to the machines at all times original S HA lab was unacceptable because it sh The s i asked the student g to@ disconnect the system from the network The following steps h t n e a are crucial to h ensuretothat usthe students can simulate disconnecting the system from z c the network (ja nse g n1 Shut e a c down the MySQL server i l h • shell> /etc/init.d/mysql stop nZ y l c Ja Create a virtual IP address that you will use during the labs in this course mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('DEL_land','IND'); • View the details for the virtual IP that was created • shell> /labs/start_virtual_ip.sh shell> ifconfig eth0:1 Write down the inet address for this virtual IP Create a new file named /var/lib/mysqlcluster/config.ini • • shell> mkdir /var/lib/mysql-cluster shell> vi /var/lib/mysql-cluster/config.ini MySQL High Availability Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 04 Original Lab 4-B, Step Add the host name for the management server Revision hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4) 04 Original Lab 4-B, Step Add in a section for one data node Revision Add the hostname to the [NDBD] section also le b a fer [NDBD] hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4) ns a r t n o an Revision s Add the hostname to the [NDBD] section also ) de i m u o [NDBD] g c ent G n i hostname=192.168.2.1pp (Replace uIPdwith inet address obtained in step 1.4) t o h S s his 04 Original @ t g n Lab 4-B, Stepa10 Add insaesection for the MySQL server zh to u c a j ( Revision se g n n e lichostname to the [MYSQLD] section also Add the Z yn l [MYSQLD] c Ja hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4) 04 Original Lab 4-B, Step Add in a section for the second data node 04 Original Lab 4-B, Step 11 Verify you have defined everything properly Revision The config.ini file should look like the configuration below (replacing the IP with the inet address obtained in step 1.4) [NDB_MGMD] hostname=192.168.2.1 datadir=/var/lib/mysql-cluster [NDBD DEFAULT] NoOfReplicas=2 datadir=/var/lib/mysql-cluster MySQL High Availability 10 Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates [NDBD] hostname=192.168.2.1 [NDBD] hostname=192.168.2.1 [MYSQLD] hostname=192.168.2.1 04 20 Original Lab 4-G, Step Find a second machine, or find another student to work together on this set of exercises le b a fer Revision In this lab, two systems will be used to create a cluster You will need to use the virtual IP addresses for each of the systems used It is important to use the eth0:1 IP addresses ns a r t n o an View the details for the virtual IP that was created as ) h ide m • shell> ifconfig eth0:1 co t Gu g in den p p tu IP Write down the inet address virtual hofor this S s s @ thi g n e a s h u acz se to j ( 04 20 nOriginal g cen a li Step 2b Create the new config.ini defining the cluster on the system Lab h Z with4-G, n the management server ly c a J Revision Choose which machine will be the Cluster Management Server and label this machine server “A” On server “A”, edit the /var/lib/mysql-cluster/config.ini file to contain the following text: [NDB_MGMD] hostname=192.168.2.1 (Server “A” Virtual IP Address) datadir=/var/lib/mysql-cluster [NDBD DEFAULT] NoOfReplicas=2 datadir=/var/lib/mysql-cluster [NDBD] hostname=192.168.2.1 (Server “A” Virtual IP Address) MySQL High Availability 11 Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates [NDBD] hostname=190.145.45.15 [MYSQLD] hostname=192.168.2.1 [MYSQLD] hostname=190.145.45.15 04 20 (Server “B” Virtual IP Address) (Server “A” Virtual IP Address) (Server “B” Virtual IP Address) Original Lab 4-G, Step 2c Edit the /etc/my.cnf files to both point to the management server Revision On server “A”, edit the /etc/my.cnf file to include the following: le b a fer ns a r t [mysqld] n o ndbcluster an s ndb-connectstring=192.168.2.1 (Server Virtual IP Address) “A” e ) om Guid c [ndbd] t n ng (Server i e connect-string=192.168.2.1 p d “A” Virtual IP Address) p u t o sh his S [ndb_mgm] @ g se t n connect-string=192.168.2.1 (Server “A” Virtual IP Address) a h u z o ac se t j ( [ndb_mgmd] g cen nconfig-file=/var/lib/mysql-cluster/config.ini a li h nZ ly c a J On server “B”, edit the /etc/my.cnf file to include the following: [mysqld] ndbcluster ndb-connectstring=192.168.2.1 04 21 (Server “A” Virtual IP Address) Original Lab 4-G, Step 12 Restart the cluster, verify it is restarted and the data is still present Disable the network (either pull the network cable, or use ifconfig eth0 down) on the non-management server machine Revision On server “B”, disable the network by issuing the following command ONLY: shell> ifdown eth0:1 MySQL High Availability 12 Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 04 21 Original Lab 4-G, Step 14 Re-enable the network, does the node automatically rejoin? Revision On server “B”, Re-enable the network by issuing the following command shell> ifup eth0:1 04 21 Original Lab 4-G, Step 19 Disable the network (either pull the network cable, or use ifconfig eth0 down) on the non-management server machine le b a fer Revision On server “B”, disable the network by issuing the following command ONLY: ns a r t n 04 21 Original o n Lab 4-G, Step 20 Re-enable the network, does the node a automatically rejoin? s de ) m Revision ui o c G On server “B”, Re-enable the network t the following command n ngby issuing i e p p Stud o shell> ifup eth0:1 h s his @ t g 04 21 Original n e a s Lab 4-G ended zh withtoa uquestion to the student c a j ( se g n n Revision e c At thelicompletion of this lab perform the following steps Z n y l In the MySQL client, issue the following commands: Jac • mysql> DROP DATABASE world; shell> ifdown eth0:1 • • • mysql> CREATE DATABASE world; mysql> USE world; mysql> SOURCE /labs/world.sql In the NDB management client (ndb_mgm), issue the following commands: • ndb_mgm> SHUTDOWN • ndb_mgm> EXIT MySQL High Availability 13 Unauthorized reproduction or distribution prohibited Copyright© 2010, Oracle and/or its affiliates 06 14 Original Lab 6-B, step Edit the ha.cf file and perform the following actions Revision The line which states, “uncomment bcast eth0”, should use eth0:1 instead of eth0 Make the change in the ha.cf file to reflect this 06 15 Original Lab 6-B, step Edit the haresources file and perform the following action Add a line: hostname1 virtual_ip_address Revision The virtual_ip_address should be the IP address associated with eth0:1 le b a fer ns a r t n o an s de ) m Revision ui o c G On the first host machine (hostname1), connection by issuing the t ng turndeoffnnetwork following command ONLY: ppi ho is Stu s shell> ifdown eth0:1th g@ n a se u 06 16 Original zh o the first host machine (hostname1), turn on the network tOn ac Steps13 j Lab(4-G, e g cenby issuing the following command: nconnection a li h Z n ly Revision c a J On the first host machine (hostname1), turn on the network connection by issuing 06 15 Original Lab 6-B, Step 10 On the first host machine (hostname1), turn off network connection by issuing the following command: the following command: shell> ifup eth0:1 MySQL High Availability 14 [...]... Address) datadir=/var/lib /mysql- cluster [NDBD DEFAULT] NoOfReplicas =2 datadir=/var/lib /mysql- cluster [NDBD] hostname=1 92. 168 .2. 1 (Server “A” Virtual IP Address) MySQL High Availability 11 Unauthorized reproduction or distribution prohibited Copyright© 20 10, Oracle and/or its affiliates [NDBD] hostname=190.145.45.15 [MYSQLD] hostname=1 92. 168 .2. 1 [MYSQLD] hostname=190.145.45.15 04 20 (Server “B” Virtual... 1 In the MySQL client, issue the following commands: Jac • mysql> DROP DATABASE world; shell> ifdown eth0:1 • • • mysql> CREATE DATABASE world; mysql> USE world; mysql> SOURCE /labs/world.sql 2 In the NDB management client (ndb_mgm), issue the following commands: • ndb_mgm> SHUTDOWN • ndb_mgm> EXIT MySQL High Availability 13 Unauthorized reproduction or distribution prohibited Copyright© 20 10, Oracle...Unauthorized reproduction or distribution prohibited Copyright© 20 10, Oracle and/or its affiliates [NDBD] hostname=1 92. 168 .2. 1 [NDBD] hostname=1 92. 168 .2. 1 [MYSQLD] hostname=1 92. 168 .2. 1 04 20 Original Lab 4-G, Step 1 Find a second machine, or find another student to work together on this set of exercises le b a fer Revision In... [ndb_mgm] @ g se t n connect-string=1 92. 168 .2. 1 (Server “A” Virtual IP Address) a h u z o ac se t j ( [ndb_mgmd] g cen nconfig-file=/var/lib /mysql- cluster/config.ini a li h nZ ly c a J On server “B”, edit the /etc/my.cnf file to include the following: [mysqld] ndbcluster ndb-connectstring=1 92. 168 .2. 1 04 21 (Server “A” Virtual IP Address) Original Lab 4-G, Step 12 Restart the cluster, verify it is restarted... following command ONLY: shell> ifdown eth0:1 MySQL High Availability 12 Unauthorized reproduction or distribution prohibited Copyright© 20 10, Oracle and/or its affiliates 04 21 Original Lab 4-G, Step 14 Re-enable the network, does the node automatically rejoin? Revision On server “B”, Re-enable the network by issuing the following command shell> ifup eth0:1 04 21 Original Lab 4-G, Step 19 Disable the network... Virtual IP Address) Original Lab 4-G, Step 2c Edit the /etc/my.cnf files to both point to the management server Revision On server “A”, edit the /etc/my.cnf file to include the following: le b a fer ns a r t [mysqld] n o ndbcluster an s ndb-connectstring=1 92. 168 .2. 1 (Server Virtual IP Address) ha “A” e ) om Guid c [ndbd] t n ng (Server i e connect-string=1 92. 168 .2. 1 p d “A” Virtual IP Address) p u t o... acz se to j ( 04 20 nOriginal g cen a li Step 2b Create the new config.ini defining the cluster on the system Lab h Z with4-G, n the management server ly c a J Revision Choose which machine will be the Cluster Management Server and label this machine server “A” On server “A”, edit the /var/lib /mysql- cluster/config.ini file to contain the following text: [NDB_MGMD] hostname=1 92. 168 .2. 1 (Server “A” Virtual... “B”, disable the network by issuing the following command ONLY: ns a r t n 04 21 Original o n Lab 4-G, Step 20 Re-enable the network, does the node a automatically rejoin? s ha de ) m Revision ui o c G On server “B”, Re-enable the network t the following command n ngby issuing i e p p Stud o shell> ifup eth0:1 h s his @ t g 04 21 Original n e a s Lab 4-G ended zh withtoa uquestion to the student c a j... connection by issuing 06 15 Original Lab 6-B, Step 10 On the first host machine (hostname1), turn off network connection by issuing the following command: the following command: shell> ifup eth0:1 MySQL High Availability 14
- Xem thêm -

Xem thêm: MySql High Availability Class Part 2, MySql High Availability Class Part 2, MySql High Availability Class Part 2

Gợi ý tài liệu liên quan cho bạn

Nạp tiền Tải lên
Đăng ký
Đăng nhập