【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例
【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例
nginx版本: nginx-1.9.8
参考来源:
【高可用HA】Apache (2) —— Mac下安装多个Apache Tomcat实例
Nginx on Mac OS X Snow Leopard in 2 Minutes
iteye:图文解说:Nginx+tomcat配置集群负载均衡
安装
首先
从nginx官方网站下载
编译配置
执行命令
$ ./configure --prefix=/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a --with-http_ssl_module
执行结果末尾几行
...
nginx error log file: "/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs/error.log"
nginx http access log file: "/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
执行命令
$ make
执行结果末尾几行
...
objs/src/http/modules/ngx_http_upstream_zone_module.o \
objs/ngx_modules.o \
-lpcre -lssl -lcrypto -lz
/Library/Developer/CommandLineTools/usr/bin/make -f objs/Makefile manpage
sed -e "s|%%PREFIX%%|/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a|" \
-e "s|%%PID_PATH%%|/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
执行命令
$ sudo make install
执行结果末尾几行
test -d '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs' || mkdir -p '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs'
test -d '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs' || mkdir -p '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs'
test -d '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/html' || cp -R html '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a'
test -d '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs' || mkdir -p '/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs'
修改服务器启动配置
将端口修改成85(与其他文章中httpd的端口区分),并修改location配置Proxy
server {
listen 85;
server_name localhost;#charset koi8-r; #access_log logs/host.access.log main; # location / {
# root html;
# index index.html index.htm;
# } location / {
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://localhost;
}
...
增加转发路由的配置,并指向之前配好的两台Tomcat服务器
upstream localhost {
#根据ip计算将请求分配各那个后端tomcat,许多人误认为可以解决session问题,其实并不能。
#同一机器在多网情况下,路由切换,ip可能不同
#ip_hash;
server localhost:8081;
server localhost:8082;
}
运行
执行命令
$ ./sbin/nginx
提示错误
nginx: [alert] could not open error log file: open() "/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/logs/error.log" failed (13: Permission denied)
2015/12/09 16:26:55 [emerg] 16550#0: mkdir() "/Users/Richard/Documents/Dev/servers/cluster/nginx/node-a/client_body_temp" failed (13: Permission denied)
*这是因为nginx没有相应的权限
运行命令授权或者以sudo运行
$ sudo ./sbin/nginx
启动
$ sudo ./sbin/nginx -s stop
测试
用浏览器访问localhost:85,页面中会交替出现"Node-A!!"和"Node-B!!"

结束
【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例的更多相关文章
- 【高可用HA】Apache (4) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk
Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk httpd版本: httpd-2.4.17 jk版本: tomcat-connectors-1.2.41 参考 ...
- 【高可用HA】Apache (3) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy
Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy httpd版本: httpd-2.4.17 参考来源: Apache (1) -- Mac下安装Apac ...
- Hadoop 高可用(HA)的自动容灾配置
参考链接 Hadoop 完全分布式安装 ZooKeeper 集群的安装部署 0. 说明 在 Hadoop 完全分布式安装 & ZooKeeper 集群的安装部署的基础之上进行 Hadoop 高 ...
- Mac下配置Nginx负载均衡
1.首先在Mac下安装Nginx(可参考我的另一篇随笔http://www.cnblogs.com/malcolmfeng/p/6896703.html). 2.安装Tomcat,下载后,解压,bin ...
- mac下配置nginx
nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,下面我们来了解下nginx的用法. 安装nginx 使用brew安装nginx brew install ...
- mysql高可用架构方案之二(keepalived+lvs+读写分离+负载均衡)
mysql主从复制与lvs+keepalived实现负载高可用 文件夹 1.前言 4 2.原理 4 2.1.概要介绍 4 2.2.工作原理 4 2.3.实际作用 4 3方 ...
- Nginx 在windows下配合iis搭建负载均衡过程 [转]
因为项目遇到大量图片存储问题,虽然现在我们图片还不是很多(目前在1T上下,预计增长速度每年1.3倍的增长速度),自己在思考如何有效地存储大量图片时,查找一些资料,看到了,有人使用 Nginx搭建服务器 ...
- Mac 下配置Nginx安装环境配置详细说明
环境信息: Mac OS X 10.11.1 Homebrew 0.9.5 正文 一.安装 Nginx 1.终端执行: ? 1 2 brew search nginx brew install ng ...
- mac下配置nginx php
修改 php-fpm 文件 1.执行命令: sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf 2.找到目录下的 p ...
随机推荐
- 使用CXF实现基于Rest方式的WebService(转)
转自:https://www.cnblogs.com/zjm701/p/6845813.html原文更清晰 本文介绍使用CXF实现基于Rest方式的WebService(CXF的版本是3.0.0) 一 ...
- HDUOJ---kiki's game
kiki's game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/1000 K (Java/Others)Total ...
- eclipse 在Servers窗口创建一个Tomcat 6.0 Server失败
web项目部署到tomcat除了用eclipse插件,eclipse也有一个Servers窗口来部署. 问题背景:Servers窗口,我之前创建过一个Tomcat v6.0 Server,后来我把 ...
- lsnrctl: error while loading shared libraries: /opt/app/oracle/product/11.2/db_1/lib/libclntsh.so.11
错误描述: 安装好数据库后,在oralce用户下敲入 查看监听状态命令,返回错误提示 [oracle@centos3 ~]$ lsnrctl statuslsnrctl: error while lo ...
- Python学习笔记014——迭代器 Iterator
1 迭代器的定义 凡是能被next()函数调用并不断返回一个值的对象均称之为迭代器(Iterator) 2 迭代器的说明 Python中的Iterator对象表示的是一个数据流,被函数next()函数 ...
- Python sin() 函数
描述 sin() 返回的x弧度的正弦值. 语法 以下是 sin() 方法的语法: import math math.sin(x) 注意:sin()是不能直接访问的,需要导入 math 模块,然后通过 ...
- 以太网帧格式、IP数据报格式、TCP段格式+UDP段格式 详解
转载:http://www.cnblogs.com/lifan3a/articles/6649970.html 以太网帧格式.IP数据报格式.TCP段格式+UDP段格式 详解 1.ISO开放系统有 ...
- python标准库介绍——17 tempfile 模块详解
==tempfile 模块== [Example 2-6 #eg-2-6] 中展示的 ``tempfile`` 模块允许你快速地创建名称唯一的临时文件供使用. ====Example 2-6. 使用 ...
- mysql-5.7 show engine innodb status 详解
一.show engine innodb status 简介: show engine innodb status 是mysql提供的一个用于查看innodb引擎时间信息的工具,就目前来说有两处比较 ...
- tomcat在conf/Catalina/localhost目录下配置项目路径
转自:http://wangyl93-dl-cn.iteye.com/blog/1508517 在tomcat的conf/Catalina/localhost目录下配置项目路径,tomcat启动是会直 ...