Hi all.I am rsyncing the mysql data-directory (/var/lib/mysql) from one server(say A) to another (say B) in realtime(Server A is up and server B is down during the sync).The backup server comes up only if the server A goes down (say power outage,system failure,etc) On server B,i change the directory permissions and then start the mysql server. The server is starting (on B) but my problem is am losing a substantial amount of data.I know that mysql-server on A holds the currently used 'binlog' file and so no complete rsync on 'B'. In other words i am trying to achieve HA without the mysql clustering technology.Is it possible? Are there ways to rsync the mysql data to the current binlog file/position from A to B
You can't reliably rsync MySQL data unless both DB servers are shut down. You really would want to look at MySQL replication instead. http://dev.mysql.com/doc/refman/5.6/en/replication.html
Keep in mind that replication is generally used in a master/slave configuration. Therefore, the slave is only a copy and can be read from but not written to separately. rsync is a haphazard way of doing it. It can work (just don't use innodb with it) but it is unaware of any MySQL file locks, etc so corruption can and often will result. If you use replication and need the slave server to do its own writes if the primary goes down, you will need to redo the replication afterwards.
i know there are is mysqldump command which exports all mysql dbs safelly then U need to rsync these dumps and then restore them on new server