1. Trang chủ
  2. » Ngoại Ngữ

MySql High Availability Class Part 2

14 279 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 14
Dung lượng 269,19 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Revision Details added: 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 mysql> GRANT REPLI

Trang 1

Errata Sheet for MySQL High Availability

(D61920GC10)

Date Generated: 27-May-10

03 8 Original

Lab 3-A, Step 1 Edit the configuration file to add the log-bin option under the [mysqld] heading Close and save the configuration file

Revision

Details added:

[mysqld]

log-bin=mysql-bin binlog_format=mixed

03 8 Original

Lab 3-A, Step 2 Restart the MySQL server

Revision

Details added:

shell> mysql restart

03 8 Original

Lab 3-A, Step 3 Locate the binary log files in the datadir

Revision

Details added:

Locate the binary log files in the datadir (/usr/local/mysql/data)

03 8 Original

Lab 3-A, Step 4 Perform a data change operation on a table in your database

Revision

Details added:

mysql> INSERT INTO City VALUES -> (4990,'Kolkata','IND','Howrah',100000);

ble

licen se t

o use this

Trang 2

03 8 Original

Lab 3-A, Step 5 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 8 Original

Lab 3-A, Step 8 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

Revision

Details added:

shell> vi mysql-bin.index

03 8 Original

Lab 3-A, Step 9 Issue a PURGE MASTER LOGS command to delete the first binary log

Revision

Details added:

mysql> PURGE MASTER LOGS to 'mysql-bin.000002';

03 8 Original

Lab 3-A, Step 10 Verify the log file has actually been deleted and view the binary log index again

Revision

Details added:

shell> vi mysql-bin.index

03 12 Original

Lab 3-B, Step 1 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

ble

licen se t

o use this

Trang 3

Revision

Details added:

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

mysql> GRANT REPLICATION SLAVE ON *.* TO

mysql> QUIT;

shell> mysqldump -uroot -p add-drop-database lock-all-tables master-data databases world >

/tmp/dumpfile.sql

03 12 Original

Lab 3-B, Step 2 Setup the slave using the following steps:

• Turn on the binary log (for the slave)

• Set the server-id to be a unique number

• Load in the backup from the master

• Setup the binary log coordinates using the CHANGE MASTER TO 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

ble

licen se t

o use this

Trang 4

shell> /etc/init.d/mysql start 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=

mysql> source /tmp/dumpfile.sql shell> START SLAVE

03 12 Original

Lab 3-B, Step 3 Perform an INSERT on the master

Revision

Details added:

mysql> INSERT INTO City VALUES -> (5000,'Bangalore','IND','Bangalore',100000);

03 12 Original

Lab 3-B, Step 4 Verify the row was received by the slave with a SELECT

Revision

Details added:

mysql> SELECT * FROM City WHERE Name=’Bangalore’;

03 17 Original

Lab 3-C, Step 4 Perform an INSERT on the master server again

Revision

Details added:

mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('MySQL_land','AUS');

ble

licen se t

o use this

Trang 5

03 17 Original

Lab 3-C, Step 5 Verify the row is not

Revision

Details added:

added on the slave

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:

mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('IO_land','USA');

03 17 Original

Lab 3-C, Step 14 Verify the row is added on the slave

Revision

Details added:

mysql> SELECT * FROM City WHERE Name=’IO_land’;

03 18 Original

Lab 3-C, Step 22 Create a table called break on the slave

Revision

Details added:

mysql> CREATE TABLE break (ID INT NOT NULL -> 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);

ble

licen se t

o use this

Trang 6

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

Revision

Details added:

user, attempt to insert a row on the slave

mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('Root_land','GBR');

03 19 Original

Lab 3-C, Step 39 As the root

Revision

Details added:

user, delete the row

mysql> DELETE FROM world.City WHERE Name='Root_land';

03 19 Original

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');

ble

licen se t

o use this

Trang 7

03 22 Original

Lab 3-D, Step 1 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

mysql> QUIT;

shell> mysqldump -uroot -p add-drop-database lock-all-tables master-data databases world > /tmp/dumpfile.sql

ON THE CURRENT SLAVE (WILL BE IDENTIFIED AS SYSTEM A)

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 this position from the dumpfile]

mysql> CHANGE MASTER TO

mysql> START SLAVE;

03 22 Original

Lab 3-D, Step 2 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');

ble

licen se t

o use this

Trang 8

03 22 Original

