Mysql : How to synchronize databases after having been offline using replication? - mysql

I created a replication between two computers (a laptop I use to add new datas in my db and a server that save everything I do on the laptop) and it works fine.
But today, my laptop was online so I was not able to update my server.
Result : I updated some lines and I created a lot of lines and when my laptop was back online, the replication did not works on the datas I've been working on offline.
Could anybody give me an advice to update datas (on the server) that have been modified on the laptop while I was not connected ? I don't get why it doesn't works !
Thx !
update : here is my show slave status :
mysql> show slave status;
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
| Slave_IO_State | Master_Host | Master_User | Master_Port | C
onnect_Retry | Master_Log_File | Read_Master_Log_Pos | Relay_Log_File
| Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Runnin
g | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignor
e_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | L
ast_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Conditi
on | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File |
Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seco
nds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Erro
r | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Serve
r_Id |
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
| Waiting for master to send event | ***.***.***.*** | masterRepli | 3306 |
60 | mysql-bin.000027 | 454717 | aofr19072-relay-bin.0000
02 | 1227 | mysql-bin.000027 | Yes | Yes
| | | |
| | | 0 |
| 0 | 454717 | 1387 | None
| | 0 | No | |
| | | |
0 | No | 0 |
| 0 | | |
2 |
+----------------------------------+-------------+-------------+-------------+--
-------------+------------------+---------------------+-------------------------
---+---------------+-----------------------+------------------+-----------------
--+-----------------+---------------------+--------------------+----------------
--------+-------------------------+-----------------------------+------------+--
----------+--------------+---------------------+-----------------+--------------
---+----------------+---------------+--------------------+--------------------+-
-------------------+-----------------+-------------------+----------------+-----
------------------+-------------------------------+---------------+-------------
--+----------------+----------------+-----------------------------+-------------
-----+
1 row in set (0.00 sec)

BRUTE FORCE SYNC
I wrote out a detailed description on how to resync a Slave to its Master in a Circular Replication setup
PRECISION STRIKE SYNC
If you simply want to find the differences and update only differences, you must use mk-table-checksum and mk-table-sync.
Give it a Try !!!

Is it possible that the slave server just doesn't have the slave process running?
See if the slave process is running by typing SHOW SLAVE STATUS; at the MySQL command prompt on the slave.
Then try starting it with START SLAVE;
If it still isn't working, post the output of the SHOW SLAVE STATUS; command, and we'll try to help you further :)

Related

How to debug "Lock wait timeout exceeded" in mysql (aurora)

I'm getting "Lock wait timeout exceeded" error when inserting a record in MySQL table (amazon aurora to be precise). We're inserting hundreds of records in one transaction with savepoint for every few inserts.
We're using the InnoDB engine. We have innodb_lock_wait_timeout set to 50 sec. We're getting this error only in production so I am limited in debugging ability here.
I've tried to pull info about locked transactions when insert statements runs and here is what I got:
MySQL [(none)]> SELECT w.* FROM information_schema.innodb_lock_waits w INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.processlist p on b.trx_mysql_thread_id = p.ID LIMIT 10;
+-------------------+--------------------------+-----------------+--------------------------+
| requesting_trx_id | requested_lock_id | blocking_trx_id | blocking_lock_id |
+-------------------+--------------------------+-----------------+--------------------------+
| 1177444193 | 1177444193:5437:2161:286 | 1177444168 | 1177444168:5437:2161:286 |
+-------------------+--------------------------+-----------------+--------------------------+
1 row in set (0.01 sec)
MySQL [(none)]> select * from information_schema.innodb_trx where trx_id=1177444168 limit 10;
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| trx_id | trx_state | trx_started | trx_requested_lock_id | trx_wait_started | trx_weight | trx_mysql_thread_id | trx_query | trx_operation_state | trx_tables_in_use | trx_tables_locked | trx_lock_structs | trx_lock_memory_bytes | trx_rows_locked | trx_rows_modified | trx_concurrency_tickets | trx_isolation_level | trx_unique_checks | trx_foreign_key_checks | trx_last_foreign_key_error | trx_adaptive_hash_latched | trx_adaptive_hash_timeout | trx_is_read_only | trx_autocommit_non_locking |
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| 1177444168 | RUNNING | 2022-09-26 12:08:49 | NULL | NULL | 1844 | 64308215 | NULL | NULL | 0 | 8 | 908 | 1136 | 2579 | 936 | 0 | READ COMMITTED | 1 | 1 | NULL | 0 | 0 | 0 | 0 |
+------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
1 row in set (0.01 sec)
As I see blocking tx isn't a query but rather some transaction with a lot of locked records because I see nothing in trx_query.
So my question is how can I get more info about this blocking transaction to see what exactly is blocking my insert for 50 sec until timeout?
p.s. we haven't had such problems on standalone MySQL but started to see lock wait errors when migrated to aurora.

how much internet traffic is used by an sql query in MySQL & MySQL Workbench

I am having a project where internet trafic is very expensive (metered connections).
Therefore I try to observe how much traffic is beeing used with different methods.
example statement:
SELECT Activation from Database.Table
WHERE ObjectID = 2382;
-------------------------
| Object ID | Activation|
|-----------|-----------|
| 2380 | 0 |
| 2381 | 0 |
| 2382 | 1 |
| 2383 | 0 |
| 2384 | 1 |
| 2385 | 0 |
-------------------------
=> returns 1 for example
Is there a method in SQL workbench, to precisely find out, how much traffic was beeing used for this query, or do I have to measure it using Wireshark?
Would http or other protocols use less traffic?
Best regards,
Julian

