准备环境
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y openssl openssl-devel
准备nginx:
下载:# wget http://nginx.org/download/nginx-1.8.1.tar.gz
解压:# tar -zxvf nginx-1.8.1.tar.gz
进入目录:# cd nginx-1.8.1
配置nginx:# ./configure --prefix=/usr/src/nginx --with-http_stub_status_module --with-http_ssl_module
编译安装:# make && make install
查看nginx版本:
进入安装目录:# cd /usr/src/nginx/sbin
查看版本:# ./nginx -v
设置开机启动
编辑/etc/rc.local:# vim /etc/rc.local
添加一行:/usr/src/nginx/sbin/nginx
,之后,开机会自动启动nginx
nginx 命令
进入nginx目录:# cd /usr/src/nginx/sbin
启动服务:# ./nginx
停止服务:# ./nginx -s stop
重启服务:# ./nginx -s reopen
重新载入配置文件:# ./nginx -s reload
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream minio{
server 172.28.8.65:9000;
server 172.28.8.61:9000;
server 172.28.8.62:9000;
server 172.28.8.63:9000;
}
server {
listen 9001;
server_name 172.28.8.111;
location / {
proxy_pass http://minio;
proxy_set_header Host $http_host;
client_max_body_size 1000m;
}
}
}
3.配置双主热备
! Configuration File for keepalived
global_defs {
notification_email {
guchang.pan@hand-china.com
2660292608@qq.com
}
notification_email_from guchang.pan@hand-china.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id MYCAT_HA
}
vrrp_instance VI_1 {
state MASTER
interface ens192
virtual_router_id 52 #路由器标识,MASTER和BACKUP必须是一致的
priority 101 #定义优先级,数字越大,优先级越高,在同一个vrrp_instance下,MASTER的优先级必须大于BACKUP的优先级。这样MASTER故障恢复后,就可以将VIP资源再次抢回来
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.28.8.111/24
}
}
virtual_server 172.28.8.111 80 {
delay_loop 6
protocol TCP
real_server 172.28.8.65 80 {
notify_down "kill -9 $(cat /var/run/keepalived.pid)"
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
潘顾昌
原创文章 7获赞 2访问量 299
关注
私信
展开阅读全文