Lab 3-D, Step 3 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 4 Verify both INSERTs were successful on both systems (“A” and

“B”)

Revision

Details added:

Perform the following SQL statement on both systems:

mysql> SELECT * FROM City WHERE Name=’OU_land’ OR -> Name=’Tin_land’;

03 22 Original

Lab 3-D, Step 6 Insert a new row into City on system “B”

Revision

Details added:

mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('BNG_land','BNG');

03 22 Original

Lab 3-D, Step 8 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’;

ble

licen se t

o use this

Trang 9

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:

mysql> INSERT INTO world.City (Name, CountryCode) -> VALUES ('DEL_land','IND');

04 9 Original

Lab 4-B, Step 1 Create a new file named /var/lib/mysqlcluster/config.ini

Revision

In the Oracle University classrooms, it is crucial to remain a network connection

to the machines at all times The original HA lab was unacceptable because it asked the student to disconnect the system from the network The following steps are crucial to ensure that the students can simulate disconnecting the system from the network

1 Shut down the MySQL server

• shell> /etc/init.d/mysql stop

2 Create a virtual IP address that you will use during the labs in this course

• shell> /labs/start_virtual_ip.sh

3 View the details for the virtual IP that was created

• shell> ifconfig eth0:1

4 Write down the inet address for this virtual IP

5 Create a new file named /var/lib/mysqlcluster/config.ini

• shell> mkdir /var/lib/mysql-cluster

ble

licen se t

o use this

Trang 10

04 9 Original

Lab 4-B, Step 3 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 9 Original

Lab 4-B, Step 8 Add in a section for one data node

Revision

Add the hostname to the [NDBD] section also [NDBD]

hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4)

04 9 Original

Lab 4-B, Step 9 Add in a section for the second data node

Revision

Add the hostname to the [NDBD] section also [NDBD]

hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4)

04 9 Original

Lab 4-B, Step 10 Add in a section for the MySQL server

Revision

Add the hostname to the [MYSQLD] section also [MYSQLD]

hostname=192.168.2.1 (Replace IP with inet address obtained in step 1.4)

04 9 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

ble

licen se t

o use this

Trang 11

[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 1 Find a second machine, or find another student to work together

on this set of exercises

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

View the details for the virtual IP that was created

• shell> ifconfig eth0:1 Write down the inet address for this virtual IP

04 20 Original

Lab 4-G, Step 2b Create the new config.ini defining the cluster on the system with the management server

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)

ble

licen se t

o use this

Trang 12

[NDBD]

hostname=190.145.45.15 (Server “B” Virtual IP Address)

[MYSQLD]

hostname=192.168.2.1 (Server “A” Virtual IP Address)

[MYSQLD]

hostname=190.145.45.15 (Server “B” Virtual IP Address)

04 20 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:

[mysqld]

ndbcluster

ndb-connectstring=192.168.2.1 (Server “A” Virtual IP Address)

[ndbd]

connect-string=192.168.2.1 (Server “A” Virtual IP Address)

[ndb_mgm]

connect-string=192.168.2.1 (Server “A” Virtual IP Address)

[ndb_mgmd]

config-file=/var/lib/mysql-cluster/config.ini

On server “B”, edit the /etc/my.cnf file to include the following:

[mysqld]

ndbcluster

ndb-connectstring=192.168.2.1 (Server “A” Virtual IP Address)

04 21 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

ble

licen se t

o use this

Trang 13

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

Revision

On server “B”, disable the network by issuing the following command ONLY:

shell> ifdown eth0:1

04 21 Original

Lab 4-G, Step 20 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 ended with a question to the student

Revision

At the completion of this lab perform the following steps

1 In the MySQL client, issue the following commands:

• mysql> DROP DATABASE world;

• 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

ble

licen se t

o use this

Trang 14

06 14 Original

Lab 6-B, step 3 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 4 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

06 15 Original

Lab 6-B, Step 10 On the first host machine (hostname1), turn off network connection by issuing the following command:

Revision

On the first host machine (hostname1), turn off network connection by issuing the following command ONLY:

shell> ifdown eth0:1

06 16 Original

Lab 4-G, Step 13 On the first host machine (hostname1), turn on the network connection by issuing the following command:

Revision

On the first host machine (hostname1), turn on the network connection by issuing the following command:

shell> ifup eth0:1

ble

licen se t

o use this

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

TỪ KHÓA LIÊN QUAN