Mycat cluster optimization of --Mycat

Linux optimal allocation

Optimization /etc/sysctl.conf file

net.ipv4.ip_forward= 0

kernel.sysrq = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
vm.overcommit_memory = 1
net.ipv4.tcp_max_syn_backlog = 1638400
net.core.somaxconn = 1638400
net.core.netdev_max_backlog = 20000
net.ipv4.tcp_max_tw_buckets = 1800000
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 90
net.ipv4.ip_local_port_range = 1024 65000 
net.ipv4.tcp_window_scaling = 1
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.tcp_sack = 0
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_orphan_retries = 3
net.ipv4.tcp_reordering = 5
net.ipv4.tcp_retrans_collapse = 0
net.ipv4.tcp_wmem = 51200 131072 4194304
net.ipv4.tcp_rmem = 51200 131072 4194304
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

net.netfilter.nf_conntrack_max = 655350
net.netfilter.nf_conntrack_tcp_timeout_established = 90
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 60

Optimization /etc/security/limits.conf file

echo "* soft nproc 65535"  >> /etc/security/limits.conf
echo "* hard nproc 65535"  >> /etc/security/limits.conf

Mycat optimal allocation

JVM parameter optimization

JVM parameters are wrapper.conf file conf directory under the installation directory of Mycat in the configuration. For example, the following configuration

wrapper.java.additional.5=-XX:MaxDirectMemorySize=4G

For Mycat stand-alone server, up the memory it can be set to half or two-thirds of the system memory.

server.xml parameter optimization

Here Insert Picture Description

Above optimize the items are arranged in the label server.xml file system.

log4j2.xml log level optimization

Optimization generally following configuration items, generally level is set to info to log log.

<asyncRoot level="info" includeLocation="true">

MySQL optimization

My.cnf MySQL configuration through optimization

For example, the following configuration for the MySQL 8.x version of the my.cnf configuration file.

[client]
port = 3306
socket = /data/mysql/run/mysql.sock
default-character-set = utf8mb4
 
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /data/mysql/run/mysql.sock
pid_file = /data/mysql/run/mysqld.pid
basedir = /usr/local/mysql
datadir = /data/mysql/data
tmpdir = /data/mysql/tmp
open_files_limit = 65535
explicit_defaults_for_timestamp
server_id = 1
lower_case_table_names = 1
character_set_server = utf8mb4
safe_user_create
max_connections = 3000
max_user_connections=2980
secure_file_priv=/data/mysql/tmp
 
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
sync_binlog=100
back_log=1024
max_binlog_cache_size=2147483648
max_binlog_size=524288000
default_storage_engine = InnoDB
log_slave_updates = 1
 
#*********** Logs related settings ***********
log_bin = /data/mysql/log/bin_log/mysql-bin
binlog_format= mixed
binlog_cache_size=32m
max_binlog_cache_size=64m
max_binlog_size=512m
long_query_time = 1
log_output = FILE
log_error = /data/mysql/log/error_log/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/log/query_log/slow_statement.log
log_queries_not_using_indexes=0
log_slave_updates=ON
log_slow_admin_statements=1
general_log = 0
general_log_file = /data/mysql/log/general_log/general_statement.log
binlog_expire_logs_seconds = 1728000
relay_log = /data/mysql/log/bin_log/relay-bin
relay_log_index = /data/mysql/log/bin_log/relay-bin.index
#****** MySQL Replication New Feature*********
master_info_repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery
#*********** INNODB Specific options ***********
innodb_buffer_pool_size = 4096M
transaction_isolation=REPEATABLE-READ
innodb_buffer_pool_instances = 8
innodb_file_per_table = 1
innodb_data_home_dir = /data/mysql/log/innodb_ts
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_thread_concurrency = 8
innodb_log_buffer_size = 67108864
innodb_log_file_size = 1048576000
innodb_log_files_in_group = 4
innodb_max_undo_log_size=4G
innodb_undo_directory=/data/mysql/log/undo_space/
 
 
innodb_log_group_home_dir = /data/mysql/log/innodb_log/
innodb_adaptive_flushing=ON
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 60
innodb_open_files=60000
innodb_purge_threads=1
innodb_read_io_threads=4
innodb_stats_on_metadata=OFF
innodb_flush_method=O_DIRECT
[mysql]
no-auto-rehash
default-character-set=utf8mb4
net-buffer-length=64K
unbuffered
max-allowed-packet = 2G
default-character-set = utf8mb4
 
#some var for mysql8
#log_error_verbosity=3
#innodb_print_ddl_logs=1
#binlog_expire_logs_seconds=259200
#innodb_dedicate_server=0
#
#innodb_status_file=1
#innodb_status_output=0
#innodb_status_output_locks=0
 
[mysqldump]
quick
max_allowed_packet=2G
log_error=/data/mysql/log/error_log/mysql_dump_error.log
net_buffer_length=8k

About MySQL 5.6 and MySQL 5.7 and MySQL 8.x version of the full my.cnf file, you can link to https://download.csdn.net/download/l1028386804/12099311 download.

Released 1343 original articles · won praise 2093 · Views 5.25 million +

Guess you like

Origin blog.csdn.net/l1028386804/article/details/104911415