Is it possible to get replication status from any system database table?
Using which I can identify whether the replication is up or down.
I need to to know whether the SLAVE_IO_RUNNING
and SLAVE_SQL_RUNNING = YES
from a system table.
Connect to the Publisher in Management Studio, and then expand the server node. Expand the Replication folder, and then expand the Local Publications folder. Expand the publication for the subscription you want to monitor. Right-click the subscription, and then click View Synchronization Status.
Each replica that connects to the source requests a copy of the binary log. That is, it pulls the data from the source, rather than the source pushing the data to the replica.
MySQL is a widely used Database by big organizations to run their business activities. Data replication is one such technique that allows users to access data from numerous sources such as servers, sites, etc. in real-time.
Replication enables data from one MySQL database server (known as a source) to be copied to one or more MySQL database servers (known as replicas). Replication is asynchronous by default; replicas do not need to be connected permanently to receive updates from a source.
This is the statement that I have used based on Manasi's top answer.
SELECT variable_value
FROM information_schema.global_status
WHERE variable_name='SLAVE_RUNNING';
hslakhan's answer works for MySQL 5.6, but for MySQL 5.7 the slave status variables have moved from information_schema
to performance_schema
.
Slave_IO_Running
corresponds to:
SELECT SERVICE_STATE FROM performance_schema.replication_connection_status;
Slave_SQL_Running
corresponds to:
SELECT SERVICE_STATE FROM performance_schema.replication_applier_status;
There are some other variables from the SHOW SLAVE STATUS
output too, see https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_show_compatibility_56_slave_status for the rest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With