I have MySQL 5.7 installed on two servers and I configured both servers' mysqld.cnf file as shown below
Server1 configuration.
[mysqld]
bind-address = 192.168.0.1
server_id = 1
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 1
Server2 configuration.
[mysqld]
bind-address = 192.168.0.2
server_id = 2
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
auto-increment-increment = 2
auto-increment-offset = 2
Then when I get the out put from Server1 with the below:
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000006 | 459 | | | |
+------------------+----------+--------------+------------------+-------------------+
Then I go to run and get the output as per below at Server2:
mysql> STOP SLAVE;
mysql> CHANGE MASTER TO master_host='192.168.0.1', master_port=3306,
master_user='replicauser',
master_password='somestrongpassword', master_log_file='mysql-bin.000006',
master_log_pos=459;
mysql> START SLAVE;
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000007 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
So what is the missing to complete my solution ?
Edit:
The missing part was just restart for both servers
Related
I have a mysql server. I use Percona and I use the audit log plugin. I have no problem with this.
But there are too many active users in the sub-structure using mysql. I just want to keep the audit logs of real users. I want to use the include and exclude properties for this.
When I apply the following percona article, it fails because it cannot find the mysql variable. Does not add new variable.
Any advice on this?
https://www.percona.com/doc/percona-server/LATEST/management/audit_log_plugin.html#filtering-by-user
I have added the following line to my.cnf file, but again nothing has changed.
audit_log_include_accounts = 'test # localhost'
[root#mysql-server ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root#mysql-server ~]# yum list installed |grep "percona"
Percona-Server-client-57.x86_64 5.7.22-22.1.el7 #percona
Percona-Server-server-57.x86_64 5.7.11-4.1.el7 #percona
Percona-Server-shared-57.x86_64 5.7.22-22.1.el7 #percona
Percona-Server-shared-compat-57.x86_64 5.7.22-22.1.el7 #percona
percona-toolkit.x86_64 3.0.10-1.el7 #percona
[root#mysql-server ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.22-22, for Linux (x86_64) using 6.2
mysql> SHOW VARIABLES LIKE 'audit%';
+---------------------------+--------------------------+
| Variable_name | Value |
+---------------------------+--------------------------+
| audit_log_buffer_size | 1048576 |
| audit_log_file | /var/log/mysql/audit.log |
| audit_log_flush | OFF |
| audit_log_format | JSON |
| audit_log_handler | FILE |
| audit_log_policy | ALL |
| audit_log_rotate_on_size | 10485760 |
| audit_log_rotations | 10 |
| audit_log_strategy | ASYNCHRONOUS |
| audit_log_syslog_facility | LOG_USER |
| audit_log_syslog_ident | percona-audit |
| audit_log_syslog_priority | LOG_INFO |
+---------------------------+--------------------------+
12 rows in set (0.01 sec)
mysql> SET GLOBAL audit_log_include_accounts = 'test#localhost';
ERROR 1193 (HY000): Unknown system variable 'audit_log_include_accounts'
mysql>
mysql> SET GLOBAL audit_log_include_accounts = NULL;
ERROR 1193 (HY000): Unknown system variable 'audit_log_include_accounts'
[root#mysql-server ~]# cat /etc/my.cnf
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[isamchk]
key_buffer_size = 16M
[mysqld]
audit_log_file = /var/log/mysql/audit.log
audit_log_format = JSON
audit_log_policy = ALL
audit_log_rotate_on_size = 10M
audit_log_rotations = 10
basedir = /usr
bind-address = 0.0.0.0
binlog-format = ROW
datadir = /var/lib/mysql
default-storage-engine = innodb
expire_logs_days = 7
explicit_defaults_for_timestamp = 1
innodb-buffer-pool-size = 1G
innodb-file-per-table = 1
innodb-flush-log-at-trx-commit = 2
innodb-flush-method = O_DIRECT
innodb-log-file-size = 512M
innodb-log-files-in-group = 2
key_buffer_size = 16M
log-error = /var/log/mysql/mysqld.log
log-queries-not-using-indexes = 0
max-connect-errors = 1000000
max-connections = 1000
max-heap-table-size = 512M
max_allowed_packet = 16M
max_binlog_size = 100M
open-files-limit = 65535
pid-file = /var/run/mysqld/mysqld.pid
port = 3306
query-cache-type = 1
query_cache_limit = 12M
query_cache_size = 16M
server_id = 1
skip-external-locking
skip-name-resolve
slave-skip-errors = 1062,1053
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
socket = /var/lib/mysql/mysql.sock
ssl = false
ssl-ca = /etc/mysql/cacert.pem
ssl-cert = /etc/mysql/server-cert.pem
ssl-key = /etc/mysql/server-key.pem
sync-binlog = 0
sysdate-is-now = 1
table-definition-cache = 4096
table-open-cache = 4096
thread_cache_size = 8
thread_stack = 256K
tmp_table_size = 16M
tmpdir = /tmp
user = mysql
[mysqld-5.0]
myisam-recover = BACKUP
[mysqld-5.1]
myisam-recover = BACKUP
[mysqld-5.5]
myisam-recover = BACKUP
[mysqld-5.6]
myisam-recover-options = BACKUP
[mysqld-5.7]
myisam-recover-options = BACKUP
[mysqld_safe]
log-error = /var/log/mysql/mysqld_safe.log
nice = 0
socket = /var/lib/mysql/mysql.sock
[mysqldump]
max_allowed_packet = 16M
quick
quote-names
!includedir /etc/my.cnf.d
I found the cause of the problem. The version needs to be upgraded. When I upgraded the version, the variables came automatically and I can make changes.
However, the supported version is 5.7 in the documentation. But not exactly.
my current version: '5.7.11-4.1.el7'
The version I upgraded to: '5.7.24-27.1.el7'
I have an error that has plagued for quite some time and still no solution
Whenever I receive :
2018-07-16 11:21:27,815 [Thread-4] WARN spi.SqlExceptionHelper - SQL
Error: 0, SQLState: 08S01 2018-07-16 11:21:27,815 [Thread-4] ERROR
spi.SqlExceptionHelper - Communications link failure
The last packet successfully received from the server was 197,301
milliseconds ago. The last packet sent successfully to the server was
197,301 milliseconds ago.
The application never seems to reconnect. Even though this is my datasource configuration (it's an external configuration):
dataSource.dbCreate=none
dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://****/*****?autoReconnect=true&failOverReadOnly=false&maxReconnects=10
dataSource.username=***
dataSource.password=******
dataSource.properties.maxActive = 50
dataSource.properties.maxIdle = 25
dataSource.properties.minIdle = 1
dataSource.properties.initialSize = 1
dataSource.properties.numTestsPerEvictionRun = 3
dataSource.properties.maxWait = 10000
dataSource.properties.testOnBorrow = true
dataSource.properties.testWhileIdle = true
dataSource.properties.testOnReturn = true
dataSource.properties.validationQuery = "select now()"
dataSource.properties.minEvictableIdleTimeMillis = 300000
dataSource.properties.timeBetweenEvictionRunsMillis = 300000
I saw several questions on this issue, but nothing that actually solved it for me.
NOTE : I just want to emphasis that this occurs rarely, so i'm not trying to solve the issue of link connection failure, I just want that when it happens to reconnect after retry so the system won't hang (another C process handles this adequately so I suspect the issue is with Hibernate or Grails)
These are my mysql config
[client]
port=3306
socket=/data/db/mysql/mysql.sock
[mysqld]
port=3306
datadir=/data/db/mysql
socket=/data/db/mysql/mysql.sock
log-bin=/data/db/mysql/mysql-bin
binlog_format=row
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id=1
max_connections=250
[mysqld_safe]
log-bin=/data/db/mysql/mysql-bin
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
server-id=1
max_connections=250
Some other info
| wait_timeout | 28800
| tx_isolation | REPEATABLE-READ
| thread_handling | one-thread-per-connection
| Table_locks_immediate | 15090998 |
| Table_locks_waited | 7453 |
| table_definition_cache | 256
| table_lock_wait_timeout | 50
| table_open_cache | 64
| table_type | MyISAM
|Bytes_received | 2844964922 |
| Bytes_sent | 5623597485 |
| Com_select | 15003437 |
| Com_set_option | 35905 |
| Handler_commit | 10842183 |
| Handler_delete | 76 |
| Handler_discover | 0 |
| Handler_prepare | 410224 |
| Handler_read_first | 90118 |
| Handler_read_key | 47411397 |
| Handler_read_next | 6354573941 |
| Handler_read_prev | 2900331388 |
| Handler_read_rnd | 449 |
| Handler_read_rnd_next | 2183682054024 |
| Handler_rollback | 44 | |
This may cause because of initial datasource pool size and your mysql timeout config.
I use following configuration:
dataSource {
pooled = true
jmxExport = true
dbCreate = 'validate'
driverClassName = 'com.mysql.jdbc.Driver'
dialect = 'org.hibernate.dialect.MySQL5InnoDBDialect'
properties {
jmxEnabled = true
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 60000
timeBetweenEvictionRunsMillis = 5000
maxWait = 10000
maxAge = 10 * 60000
numTestsPerEvictionRun = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
ignoreExceptionOnPreLoad = true
validationQuery = "SELECT 1"
validationQueryTimeout = 3
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
abandonWhenPercentageFull = 100
removeAbandonedTimeout = 120
removeAbandoned = true
logAbandoned = false
dbProperties {
autoReconnect = true
jdbcCompliantTruncation = false
zeroDateTimeBehavior = 'convertToNull'
}
}
}
along with:
dataSource {
url = "jdbc:mysql://localhost:3306/dbname?useSSL=false&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true"
username = "user"
password = "xxxxx"
logSql = true
}
Does the application work fine on another database?
Kindly check your mysql settings and share what is in the following lines:
sudo nano /etc/mysql/my.cnf
wait_timeout = 28800
interactive_timeout = 28800
I am thinking this might not be a grails issue.
Why is the record not locking between 2 nodes of MariaDB Galera Cluster 10.2.11?
Node 1 Node 2
START TRANSACTION;
SELECT * FROM table WHERE id = 1 FOR UPDATE;
+----+------+
| id | info |
+----+------+
| 1 | 123 |
+----+------+
START TRANSACTION;
SELECT * FROM table WHERE id = 1 FOR UPDATE;
+----+------+
| id | info |
+----+------+
| 1 | 123 |
+----+------+
If I try this by two connection in one node - locking is ok.
My server config (/etc/my.cnf.d/server.cnf)
[server]
[mysqld]
log_bin = prod-bin
sql_mode = STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
transaction-isolation = READ-COMMITTED
slow_query_log = ON
slow_launch_time = 2
innodb_buffer_pool_size=3G
expire_logs_days = 30
auto_increment_increment = 3
auto_increment_offset = 2
sql_error_log_rotate = TRUE
max_connections = 2000
[galera]
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.0.102,192.168.0.80,192.168.0.23
wsrep_cluster_name="cluster"
wsrep_sst_method=xtrabackup
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
[embedded]
[mariadb]
[mariadb-10.1]
Thank you.
I have a small OpenVZ container.
2 cores and 4096MB RAM.
I have mysql database (overal size is 80MB InnoDb)
When i do 100 queries like INSERT ON DUPLICATE KEY UPDATE, few of them executes longer than 1 seconds, always
mysql> SHOW PROFILE;
+----------------------+----------+
| Status | Duration |
+----------------------+----------+
| checking permissions | 0.000040 |
| creating table | 0.000056 |
| After create | 0.011363 |
| query end | 1.231525 |
| freeing items | 0.000089 |
| logging slow query | 0.000019 |
| cleaning up | 0.000005 |
+----------------------+----------+
7 rows in set (0.00 sec)
When i turned off binary logging, it helped. So the problem maybe in hard drive. And occurs when binary log is writing during the query executing.
Will it help, if i replace mysql with the tarantool? As i know tarantool also writes binlogs.
I have percona mysql
mysql> select version();
+-----------------+
| version() |
+-----------------+
| 5.6.25-73.1-log |
+-----------------+
1 row in set (0.01 sec)
Here is the my.cnf
[client]
default-character-set = utf8mb4
[mysql]
# CLIENT #
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pid
# MyISAM #
key-buffer-size = 32M
myisam-recover = FORCE,BACKUP
# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 1000000
# DATA STORAGE #
datadir = /var/lib/mysql/
# BINARY LOGGING #
#log-bin = /var/lib/mysql/mysql-bin
#expire-logs-days = 14
#sync-binlog = 1
# CACHES AND LIMITS #
tmp-table-size = 128M
max-heap-table-size = 128M
query-cache-type = 1
query-cache-size = 32M
max-connections = 1000
thread-cache-size = 128
open-files-limit = 65535
table-definition-cache = 1024
table-open-cache = 2048
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 256M
innodb_log_buffer_size = 32M
innodb-flush-log-at-trx-commit = 0
innodb-file-per-table = 1
innodb-buffer-pool-size = 1G
innodb_buffer_pool_instances = 1
# LOGGING #
log-error = /var/lib/mysql/mysql-error1.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
long_query_time = 1
log-queries-not-using-indexes = 1
#PERCONA
log_slow_verbosity = microtime,query_plan,innodb
Yes Tarantool write 'binlogs' (WAL - write-ahead logging).
Definitely tarantool are more faster than mysql.
But probably mysql need more tuning. Sorry I'm not know much about mysql tuning.
Tarantool should help you out here.
It delivers sub 0.001s latencies even with transaction log turned on. Here is the piece of code that helps you testing Tarantool under heavy read/write workloads: https://gist.github.com/danikin/a5ddc6fe0cedc6257853.
I was running benchmark test in mysql server using mysqlslap. But sometimes the last thread in the pool is not executing and closing the connection. It keeps in sleep state.
mysql> show full processlist;
+-----+------+-----------------------+-----------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+------+-----------------------+-----------+---------+------+-------+-----------------------+
| 2 | root | 122.178.231.xxx:15832 | mysqlslap | Sleep | 740 | | NULL |
| 106 | root | localhost | NULL | Query | 0 | NULL | show full processlist |
+-----+------+-----------------------+-----------+---------+------+-------+-----------------------+
2 rows in set (0.00 sec)
Any idea? It happens often :(
This was the command I executed.
mysqlslap -h IP_address -u root --auto-generate-sql --concurrency=100
-pPASSWORD -vvv --number-of-queries=2500
my.cnf file is as follows,
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
skip-bdb
max_connections = 500
query_cache_type = 1
query_cache_size = 128M
sort_buffer_size = 64M
key_buffer_size = 425M
query_cache_limit = 1024M
thread_cache_size = 4M
innodb_buffer_pool_size = 1360M
innodb_log_file_size = 512M
long_query_time = 5
innodb_thread_concurrency = 8
innodb_lock_wait_timeout = 300
max_allowed_packet = 128M
net_read_timeout = 240
net_write_timeout = 240
table_lock_wait_timeout =240
connect_timeout = 30
log-warnings = 2
log = /var/log/mysqld.log
log-error = /var/log/mysqld.error.log
log-slow-queries = /var/log/mysql_slow_queries.log