文章目录
  1. 1. The easyest way to install mysql
  2. 2. Install software
  3. 3. Install mysql
  4. 4. Create user & dictionarys
  5. 5. Configure the /etc/my.cnf
  6. 6. Initialize and start up the server
  • Done
  • The easyest way to install mysql

    Install software

    yum -y  install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL
    

    Install mysql

    Using yum to install mysql , example percona server

    1
    2
    3
    rpmkeys --import https://www.percona.com/downloads/RPM-GPG-KEY-percona
    yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
    yum install -y which perl-Digest-MD5 percona-xtrabackup-24 Percona-Server-server-57 Percona-Server-client-57 Percona-Server-shared-57

    Create user & dictionarys

    delete the default mysql user:

    userdel mysql 
    

    create user and grant the privileges:

    1
    2
    3
    4
    5
    6
    7
    groupadd mysql
    useradd -c "mysql software owner" -g mysql -G mysql mysql
    chmod 755 /home/mysql
    mkdir /data/mysql/{data,log,run,tmp} -p
    mkdir /log/mysql/{iblog,binlog} -p
    chown -R mysql:mysql /data/mysql
    chown -R mysql:mysql /log/mysql

    Configure the /etc/my.cnf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    [client]
    port=3306
    default-character-set=utf8mb4
    socket=/data/mysql/run/mysql.sock
    [mysql]
    port=330
    prompt=\\u@\\d \\r:\\m:\\s>
    default-character-set=utf8mb4
    no-auto-rehash
    socket=/data/mysql/run/mysql.sock
    [mysqld]
    character-set-server=utf8mb4
    default-storage-engine=INNODB
    default-time-zone="+08:00"
    log_timestamps=system
    #dir
    innodb_log_group_home_dir=/log/mysql/iblog
    innodb_data_home_dir=/log/mysql/iblog
    innodb_data_file_path=ibdata1:10M:autoextend:max:10G
    datadir=/data/mysql/data
    tmpdir=/data/mysql/tmp
    slave_load_tmpdir=/data/mysql/tmp
    log-error=/data/mysql/log/alert.log
    slow_query_log_file=/data/mysql/log/slow.log
    socket=/data/mysql/run/mysql.sock
    log-bin=/log/mysql/binlog/binlog
    relay-log=/log/mysql/binlog/relaylog
    #undo
    innodb_undo_tablespaces=2
    innodb_undo_logs=128
    innodb_undo_directory=/log/mysql/iblog
    innodb_undo_log_truncate = 1
    innodb_max_undo_log_size = 1G
    #innodb
    innodb_log_files_in_group=2
    innodb_log_file_size=128M
    innodb_buffer_pool_size=256M
    innodb_open_files=15535
    innodb_flush_log_at_trx_commit=1
    innodb_max_dirty_pages_pct=50
    innodb_io_capacity=1000
    innodb_io_capacity_max=4000
    innodb_read_io_threads=8
    innodb_write_io_threads=16
    innodb_file_format=Barracuda
    innodb_file_per_table=1
    innodb_thread_concurrency=16
    innodb_change_buffering=inserts
    innodb_checksum_algorithm=crc32
    innodb_adaptive_flushing=1
    innodb_stats_on_metadata=0
    innodb_flush_method=O_DIRECT
    innodb_log_buffer_size=10M
    innodb_flush_neighbors=0
    innodb_lock_wait_timeout=50
    innodb_sync_array_size=16
    transaction-isolation = READ-COMMITTED
    ##
    optimizer_switch='mrr_cost_based=off,batched_key_access=on'
    #table
    metadata_locks_hash_instances=256
    table_definition_cache=8192
    table_open_cache=8192
    table_open_cache_instances = 16
    #thread
    thread_stack=262144
    thread_cache_size=256
    #thread pool
    thread_handling=pool-of-threads
    thread_pool_high_prio_mode=transactions
    thread_pool_idle_timeout=60
    thread_pool_oversubscribe=8
    thread_pool_size=32
    thread_pool_stall_limit=10
    #binlog
    binlog_cache_size=5M
    binlog-format=ROW
    sync_binlog=1
    expire_logs_days=7
    log_slave_updates = 1
    relay_log_info_repository=TABLE
    master_info_repository=TABLE
    relay_log_recovery=1
    max_binlog_size=512M
    binlog-format=ROW
    # semi sync replication settings #
    plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
    rpl_semi_sync_master_enabled = 1
    rpl_semi_sync_master_timeout = 300
    rpl_semi_sync_slave_enabled = 1
    # new replication setting #
    slave-parallel-type = LOGICAL_CLOCK
    slave-parallel-workers = 16
    slave_preserve_commit_order=1
    slave_transaction_retries=128
    # gtid&repl
    gtid_mode=ON
    enforce_gtid_consistency=ON
    #slow log
    log_slow_verbosity=full
    long_query_time=0.2
    slow_query_log=1
    skip-slave-start=1
    #coms
    query_cache_type=0
    query_cache_size=0
    local-infile=0
    port=3306
    server_id=2819248362
    max_allowed_packet=64M
    read_rnd_buffer_size=16M
    join_buffer_size=8M
    sort_buffer_size=2M
    read_buffer_size=4M
    open_files_limit=65535
    lower_case_table_names=1
    character-set-server=utf8
    skip-name-resolve=1
    skip-external-locking=1
    safe-user-create
    #timeout
    connect_timeout=30
    delayed_insert_timeout =300
    innodb_rollback_on_timeout=OFF
    net_read_timeout=30
    net_write_timeout=60
    slave_net_timeout=30
    #myisam
    concurrent_insert=2
    key_buffer_size=8M
    myisam_sort_buffer_size=20M
    #coms
    query_cache_type=0
    query_cache_size=0
    local-infile=0
    port=3306
    max_connections=11100
    max_user_connections=10000
    max_connect_errors=3500
    character-set-server=utf8mb4
    skip-name-resolve

    Initialize and start up the server

    1
    2
    3
    4
    5
    su - mysql 
    # init
    mysqld --initialize-insecure
    # startup
    mysqld &

    Done

    文章目录
    1. 1. The easyest way to install mysql
    2. 2. Install software
    3. 3. Install mysql
    4. 4. Create user & dictionarys
    5. 5. Configure the /etc/my.cnf
    6. 6. Initialize and start up the server
  • Done