S
S
Sergey Goryachev2017-04-25 10:08:13
MySQL
Sergey Goryachev, 2017-04-25 10:08:13

MySQL replication, how should it work?

Actually, after yesterday's question How is it better to organize work with databases?
decided to go this way:
1) Make yourself a small server on VPS, where there will be only databases for development.
2) Set it up as the master server for replication.
3) Make two computers with Lamp Servers slaves.
The main development is carried out on a remote server.
But in the event of an emergency (the Internet is gone, the server is broken), I want to be able to quickly switch to local storage.
Actually, all the changes made earlier to the server should be in the local storage.
I configured the head server, writes that bases are replicated.
But for some reason, the slave servers do not see anything, as there were no bases from the server, and there are none.
Questions related to this.
1) Does replication happen automatically or do I need to somehow get the data manually?
2) Is it possible to add the changes made on the slave to the master server?
3) On the subordinate bases will appear themselves or need to be created, then the tables are replicated?
4) In general, how good/bad is this way of working?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2017-04-25
@webirus

What do you mean they don't see? Is replication basically set up? What does the command on replica ("local storage") say? Generally replication works automatically (if it is of course configured). An example from the output of a command from a replica:

mysql --execute 'SHOW SLAVE STATUS\G'
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.3.12
                  Master_User: replication
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.024614
          Read_Master_Log_Pos: 69542233
               Relay_Log_File: mysql-relay-bin-1.010200
                Relay_Log_Pos: 69542379
        Relay_Master_Log_File: mysql-bin.024614
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: berito
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 69542233
              Relay_Log_Space: 69542580
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1

The Slave_IO_Running =Yes and Slave_SQL_Running=Yes lines indicate that replication is running, and Seconds_Behind_Master=0 indicates that the replica is 0 seconds behind the master.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question