Intercept the id or the command of a Rollback process in MySQL

Is it possible to find the process ID or the command that is executed for a rollback ?
More specifically :
The Information_Schema of MySQL has a specific table named processlist. This contains the details about every ongoing process in MySQL. An example of the table looks like this:
mysql> select * from processlist;
+----+------+-----------+--------------------+---------+------+------------+---------------------------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+----+------+-----------+--------------------+---------+------+------------+---------------------------+
| 5 | root | localhost | information_schema | Query | 5 | User sleep | select sleep(20) |
| 4 | root | localhost | information_schema | Query | 0 | executing | select * from processlist |
+----+------+-----------+--------------------+---------+------+------------+---------------------------+
Is it possible for me to intercept a Rollback and grab its ID or INFO from this table ? The issue I have been facing is that any Rollback I execute gets completed before I am able to intercept its ID from the Table.

Galera_new_cluster command not starting a cluster

Following documentation on how to set up a MariaDB Galera cluster, I simply created the proper config files and started my primary db server with the galera_new_cluster command (I'm running RHEL7). According to the documentation, at that point you should be able to run:
SHOW STATUS LIKE 'wsrep_cluster_size';
And see
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 1 |
+--------------------+-------+
However, I see wsrep_cluster_size of zero with these other relevant values:
MariaDB [(none)]> show global status like 'wsrep%';
+--------------------------+----------------------+
| Variable_name | Value |
+--------------------------+----------------------+
| wsrep_cluster_conf_id | 18446744073709551615 |
| wsrep_cluster_size | 0 |
| wsrep_cluster_state_uuid | |
| wsrep_cluster_status | Disconnected |
| wsrep_connected | OFF |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 18446744073709551615 |
| wsrep_provider_name | |
| wsrep_provider_vendor | |
| wsrep_provider_version | |
| wsrep_ready | OFF |
| wsrep_thread_count | 0 |
+--------------------------+----------------------+
My settings in /etc/my.cnf.d/server.cnf are:
bind_address=172.28.7.15
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://172.28.7.15,172.28.7.18,172.28.7.19"
wsrep_node_address=172.28.7.15
wsrep_node_name='node01'
wsrep_slave_threads=1
wsrep_certify_nonPK=1
wsrep_max_ws_rows=131072
wsrep_max_ws_size=1073741824
wsrep_debug=1
wsrep_convert_LOCK_to_trx=0
wsrep_retry_autocommit=1
wsrep_auto_increment_control=1
wsrep_drupal_282555_workaround=0
wsrep_causal_reads=0
wsrep_notify_cmd=
wsrep_sst_method=rsync
And I've confirmed that the variables are loaded using SHOW VARIABLES.
I feel like I'm following the documentation exactly and it's just not showing what I expect. The only warnings in logs are warnings about SSL not being set up - is that required?
You mentioned you didn't see any WSREP logs in /var/log/mariadb/mariadb.log. Perhaps wsrep_on option is set to OFF. Try setting it to ON.
Lots of documentation assumes MariaDB Galera 10.0. But in 10.1 and higher, wsrep_on defaults to OFF.
Default Value: OFF (>= MariaDB 10.1), ON (<= MariaDB Galera Cluster 10.0)
https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/#wsrep_on
For Centos 7, edit your /etc/my.cnf file and
setenforce 0
write it on your all nodes.
Then start your cluster and connect nodes.

Slow mysql query execution across local network

I have a mysql database set up on a mac mini server on a local network. When I query the database from the server as the root user, everything behaves well. However, I am having serious problems when I log into mysql from another machine on the local network I perform those same queries.
For example, the table items has 1,831,218 rows and two columns, item and total (not indexed). When I perform the following query is is very quick as expected:
mysql> select * from items limit 10;
+------+-----------+
| item | total |
+------+-----------+
| a | 577846916 |
| b | 489378579 |
| c | 485798873 |
| d | 476865689 |
| e | 425954264 |
| f | 399431640 |
| g | 375218023 |
| h | 325892006 |
| i | 169948795 |
| j | 116927132 |
+------+-----------+
10 rows in set (0.00 sec)
Now by logging in remotely from another machine on the network:>mysql --host=192.168.2.2 -u newuser -p, where newuser has select privileges on the database, I perform the same query and get wildly different execution times.
mysql> select * from items limit 10;
+------+-----------+
| item | total |
+------+-----------+
| a | 577846916 |
| b | 489378579 |
| c | 485798873 |
| d | 476865689 |
| e | 425954264 |
| f | 399431640 |
| g | 375218023 |
| h | 325892006 |
| i | 169948795 |
| j | 116927132 |
+------+-----------+
10 rows in set (7 min 3.10 sec)
This is an exceptionally bad example that doesn't happen all the time, but in general queries are much slower (usually 10-100 times slower (or more) than on the server itself). For this much of a slow down it doesn't seem likely that the bottleneck has to do with latency in the network, but rather some configuration issue that is causing mysql to not communicate well with between the server and the various nodes.
Aside from verifying that both machines are running he same version of mysql: mysql Ver 14.14 Distrib 5.6.19, for osx10.7 (x86_64) using EditLine wrapper, I am not sure what other settings to verify and what else to do to try to fix this problem.
Please let me know if anyone has any ideas, thank you.