Skip to main content

MySQL database configuration for Galera Replication | Galera cluster | Multi Master Replication

Configure MySQL Database parameters for Galera replication in /etc/my.cnf file:

#Defines the path to the Galera Replication Plugin.
wsrep_provider=/usr/lib/libgalera_smm.so
#Semicolon (;) separated list of wsrep options,

#https://mariadb.com/kb/en/library/wsrep_provider_options/
wsrep_provider_options="gcache.size=300M; gcache.page_size=300M"
# logical name for your cluster. You must use the same name for every node in your cluster.
wsrep_cluster_name="my_cluster"
#IP addresses of nodes in a comma separated list.
wsrep_cluster_address="gcomm://node1,node2,node3"
#method or script the node uses in a State Snapshot Transfer, mysqldump, rsync, #rsync_wan, xtrabackup,wsrep_%.sh For instance, giving the node a transfer method of #MyCustomSST causes it to look for wsrep_MyCustomSST.sh in /usr/bin
wsrep_sst_method=rsync
#logical name for the individual node.
wsrep_node_name=node1
#set the IP address for the individual node.
wsrep_node_address="192.168.0.1"


#configuration file includes the conf.d/
!includedir /etc/mysql/conf.d/
#mysqld is not bound to 127.0.0.1. This is IP address for localhost. If the configuration #variable appears in the file, comment it out:
# bind-address = 127.0.0.1 OR bind-address=0.0.0.0
#InnoDB locking mode for generating auto-increment values is set to interleaved lock mode, #which is designated by a 2 value. Other modes may cause INSERT statements on tables #with AUTO_INCREMENT columns to fail.
innodb_autoinc_lock_mode = 2 - do not use table-level AUTO-INC lock, fastest and most #scalable lock mode, good during row based replication
#Ensure that the InnoDB log buffer is written to file once per second, rather than on each #commit, to improve performance.
innodb_flush_log_at_trx_commit=0 - Write contents of the log buffer to log file every #second.
innodb_buffer_pool_size=122M
#set to use row-level replication, as opposed to statement-level replication.
binlog_format=ROW
#Galera Cluster will not work with MyISAM or similar nontransactional storage engines
default_storage_engine=InnoDB

Using auto-increment with replication:
If you are using statement-based replication, set innodb_autoinc_lock_mode to 0 or 1 and use the same value on the master and its slaves.
Auto-increment values are not ensured to be the same on the slaves as on the master if you use innodb_autoinc_lock_mode = 2 (“interleaved”)
or configurations where the master and slaves do not use the same lock mode.
If you are using row-based or mixed-format replication, all of the auto-increment lock modes are safe, since row-based replication is not sensitive to the order of execution of the SQL statements (and the mixed format uses row-based replication for any statements that are unsafe for statement-based replication).

innodb_autoinc_lock_mode = 0 (“traditional” lock mode)
In the case of statement-based replication, this means that when an SQL statement is replicated on a slave server, the same values are used for the auto-increment column as on the master server.
The result of execution of multiple INSERT statements is deterministic, and the slave reproduces the same data as on the master. If auto-increment values generated by multiple INSERT statements were interleaved, the result of two concurrent INSERT statements would be nondeterministic, and could not reliably be propagated to a slave server using statement-based replication.

innodb_autoinc_lock_mode = 1 (“consecutive” lock mode)
This is the default lock mode. Simply put, this lock mode significantly improves scalability while being safe for use with statement-based replication.
Further, as with “traditional” lock mode, auto-increment numbers assigned by any given statement are consecutive. There is no change in semantics compared to “traditional” mode for any statement that uses auto-increment, with one important exception.

innodb_autoinc_lock_mode = 2 (“interleaved” lock mode)
In this lock mode, no “INSERT-like” statements use the table-level AUTO-INC lock, and multiple statements can execute at the same time.
This is the fastest and most scalable lock mode, but it is not safe when using statement-based replication or recovery scenarios when SQL statements are replayed from the binary log.

innodb_flush_log_at_trx_commit:
The default value of 1 -  the contents of the InnoDB log buffer are written out to the log file at each transaction commit and the log file is flushed to disk.
With a value of 0, the contents of the InnoDB log buffer are written to the log file approximately once per second and the log file is flushed to disk.
With a value of 2, the contents of the InnoDB log buffer are written to the log file after each transaction commit and the log file is flushed to disk approximately once per second.

innodb_buffer_pool_size=122M

Ref.:
http://galeracluster.com/documentation-webpages/index.html
https://dev.mysql.com/doc/refman/5.5/en/innodb-auto-increment-handling.html#innodb-auto-increment-lock-modes
https://mariadb.com/kb/en/library/galera-cluster-system-variables/
http://galeracluster.com/documentation-webpages/mysqlwsrepoptions.html



 

Comments

Popular posts from this blog

MySQL InnoDB cluster troubleshooting | commands

Cluster Validation: select * from performance_schema.replication_group_members; All members should be online. select instance_name, mysql_server_uuid, addresses from  mysql_innodb_cluster_metadata.instances; All instances should return same value for mysql_server_uuid SELECT @@GTID_EXECUTED; All nodes should return same value Frequently use commands: mysql> SET SQL_LOG_BIN = 0;  mysql> stop group_replication; mysql> set global super_read_only=0; mysql> drop database mysql_innodb_cluster_metadata; mysql> RESET MASTER; mysql> RESET SLAVE ALL; JS > var cluster = dba.getCluster() JS > var cluster = dba.getCluster("<Cluster_name>") JS > var cluster = dba.createCluster('name') JS > cluster.removeInstance('root@<IP_Address>:<Port_No>',{force: true}) JS > cluster.addInstance('root@<IP add>,:<port>') JS > cluster.addInstance('root@ <IP add>,:<port> ') JS > dba.getC...

Amazon RDS | Amzon Redshift | Big Data | Boost Performance with Amazon ElastiCache

Amazon RDS with Amazon ElastiCache for Performance: Amazon RDS supports - Oracle, MS SQL server, MySQL, Maria DB and PostgreSQL. It is a managed service offered by the Amazon.  Couple of customers have observed the performance issues during their journey with Amazon RDS with Oracle, MS SQL Server, MySQL, Maria DB and PostgreSQL. Amazon cloud engineers / database consultants / database architect and Amazon supports worked to-gather to boost the Amazon RDS performance by tuning the RDBMS configuration parameters using Amazon RDS parameter group , and have not achieved the SLA for Amazon RDS .  Amazon RDS with Multi AZ and Read Replica: Some of the the AWS professionals have suggested for vertical scaling of the Amazon RDS . It should works and its absolutely correct. In my opinion, it would be a good idea to think about the Amazon ElastiCache service with Amazon RDS for better performance and cost optimization also rather than vertically scaling the Amazon RDS . I would sug...

Needs for Graph Database

Needs for Graph Database: We are living in the era of data, data is treated more precise than gold and platinum. Most of the enterprises are trying to get more insight about the data they have it as an operational / warehouse / analytical.   Ref.: https://dist.neo4j.com/wp-content/uploads/graph-example.png To get more insight into the data, it is required to see the relationship among the data points. The challenge is how to establish the relationship among data points and the answers is Graph database. Relational databases can't help to establish the relationship among data points, due to their rigid schema, and consistent schema. Relational Database issues for data set: Number of Joins:  While fetching data from relational databases, we join many tables, these joins are complex, and consume considerable amount of computing resources, which increase the query response times. Self- joins: For database ware house / business intelligence systems using RDBMS, self-JOIN are ...