以下内容在测试环境做调整,然后就写文档。
系统调优方面:
1.内核参数调整
additional
net.ipv4.ip_local_port_range = 1024 65535
net.core.somaxconn = 2048
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 20000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_orphans = 131072
vm.overcommit_memory=1
fs.file-max = 209708
这些内容添加到/etc/sysctl.conf 里
2.句柄数量调整
* soft nofile 209870
* hard nofile 209870
这个内容添加到/etc/security/limits.conf
3. Nproc调整
/etc/security/limits.d/90-nproc.conf 这个文件里的nproc也要改成209870.调成20万。不用是默认的1024.
TOMCAT方面:
4.JDK和TOMCAT版本调整
不能用系统自带的openJDK,应该卸载openJDK,下载java-jdk. 最少要1.7.52以上版本。tomcat也不要用tomcat6了。用tomcat7或者tomcat8。
5.TOMCAT调优
tomcat安装后,把最大线程数调到5000-8000. URLEncoding改成UTF-8,同时使用NIO替换BIO方式,使用jsvc守护进程,如果tomcat挂掉可以自动重启。
MYSQL方面:
6.MYSQL 调优
mysql配置更改如下
[mysqld]
character-set-server=utf8
max_connections=2000
max_connect_errors = 1000000
long_query_time=2
slow_query_log=on
slow_query_log_file=/home/db/mysqldata/slow.log
log_queries-not-using-indexes = 1
expire_logs_days = 15
skip-name-resolve = 1
skip_external_locking = 1
innodb_io_capacity = 500
innodb_flush_method = O_DIRECT
innodb_lock_wait_timeout = 5
innodb_log_buffer_size = 8388608
innodb_print_all_deadlocks = on
innodb_flush_log_at_trx_commit = 2
innodb_autoextend_increment = 64
innodb_thread_concurrency = 0
innodb_old_blocks_time = 1000
innodb_buffer_pool_instances = 8
innodb_lru_scan_depth = 512
innodb_flush_neighbors = 1
innodb_checksum_algorithm = crc32
innodb_buffer_pool_dump_at_shutdown = on
innodb_buffer_pool_load_at_startup = on
innodb_buffer_pool_dump_pct = 40
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_buffer_pool_size = 120000M
innodb_file_per_table=1
lower_case_table_names=1
【注意】:
这里面对性能影响比较的主要是:
innodb_buffer_pool_size
innodb_log_buffer_size
innodb_log_file_size
skip-name-resolve
table_open_cache
NGINX方面
8.NGINX调整
安装nginx的文档有点滞后了。需要更新一下。可以参考这篇文章:
https://yq.aliyun.com/articles/7171。 将 http2.0模块包含进去。 http2.0在https上速度比http还要快
9.nginx安装第三方模块
nginx没有安装任何第三方模块,甚至连openssl模块都没包含进去,意味着不能使用https. 至少先把openssl装上,其他的查一查网上哪些是必须装的。
参考参数如下:
./configure --prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-pcre --with-luajit --add-module=../ngx_cache_purge-2.3/ --add-module=../nginx_upstream_check_module-0.3.0/ -j2 --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-file-aio --with-http_v2_module