January 2019
M T W T F S S
« Dec    
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories

WordPress Quotes

Cherish your visions and your dreams as they are the children of your soul, the blueprints of your ultimate achievements.
Napoleon Hill

Recent Comments

January 2019
M T W T F S S
« Dec    
 123456
78910111213
14151617181920
21222324252627
28293031  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (34)
Ansibile (19)
Apache (133)
Asterisk (2)
cassandra (2)
Centos (209)
Centos RHEL 7 (261)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (28)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (2)
Ldap (5)
Linux (189)
Linux Commands (167)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (31)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (34)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (60)
Uncategorized (29)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

20 visitors online now
6 guests, 14 bots, 0 members

Hit Counter provided by dental implants orange county

MARIADB MASTER SLAVE

MARIADB MASTER SLAVE

Install on both master and slave

yum install mariadb-server mariadb -y

systemctl enable mariadb

systemctl start mariadb.service

mysql_secure_installation

Master

Add below lines on the mysql

vi /etc/my.cnf

[server]
# add follows in [server] section : get binary logs
log-bin=mysql-bin
# define uniq server ID
server-id=101

Restart the mariadb service

systemctl restart mariadb.service

mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.2.8-MariaDB-log MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

# create user (set any password for ‘password’ section)

MariaDB [(none)]> grant replication slave on *.* to replication@’%’ identified by ‘P@assword’;

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit

Bye

Slave

Add below lines on the mysql on the slave server

vi /etc/my.cnf

slave node
[server]
# add follows in [server] section : get binary logs

log-bin=mysql-bin
# define server ID (different one from Master Host)

server-id=102
# read only

read_only=1
# define own hostname
report-host=slaveserver

Restart the mariadb service
systemctl restart mariadb.service

Get Dump-Data on Master Host server

mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.2.8-MariaDB-log MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

# lock all tables

MMariaDB [(none)]> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000001 | 541 | | |
+——————+———-+————–+——————+
1 row in set (0.00 sec)

mysqldump -u root -p –all-databases –lock-all-tables –events > mysql_dump.sql

unlock the tables on the master server

Enter password:
# back to the remained window and unlock

MariaDB [(none)]> unlock tables;

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit

Bye

scp mysql_dump.sql dev01@ec2-13-127-218-218.ap-south-1.compute.amazonaws.com:/tmp/

Go to the Slave Host.

import dump from Master Host

[root@ip-172-31-25-39 ~]# mysql -u root -p < /tmp/mysql_dump.sql
Enter password:

Configure replication settings on Slave Host. It’s OK all, make sure the settings work normally to create databases on Master Host.
# import dump from Master Host

mysql -u root -p

CHANGE MASTER TO MASTER_HOST=’13.127.203.148′, MASTER_USER=’replication’, MASTER_PASSWORD=’P@assword’, MASTER_LOG_FILE=’| mysql-bin.000001′, MASTER_LOG_POS=541;

MariaDB [(none)]> start slave;

Query OK, 0 rows affected (0.00 sec)
# show status

MariaDB [(none)]> show slave status\G

asterA has the following error in show slave status:

Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Could not find first log file name in binary log index file’

Solution:

Slave: stop slave;

Master: flush logs

Master: show master status; — take note of the master log file and master log position

Slave: CHANGE MASTER TO MASTER_LOG_FILE=’log-bin.00000X?, MASTER_LOG_POS=106;

Slave: start slave;

MariaDB [(none)]> stop slave;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> reset slave;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST=’13.127.203.148′, MASTER_USER=’replication’, MASTER_PASSWORD=’P@assword’, MASTER_LOG_FILE=’| mysql-bin.000005′, MASTER_LOG_POS=245;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show slave status\G ;

 

show binary logs ;
>for f in $(cat mysqld-bin.index); do test -f $f || echo "Not found $f" ; done;

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam