1. check master status in master
SHOW MASTER STATUS
[root@teguhth01 ~]# mysql -uroot -proot -e "SHOW MASTER STATUS;"
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000016 | 471 | | |
+------------------+----------+--------------+------------------+
[root@teguhth01 ~]#
[root@teguhth01 ~]# mysql -uroot -proot -e "SHOW MASTER STATUS;" | awk '{print $1}'
File
mysql-bin.000016
[root@teguhth01 ~]# mysql -uroot -proot -e "SHOW MASTER STATUS;" | awk '{print $2}'
Position
471
[root@teguhth01 ~]# mysql -uroot -proot -e "SHOW MASTER STATUS;" | awk '{print $3}'
Binlog_Do_DB
[root@teguhth01 ~]# mysql -uroot -proot -e "SHOW MASTER STATUS;" | awk '{print $4}'
Binlog_Ignore_DB
[root@teguhth01 ~]#
2. info from master
start_binlog = File > mysql-bin.000016
start_pos = Position > 471
gtid_binlog = SELECT BINLOG_GTID_POS('start_binlog', 'start_pos');
3. get gtid master
mysql -uroot -proot -e "SELECT @@hostname,BINLOG_GTID_POS('mysql-bin.000016','471')"
[root@teguhth01 ~]# mysql -uroot -proot -e "SELECT @@hostname,BINLOG_GTID_POS('mysql-bin.000016','471')"
+------------+-------------------------------------------+
| @@hostname | BINLOG_GTID_POS('mysql-bin.000016','471') |
+------------+-------------------------------------------+
| teguhth01 | 1-1-119 |
+------------+-------------------------------------------+
[root@teguhth01 ~]#
4. cek slave status G in slave
mysql -uroot -proot -e "show slave status\G"
mysql -uroot -proot -e "show slave status\G" | grep -i Relay_Master_Log_File
mysql -uroot -proot -e "show slave status\G" | grep -i Exec_Master_Log_Pos
mysql -uroot -proot -e "show slave status\G" | grep -i Gtid_IO_Pos
[root@teguhth02 ~]# mysql -uroot -proot -e " show slave status\G" | grep -i Relay_Master_Log_File
Relay_Master_Log_File: mysql-bin.000016
[root@teguhth02 ~]# mysql -uroot -proot -e " show slave status\G" | grep -i Exec_Master_Log_Pos
Exec_Master_Log_Pos: 471
[root@teguhth02 ~]# mysql -uroot -proot -e " show slave status\G" | grep -i Gtid_IO_Pos
Gtid_IO_Pos: 1-1-119
[root@teguhth02 ~]#
5. conclusion
[root@teguhth01 data]# cat script_get_gtid.sh
## login to MariaDB
mariadbx=$(echo "mysql -uroot -pxxx -N");
## File binlogs
start_binlog=$(echo "SHOW MASTER STATUS;" | $mariadbx | awk '{print $1}');
## Position
start_pos=$(echo "SHOW MASTER STATUS;" | $mariadbx | awk '{print $2}');
gtid_binlog=$(echo "SELECT BINLOG_GTID_POS('$start_binlog', $start_pos);" | $mariadbx | awk '{print $1}');
logx=gtidlox.txt
echo "binlog: "$start_binlog > $logx
echo "position: "$start_pos >> $logx
echo "GTID :"$gtid_binlog >> $logx
cat $logx
[root@teguhth01 data]#
[root@teguhth01 data]#
## login to MariaDB
mariadbx=$(echo "mysql -uroot -pxxx -N");
## File binlogs
start_binlog=$(echo "SHOW MASTER STATUS;" | $mariadbx | awk '{print $1}');
## Position
start_pos=$(echo "SHOW MASTER STATUS;" | $mariadbx | awk '{print $2}');
gtid_binlog=$(echo "SELECT BINLOG_GTID_POS('$start_binlog', $start_pos);" | $mariadbx | awk '{print $1}');
logx=gtidlox.txt
echo "binlog: "$start_binlog > $logx
echo "position: "$start_pos >> $logx
echo "GTID :"$gtid_binlog >> $logx
cat $logx
[root@teguhth01 data]#
[root@teguhth01 data]#
No comments:
Post a Comment