Skip to main content

Configure MySQL 8.0.17 Community Edition for Red Hat Linux and Cent OS

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;

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

MySQL slave Error_code: 1032 | MySQL slave drift | HA_ERR_KEY_NOT_FOUND

MySQL slave Error_code: 1032 | MySQL slave drift: With several MySQL, instance with master slave replication, I have one analytics MySQL, environment which is larger in terabytes, compared to other MySQL instances in the environment. Other MySQL instances with terabytes of data are running fine master, slave replication. But this analytics environment get started generating slave Error_code :1032. mysql> show slave status; Near relay log: Error_code: 1032; Can't find record in '<table_name>', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log <name>-bin.000047, end_log_pos 5255306 Near master section: Could not execute Update_rows event on table <db_name>.<table_name>; Can't find record in '<table_name>', Error_code: 1032; Can't find record in '<table_name>', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log <name>-bin.000047, end_l

Create MySQL database with hyphen

Create MySQL database with hyphen: If you are trying to create MySQL database with hyphen " - " in the name such as test-db and get error  " your MySQL server version for the right syntax to use near '-db' at line" then you might be wondering how to get it done as your business require MySQL database name with hyphen " - "  Here is the fix, use escape character " ` " before and after database name such as `test-db` and you will be able to create database with hyphen. CREATE DATABASE `test-db`;