In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to configure nginx + mysql server, I hope you will learn something after reading this article, let's discuss it together!
# dual-core CPUuser nobody;worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000; worker_rlimit_nofile 65535 linux2.6 error.log / var/log/nginx/error.log warn;pid / var/run/nginx.pid;events {use epoll; # epoll is one of the ways of multiplexing IO (linux2.6 O Multiplexing), but only for kernels above linux2.6, it can greatly improve the performance of nginx multi_accept on Worker_connections 2048;} http {include / etc/nginx/mime.types; default_type application/octet-stream; server_tokens off; log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"' Access_log / var/log/nginx/access.log main; # tcp_nopush on; tcp_nopush on; tcp_nodelay on; access_log off; client_header_timeout 10; client_body_timeout 10; reset_timedout_connection on; send_timeout 10; keepalive_timeout 65 Ten # timeout client_header_buffer_size 4k # buffer size of the client request header, which can be set according to the paging size of your system: open_file_cache max=102400 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 1; gzip on; gzip_disable "msie6"; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 4 The gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # compression type already contains text/html by default, so there is no need to write below, and there will be no problem writing it, but there will be a warn. Include / etc/nginx/conf.d/*.conf;} server {listen 80; server_name www.test.com.cn test.com.cn; # charset koi8-r; # access_log / var/log/nginx/log/host.access.log main; location / {root / www/www/test; index index.html index.htm index.php; autoindex off } # error_page 404 / 404.html; # redirect server error pages to the static page / 50x.html # error_page 500502503504 / 50x.html; location = / 50x.html {root / usr/share/nginx/html } # proxy the PHP scripts to Apache listening on 127.0.0.1 php$ 80 # # location ~. Php$ {# proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.1 # location ~. Php$ {# root html; # fastcgi_pass 127.0.1 # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name; # include fastcgi_params; #} location ~ * ^ / (attachment | static | images) /. *. (php | php5) ${deny all;} location ~ * ^ / addons/ewei/ (static | images | data | cert) /. * (php | php5) ${deny all } location ~\ .php$ {root / www/www/test; fastcgi_pass 127.0.0.1 root 9000; # fastcgi_pass unix:/dev/shm/fpm-cgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params } location ~. *\. (gif | jpg | jpeg | png | swf) ${expires 15d;} location ~. *\. (js | css)? ${expires 1d;} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # # location ~ /\ .ht {# deny all; #}}
Myssql5.7 configuration
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M## Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed Experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2Mdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pidslow_query_log=ONlong_query_time=1slow_query_log_file = / var/log/mysql/mysql-slow.loggeneral_log_file=/var/log / mysql/mysql-general-log.loggeneral_log = OFF# avoids external locking of Mysql Reduce the probability of error and enhance stability: if skip-external-locking# is 1, then the query is always looked up in the query cache first, even if sql_no_cache is used, the query cache is still used, because sql_no_cache simply does not cache query results, not use query results. The value of the query_cache_type=1#back_log parameter indicates how many requests can be saved in a short period of time before MySQL temporarily stops responding to new requests. In the pair stack, if the system has many connections in a short period of time, you need to > to increase the value of this parameter, which specifies the size of the listening queue for incoming TCP/IP connections. Different operating systems have their own limits on the size of this queue, setting back_log higher than the operating system limit will be invalid, the default value is 50, for LINUX systems, it is recommended to be set to an integer less than 512: back_log=100binlog_cache_size=64M# index buffer size, increase it to get better index processing performance, for memory 4GB or so servers, this parameter can be set to 256m or 384m. If the parameter value is set too large > it will reduce the overall efficiency of the server: key_buffer_size=512M# sets the maximum number of messages transmitted in the network transmission, the system default value is 1MB, and the maximum value is 1GB, which must be set to a multiple of 1024, in bytes: max_allowed_packet=64M# sets the stack size of each thread of MySQL, and the default value is large enough to meet normal operations. The range can be set from 128KB to 4GB. The default 192K:thread_stack=64Msort_buffer_size=64Mmax_connect_errors = 6000open_files_limit = 65535table_open_cache=256max_heap_table_size=16M# sets the maximum number of connection pool threads that can be cached in the Thread Cache pool, which can be set to 0-16384, with a default of 0. 1GB memory we configure to 8JZ 2GB memory We configure 16JI 4GB or above 4GB we configure 64:thread_cache_size=64# to specify the size of the Mysql query buffer, you can observe it in the Mysql console. If the value of Qcache_lowmem_prunes is very large, it indicates that the buffer is often insufficient, if the value of Qcache_hits is very large. Indicates that query buffering is used very frequently: query_cache_size=64Mquery_cache_limit=64M# sets the maximum value of the internal temporary table, and if it exceeds this value, the temporary table will be written to disk, which ranges from 1KB to 4GB:tmp_table_size=64M# to specify the maximum connection time for a request, for servers around 4GB. You can set it to 5-10:wait_timeout=20# to enable this option to completely turn off MYSQL's TCP/IP connection mode. If the WEB server accesses MYSQL's database server by remote connection, do not turn on this option, otherwise > will not be able to connect normally. Skip-networking complains that Innodb is 100 times slower than MyISAM? So you probably forgot to adjust this value. The default value of 1 means that every transaction commit or instruction outside a transaction needs to be written to (flush) the hard disk, which is time-consuming. Especially when using battery powered cache (Battery backed up cache). Set to 2 is OK for many applications, especially those transferred from the MyISAM table >, which means writing not to the hard disk but to the system cache. Logs still flush to the hard disk per second, so you don't usually lose updates of more than 1-2 seconds. Setting it to 0 will be faster, but the security > aspect is poor, and even if the MySQL is down, the transaction data may be lost. A value of 2 can only lose data when the entire operating system # is down: innodb_flush_log_at_trx_commit=2#, which is the buffer used by the transaction log of the InnoDB storage engine. Similar to when Binlog Buffer,InnoDB writes transaction logs, in order to improve performance, the information is written > to Innofb Log Buffer first, and only when the corresponding condition set by innodb_flush_log_trx_commit parameter (or log buffer is full) is met, the log is written to text > (or synchronized to disk). You can set the maximum memory space it can use through the innodb_log_buffer_size parameter: innodb_log_buffer_size=64Minnodb_buffer_pool_size=64Minnodb_log_file_size=1Ginnodb_file_per_table=1innodb_read_io_threads=10innodb_write_io_threads=10innodb_flush_method=O_DIRECTinnodb_io_capacity=1000innodb_io_capacity_max=1000innodb_lru_scan_depth=500innodb_thread_concurrency=0 innodb_autoinc_lock_mode=2innodb_log_files_in_group=3innodb_max_dirty_pages_pct=90innodb_lock_wait_timeout=100bulk The default size for _ insert_buffer_size = 16m innodb_thread_concurrency = 8innodb_purge_threads = 1#tmp_table_size is 32m. If a temporary table exceeds this size, MySQL generates an error in the form of The table tbl_name is full. If you do a lot of # advanced GROUP BY queries, increase the tmp_table_size value: tmp_table_size=512M# random read data buffer uses memory (read_rnd_buffer_size): corresponding to sequential read, when MySQL does non-sequential read (random read) data blocks, it will use the > buffer to temporarily store the read data. Such as reading table data according to index information, Join according to the sorted result set and table, and so on. Generally speaking, when data blocks need to be read in a certain order, MySQL needs to generate random reads and then use the memory buffer set by the read_rnd_buffer_size parameter: read_rnd_buffer_size=128M# default configuration does not turn on query caching: explicit_defaults_for_timestamp# needs a database that records binary logs. If you have multiple databases that can be separated by commas, or use multiple binlog-do-db options: binlog-do-db=dbname# does not need a database that records binary logs. If there are multiple databases that can be separated by commas, or use multiple binlog-do-db options: binlog-ignore-db=dbname# filters out some errors that are not a big problem: slave-skip-errors=allsql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_ support [mysqldump] host=localhostuser=mysqlbackpassword='password' has finished reading this article, I believe you have some understanding of "how to configure the server with nginx + mysql", if you want to know more about it Welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.