Lanp+keepalived Cluster (ii)

Source: Internet
Author: User



lanp+keepalived cluster (ii)


#基于不同域名

Server

{

Listen 80;

server_name nginx.postfix.local;

CharSet Utf-8;

Access_log Logs/domain.log Main;

Location/

{

Root Html/domain;

Index domain.html;

}

Error_page 502 503 504/50x.html;

Location =/50x.html

{

root HTML;

}

}

#图示, visit nginx.postfix.local

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/0E/wKioL1VytcbhJtQ6AAFTNUb84ak978.jpg "/>

#基于不同端口

Server

{

Listen 8080;

server_name 192.168.10.88;

CharSet Utf-8;

Access_log Logs/port.log Main;

Location/

{

Root Html/port;

Index port.html;

}

}

#图示, visit 192.168.10.88:8080

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/12/wKiom1VytCfzs23pAAFkJ4ToBsU209.jpg "/>

#nginx. conf configuration, based on the full configuration of different IPs, different domain names and different ports 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/6E/12/ Wkiom1vytcjix4k6aakuvgc2jis238.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/0E/wKioL1VytcjTkgO5AAGnspN_KP8190.jpg "/>


(3) Load Balancing configuration


#将访问www. postfix.local request load to 81-84 of these 4 back-end servers

#负载使用ip_hash算法

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/0E/wKioL1VytciAS4FgAACvwwJKSxA748.jpg "/>


(4) Anti-theft chain configuration


#待补充


(5) Log split configuration


#利用信号控制功能来分割日志

#!/bin/sh

#nginx Log cut every day

Log_path=/home/logs

Nginx_log=/usr/local/nginx/logs

Mkdir-p $log _path/$ (date +%y)/$ (date +%m)

MV $nginx _log/access.log $log _path/$ (date +%y)/$ (date +%m)/access.$ (date +%y%m%d). log

MV $nginx _log/error.log $log _path/$ (date +%y)/$ (date +%m)/error.$ (date +%y%m%d). log

KILL-USR1 ' Cat/usr/local/nginx/logs/nginx.pid '

#日志分割效果650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/12/wKiom1VytCmy1EQSAAEX8749nu0165.jpg "/>

#设定每天23点开始执行

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/0E/wKioL1VytcmB9viEAAEQuMZPtco839.jpg "/>


(6) Nginx+ssl


Under #证书文件存放在/usr/local/nginx/ssl

#生成1024位rsa密钥server. Key

OpenSSL genrsa-des3-out Server.key 1024

#生成server. CSR file

OpenSSL Req-new-key server.key-out SERVER.CSR

#生成server. CRT Certificate Files

OpenSSL req-new-x509-days 3650-key server.key-out server.crt

#配置nginx +ssl

Server

{

Listen 443 SSL;

SSL on;

server_name www.postfix.local;

SSL_CERTIFICATE/USR/LOCAL/NGINX/SSL/SERVER.CRT;

Ssl_certificate_key/usr/local/nginx/ssl/server.key;

Ssl_session_cache shared:ssl:1m;

Ssl_session_timeout 5m;

Ssl_ciphers high:!anull:! MD5;

Ssl_prefer_server_ciphers on;

Access_log Logs/443.log;

Location/{

Root html/443;

Index 443.html;

}

}

#图示, nginx.conf Configuration and Access effect 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/6E/12/ Wkiom1vytcrhze66aaeswrndpsw710.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/0E/wKioL1VytcrjDhfVAAI3rHV-cnM957.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/12/wKiom1VytCvidbkKAAC0QP1ybaQ501.jpg "/>


6. Performance Optimization



(1) Source code compilation optimization


#编译时取消开启debug

The following statement is found in the #在auto/CC/GCC file, with the "#" comment at the top

Cflags= "$CFLAGS-G"

#对特定CPU类型编译优化

#查看CPU类型

Cat/proc/cpuinfo | grep "model name"

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/0E/wKioL1VytcrBFnGXAABjsOHjyK8448.jpg "/>

#在编译时添加--with-cpu-opt

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/12/wKiom1VytCvTm583AACnUgReesM578.jpg "/>


(2) Tcmalloc optimized Nginx


#TCMalloc在内存分配效率和速度优化 to improve the performance of servers in high concurrency

#安装libunwind-1.1 and google-perftools-1.8.2

CD libunwind-1.1

./configure && make && make install

CD google-perftools-1.8.2

./configure && make && make install

echo "/usr/local/lib" >/etc/ld.so.conf.d/user_local_lib.conf

#编译时添加选项--with-google_perftools_module, re-compile Nginx

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/0E/wKioL1VytcvA8XidAACGwwj8pbw425.jpg "/>

./configure--prefix=/usr/local/nginx--with-pcre--with-http_stub_status_module--with-poll_module--with-http_ssl _module--with-google_perftools_module

Make && make install

#在nginx. conf global configuration is added to load google-perftools at nginx startup,

Google_perftools_profiles/tmp/tcmalloc;

#重启nginx

Kill HUP ' Cat/usr/local/nginx/logs/nginx.pid '

#查看是否已经加载google-perftools

Lsof-n | grep tcmalloc650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/12/wKiom1VytCvzfY0gAABCkOULFe0471.jpg "/ >


(3) kernel optimization


#待补充


7, Lanp



(1) source installation Nginx


#先安装依赖包

Yum-y Install Pcre-devel zlib-devel openssl-devel

./configure--prefix=/usr/local/nginx--with-pcre--with-http_stub_status_module--with-poll_module--with-http_ssl _module

Make && make install


(2) source code to install PHP and PHP-FPM


#安装php -5.5.24

#--enable-fpm enable PHP-FPM, the new version of PHP has added PHP-FPM to the core module

./configure--prefix=/usr/local/php--with-config-file-path=/etc--with-mysql=/usr/local/mysql/--enable-fpm

Make && make install

This article is from the "Love On Action" blog, please be sure to keep this source http://1055745601.blog.51cto.com/5003160/1659218

Lanp+keepalived Cluster (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.