Sei sulla pagina 1di 6

Steps for a one-way replication

Master Side

1. Connect the two laptops via Ethernet connection using UTP Cable.

2. Setup the IPv4 of the two devices, for PC1 use the IP address 192.168.1.1 and for PC2
use 192.168.1.2 and a subnet mask of 255.255.255.0 and a subnet gateway of the IP
address of the other PC.

3. Ping the IP address of each computer to check if they are connected.

4. In the Master computer, go to xampp and on the mysql side, click config and then open
my.ini , Note you must use the same xampp Version.
5. Type in log-bin=mysql-bin and set server-id=1 and master server-id=1, note that the
master-slave can’t have the same server-id. After setting, save the file and restart mysql.

6. Create user and grant slave replication. On the mysql shell, type in the following codes:
CREATE USER ‘user_name’@’%’ IDENTIFIED BY ‘password’;
GRANT REPLICATION SLAVE ON *.* TO ‘user_name’@’%’ IDENTIFIED
BY ‘password’;
FLUSH TABLES WITH READ LOCK;

SHOW MASTER STATUS;


UNLOCK TABLES;
Slave Side

7. On the slave computer open the my.ini of mysql file and set server-id=2. After setting,
save file and then restart mysql.

8. To change the master, open mysql shell, then type in the following:

mysql -u root -p
STOP SLAVE;
CHANGE MASTER TO
MASTER_HOST='192.168.1.1',
MASTER_USER='karlo1',
MASTER_PASSWORD=’12345’,
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000003',
MASTER_LOG_POS=120,
MASTER_CONNECT_RETRY=10;

9. After changing the master successfully, start the slave and then check slave status. The
SLAVE_IO and SLAVE_SQL should be running.
10. If The SLAVE_IO and SLAVE_SQL are running, then the replication has been a success.

Create and Import Database

11. Create database then import the database that has a data. And then check if the import
succeeds by checking if the new database has a data.

Trying the replication process

12. Then try to a insert value.


13. the slave computer can now view the database and its content.

(no new data)

(with new data)

14. one-way replication of the data manipulated or performed by the slave computer does
not affect/reflect in the master database. Changes by the master are always replicated in
the slave.

Scenario
1. A hospital has their own patients.

2. Each patient has a full description about the patient about personal detail and phone
number, and then Disease and what treatment is going on.

3. The doctor will handle patients, one doctor can Treat more than 1 patient.
4. Patients can be admitted to hospital. So different room numbers will be there, also
rooms for Operation Theaters and ICU.

5. There are some nurses, and ward boys for the maintenance of hospital and for patient
take care. Based upon the number of days and treatment bill will be generated.

Entity Relationship Diagram

Potrebbero piacerti anche