Rate This Document
Findability
Accuracy
Completeness
Readability

Initializing the MySQL Database

Initialize the MySQL database by following instructions in MySQL Installation Guide.

Table 1 Database initialization parameters

Parameter

Description

master (Primary Database)

slave1 (Secondary Database)

slave2 (Secondary Database)

port

Port

3306

3307

3308

datadir

Data path

/data/mysql/datam

/data/mysql/datas

/data/mysql/datas2

log-error

Log path

/data/mysql/log/mysqlm.log

/data/mysql/log/mysqls.log

/data/mysql/log/mysqls2.log

pid-file

PID file path

/data/mysql/run/mysqldm.pid

/data/mysql/run/mysqlds.pid

/data/mysql/run/mysqlds2.pid

socket

Socket path

/data/mysql/run/mysqlm.sock

/data/mysql/run/mysqls.sock

/data/mysql/run/mysqls2.sock

mysqlx_socket

mysqlx_socket path

/data/mysql/run/mysqlxm.sock

/data/mysql/run/mysqlxs.sock

/data/mysql/run/mysqlxs2.sock

mysqlx_port

mysqlx_port port

33060

33070

33080

  1. Configure the primary database.
    1
    2
    mkdir -p /data/mysql/datam
    vim /etc/my.cnf-master-mgr
    

    Edit the content as follows:

    [mysqld_safe]
    log-error=/data/mysql/log/mysqlm.log
    pid-file=/data/mysql/run/mysqldm.pid
    
    [client]
    socket=/data/mysql/run/mysqlm.sock
    default-character-set=utf8
    
    [mysqld]
    skip-name-resolve
    basedir=/usr/local/mysql
    socket=/data/mysql/run/mysqlm.sock
    mysqlx_socket=/data/mysql/run/mysqlxm.sock
    tmpdir=/data/mysql/tmp
    datadir=/data/mysql/datam
    default_authentication_plugin=mysql_native_password
    mysqlx_port=33060
    port=3306
    user=root
    report_host=127.0.0.1
    #innodb_page_size=4k
    
    max_connections=2000
    back_log=4000
    performance_schema=OFF
    max_prepared_stmt_count=128000
    #transaction_isolation=READ-COMMITTED
    
    #file
    innodb_file_per_table
    innodb_log_file_size=2048M
    innodb_log_files_in_group=32
    innodb_open_files=10000
    table_open_cache_instances=64
    
    #buffers
    innodb_buffer_pool_size=44G
    innodb_buffer_pool_instances=16
    innodb_log_buffer_size=2048M
    
    #tune
    sync_binlog=1
    innodb_flush_log_at_trx_commit=1
    innodb_use_native_aio=1
    innodb_spin_wait_delay=180
    innodb_sync_spin_loops=25
    innodb_flush_method=O_DIRECT
    innodb_io_capacity=30000
    innodb_io_capacity_max=40000
    innodb_lru_scan_depth=9000
    innodb_page_cleaners=16
    #innodb_spin_wait_pause_multiplier=25
    
    #perf special
    innodb_flush_neighbors=0
    innodb_write_io_threads=24
    innodb_read_io_threads=16
    innodb_purge_threads=32
    sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES
  2. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. On the secondary database, create /data/mysql/datas and /data/mysql/datas2 directories and edit the /etc/my.cnf-slave-mgr and /etc/my.cnf-slave-2-mgr files. Change the paths in the file according to the actual situation.