Nginx Tomcat6配置負載均衡

2021-09-05 23:30:51 字數 1109 閱讀 9007

安裝nginx

# ./configure

# make

# make install

在這裡假定nginx安裝在nginxhost,tomcat分別安裝在tomcathost1和tomcathost2上;

2. 修改/usr/local/nginx/conf/nginx.conf檔案,

3. 確定nginxhost和兩台tomcathost可以互訪,並且兩個tomcat機器在乙個網段內;

4. 確定兩台tomcat host多播已經開啟,在linux機器上可以使用cat /proc/net/dev_mcast檢查,如果檔案存在基本上就是開啟了;另外確定兩台tomcat機器的/etc/hosts檔案中包含「***.***.***.***    hostname」比如「172.17.1.101    tomcathost1」或「172.17.1.102    tomcathost2」;

5. 修改兩個tomcat的conf/server.xml檔案,對engine節點分別新增jvmroute="tomcat1"和jvmroute="tomcat2",並新增以下內容:

<% string mydata = request.getparameter("mydata"); if (mydata != null && mydata.length() != 0) out.println("request.getlocaladdr(): " + request.getlocaladdr()); out.println("

"); out.println("request.getlocalport(): " + request.getlocalport()); out.println("

"); out.println("session id: " + session.getid()); out.println("

"); out.println("mydata: " + session.getattribute("mydata")); %>

8. 啟動tomcat和nginx,訪問http://nginxhost/examples/,可以修改其中session中的值,並且可以看到兩個tomcat的session中的值是一樣的;

Nginx Tomcat6配置負載均衡

安裝nginx configure make make install 在這裡假定nginx安裝在nginxhost,tomcat分別安裝在tomcathost1和tomcathost2上 2.修改 usr local nginx conf nginx.conf檔案,3.確定nginxhost和兩台...

Nginx Tomcat6配置負載均衡

nginx tomcat6配置負載均衡 安裝nginx configure make make install 在這裡假定nginx安裝在nginxhost,tomcat分別安裝在tomcathost1和tomcathost2上 2.修改 usr local nginx conf nginx.con...

Nginx Tomcat6配置負載均衡

安裝nginx configure make make install 在這裡假定nginx安裝在nginxhost,tomcat分別安裝在tomcathost1和tomcathost2上 2.修改 usr local nginx conf nginx.conf檔案,3.確定nginxhost和兩台...