Configure MySQL 8.0.17 Community Edition for Red Hat Linux and Cent OS:
01. Create following directory structure on each server for MySQL datadir, binlog, iblogs and temp:
/mysql/<project_name>/
/mysql/<project_name>/binlog
/mysql/<project_name>/iblogs
/mysql/<project_name>/temp
02. Edit file /etc/my.cnf as and include following minimum parameters to initialize mysqld. Make sure to change port and server-id unique for each server. Refer excel sheet.
Minimum content of /etc/my.cnf file to initialize mysqld:
datadir=/mysql/<project_name>
socket=/mysql/<project_name>/<project_name>.sock
port=<port_no>
server-id=<port_no>
log-error=/mysql/<project_name>_error.log
03. Configure systemd to manage mysqld using systemctl:
a. Edit file /usr/lib/systemd/system/mysqld.service
b. Under section [Service] include following line
PIDFile=/mysql/<project_name>/<project_name>.pid
c. Under section [Service], at Start main service, comment existing ExeStart and custom line as follows
# Start main service
#ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS
ExecStart=/usr/sbin/mysqld --defaults-file=/etc/my.cnf --daemonize --pid-file=/mysql/<project_name>/<project_name>.pid $MYSQLD_OPTS
04. Execute following command to reload system daemon and initialize mysqld
#systemctl daemon-reload
#systemctl start mysqld
Note: If it does not start and generate error check MySQL error log.
05. Check status of mysqld service using following
#systemctl status mysqld
06. Get temporary password for root a/c from mysql error log files, connect to mysql server and change root password for root account.
mysql> alter user `root`@`localhost` identified by `code`;
mysql> CREATE USER 'repl'@'%' IDENTIFIED BY '<code>';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
mysql> FLUSH PRIVILEGES;
Configure MySQL parameter:
Edit file /etc/my.cnf file, included following parameters, and bounce mysqld service. Make sure to update host related parameters such as IP address, port, server-id, seeds etc.
#### Custom Parameters
####
tmpdir=/mysql/<project_name>/temp
default_authentication_plugin=mysql_native_password
max_allowed_packet=1024M
event_scheduler=ON
tmp_table_size=83886080
max_heap_table_size=83886080
max_connections=500
log_timestamps=SYSTEM
disabled_storage_engines= MyISAM,BLACKHOLE,FEDERATED,ARCHIVE
#Storage Engine MyISAM is required during upgrade
#disabled_storage_engines= BLACKHOLE,FEDERATED,ARCHIVE
#### Customization end
########################
## -- InnoDB parameters
########################
innodb_log_group_home_dir=/mysql/<project_name>/iblogs
innodb_temp_data_file_path =/mysql/<project_name>/temp/ibtmp1:2G:autoextend
innodb_flush_method=O_DIRECT
innodb_log_file_size=250M
innodb_log_files_in_group=2
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_buffer_pool_size=1G
##########################
## -- Binlog configuration
##########################
binlog_format= ROW
log_bin=/mysql/<project_name>/binlog/<project_name>-bin
log_bin_index=/mysql/<project_name>/binlog/<project_name>-bin.index
max_binlog_size=10M
binlog_rows_query_log_events=ON
###################
## -- Master Slave
###################
gtid-mode=on
enforce-gtid-consistency=true
relay-log-info-repository=TABLE
master-info-repository=TABLE
relay-log=/mysql/<project_name>/binlog/<project_name>-relay
relay-log-index=/mysql/<project_name>/binlog/<project_name>-relay.index
expire_logs_days = 7
Slave Configure:
mysql> CHANGE MASTER TO
MASTER_HOST = '<master_hostname>',
MASTER_PORT = <port_no>,
MASTER_USER = 'repl',
MASTER_PASSWORD = '<code>',
MASTER_AUTO_POSITION = 1;
Start Slave:
mysql> start slave;
01. Create following directory structure on each server for MySQL datadir, binlog, iblogs and temp:
/mysql/<project_name>/
/mysql/<project_name>/binlog
/mysql/<project_name>/iblogs
/mysql/<project_name>/temp
02. Edit file /etc/my.cnf as and include following minimum parameters to initialize mysqld. Make sure to change port and server-id unique for each server. Refer excel sheet.
Minimum content of /etc/my.cnf file to initialize mysqld:
datadir=/mysql/<project_name>
socket=/mysql/<project_name>/<project_name>.sock
port=<port_no>
server-id=<port_no>
log-error=/mysql/<project_name>_error.log
03. Configure systemd to manage mysqld using systemctl:
a. Edit file /usr/lib/systemd/system/mysqld.service
b. Under section [Service] include following line
PIDFile=/mysql/<project_name>/<project_name>.pid
c. Under section [Service], at Start main service, comment existing ExeStart and custom line as follows
# Start main service
#ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS
ExecStart=/usr/sbin/mysqld --defaults-file=/etc/my.cnf --daemonize --pid-file=/mysql/<project_name>/<project_name>.pid $MYSQLD_OPTS
04. Execute following command to reload system daemon and initialize mysqld
#systemctl daemon-reload
#systemctl start mysqld
Note: If it does not start and generate error check MySQL error log.
05. Check status of mysqld service using following
#systemctl status mysqld
06. Get temporary password for root a/c from mysql error log files, connect to mysql server and change root password for root account.
mysql> alter user `root`@`localhost` identified by `code`;
mysql> CREATE USER 'repl'@'%' IDENTIFIED BY '<code>';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
mysql> FLUSH PRIVILEGES;
Configure MySQL parameter:
Edit file /etc/my.cnf file, included following parameters, and bounce mysqld service. Make sure to update host related parameters such as IP address, port, server-id, seeds etc.
#### Custom Parameters
####
tmpdir=/mysql/<project_name>/temp
default_authentication_plugin=mysql_native_password
max_allowed_packet=1024M
event_scheduler=ON
tmp_table_size=83886080
max_heap_table_size=83886080
max_connections=500
log_timestamps=SYSTEM
disabled_storage_engines= MyISAM,BLACKHOLE,FEDERATED,ARCHIVE
#Storage Engine MyISAM is required during upgrade
#disabled_storage_engines= BLACKHOLE,FEDERATED,ARCHIVE
#### Customization end
########################
## -- InnoDB parameters
########################
innodb_log_group_home_dir=/mysql/<project_name>/iblogs
innodb_temp_data_file_path =/mysql/<project_name>/temp/ibtmp1:2G:autoextend
innodb_flush_method=O_DIRECT
innodb_log_file_size=250M
innodb_log_files_in_group=2
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_buffer_pool_size=1G
##########################
## -- Binlog configuration
##########################
binlog_format= ROW
log_bin=/mysql/<project_name>/binlog/<project_name>-bin
log_bin_index=/mysql/<project_name>/binlog/<project_name>-bin.index
max_binlog_size=10M
binlog_rows_query_log_events=ON
###################
## -- Master Slave
###################
gtid-mode=on
enforce-gtid-consistency=true
relay-log-info-repository=TABLE
master-info-repository=TABLE
relay-log=/mysql/<project_name>/binlog/<project_name>-relay
relay-log-index=/mysql/<project_name>/binlog/<project_name>-relay.index
expire_logs_days = 7
Slave Configure:
mysql> CHANGE MASTER TO
MASTER_HOST = '<master_hostname>',
MASTER_PORT = <port_no>,
MASTER_USER = 'repl',
MASTER_PASSWORD = '<code>',
MASTER_AUTO_POSITION = 1;
Start Slave:
mysql> start slave;
Comments
Post a Comment