Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created May 11, 2016 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhyland87/94d3e04d720c57a69133622e0ae7ac2c to your computer and use it in GitHub Desktop.
Save jhyland87/94d3e04d720c57a69133622e0ae7ac2c to your computer and use it in GitHub Desktop.
Bash script to create /etc/my.cnf for mysql master replicator
cp /etc/my.cnf{,.orig} && \
echo "#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPUs*2 for thread_concurrency
thread_concurrency = 8
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = $(nmcli con show eno16777984 | grep -E '^ipv4.address' | grep -o -P '(?<=[0-9]{3}.[0-9]{3}.[0-9]{1}.).*(?=/24)')
# Replication settings
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = $(nmcli con show eno16777984 | grep -E '^ipv4.address' | grep -o -P '(?<=[0-9]{3}.[0-9]{3}.[0-9]{1}.).*(?=/24)')
log-bin = \"mysql-bin\"
binlog-ignore-db = test
binlog-ignore-db = information_schema
binlog-ignore-db = mysql
binlog-ignore-db = performance_schema
replicate-ignore-db = test
replicate-ignore-db = information_schema
replicate-ignore-db = mysql
replicate-ignore-db = performance_schema
relay-log = \"mysql-relay-log\"
binlog-format = ROW
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout" > /etc/my.cnf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment