mysql优化后的主配置文件
#!/bin/bash basedir=$mysql datadir=$mysql/data server_id=$(hostname -I | awk '{print $NF}'|awk -F '.' '{print $NF}') mem=$(free | awk NR==2'{print $2}') innodb_buffer_pool_size=$(($mem/2/1024/1024+1))G cat >/etc/my.cnf <<EOF [mysqld] basedir = ${basedir} datadir = ${datadir} character_set_server = utf8 skip_name_resolve = on innodb_buffer_pool_size =${innodb_buffer_pool_size} innodb_write_io_threads = 8 innodb_read_io_threads= 8 innodb_log_file_size = 128M innodb_log_buffer_size = 32M innodb_page_cleaners = 4 innodb_io_capacity = 5000 innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT max_allowed_packet = 32M max_connections = 4000 key_buffer_size = 32M read_buffer_size = 2M read_rnd_buffer_size = 16M sort_buffer_size = 8M join_buffer_size = 8M thread_stack = 256K thread_cache_size = 64 query_cache_limit = 8M query_cache_size = 64M query_cache_type = 1 server_id = ${server_id} log_bin = mysql-bin binlog_format = row relay_log = relay-log gtid_mode = ON enforce_gtid_consistency = true master_info_repository = TABLE relay_log_info_repository = TABLE slave_parallel_type = LOGICAL_CLOCK slave_parallel_workers = 8 relay_log_recovery = ON slow_query_log = on long_query_time = 3 slow_query_log_file = mysql-slow.log expire_logs_days = 40 log_error = mysql.log log_bin_trust_function_creators = on sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" lower_case_table_names = 1 log_timestamps = SYSTEM
group_concat_max_len = 10240000 EOF