HEX
Server: nginx/1.22.1
System: Linux VM-16-9-centos 3.10.0-1160.99.1.el7.x86_64 #1 SMP Wed Sep 13 14:19:20 UTC 2023 x86_64
User: www (1001)
PHP: 7.3.31
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //www/server/mysql/support-files/setmycnf.sh
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
cpuInfo=`cat /proc/cpuinfo |grep "processor"|wc -l`
sed -i 's/innodb_write_io_threads = 4/innodb_write_io_threads = '${cpuInfo}'/g' /etc/my.cnf
sed -i 's/innodb_read_io_threads = 4/innodb_read_io_threads = '${cpuInfo}'/g' /etc/my.cnf
MemTotal=`free -m | grep Mem | awk '{print  $2}'`
if [[ ${MemTotal} -gt 1024 && ${MemTotal} -lt 2048 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 128#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 16M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" /etc/my.cnf
	sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 64M#" /etc/my.cnf
	sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 16M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 2048 && ${MemTotal} -lt 4096 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 256#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /etc/my.cnf
	sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 128M#" /etc/my.cnf
	sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 32M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 4096 && ${MemTotal} -lt 8192 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 512#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 64M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" /etc/my.cnf
	sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 256M#" /etc/my.cnf
	sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 64M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 8192 && ${MemTotal} -lt 16384 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 1024#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 128M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" /etc/my.cnf
	sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 512M#" /etc/my.cnf
	sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 128M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 16384 && ${MemTotal} -lt 32768 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 2048#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 256M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" /etc/my.cnf
	sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf
	sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 256M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 32768 ]]; then
	sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" /etc/my.cnf
	sed -i "s#^table_open_cache.*#table_open_cache = 4096#" /etc/my.cnf
	sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" /etc/my.cnf
	sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" /etc/my.cnf
	sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" /etc/my.cnf
	sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" /etc/my.cnf
	sed -i "s#^query_cache_size.*#query_cache_size = 512M#" /etc/my.cnf
	sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" /etc/my.cnf
	sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" /etc/my.cnf
	if [ "${version}" == "5.5" ];then
		sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf
		sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 256M#" /etc/my.cnf
	else
		sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 2048M#" /etc/my.cnf
		sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 512M#" /etc/my.cnf
	fi
fi