国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

nginx+tomcat實(shí)現(xiàn)負(fù)載均衡,使用redis session共享

2019-11-02 16:37:22
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

環(huán)境準(zhǔn)備

1、準(zhǔn)備一臺(tái)nginx服務(wù)器 ip192.168.1.133 端口81

安裝過(guò)程:

#首先安裝依賴:yum -y install gcc-c++ yum -y install pcre pcre-devel yum -y install zlib zlib-devel yum -y install openssl openssl―devel#注意 : 安裝nginx必須使用 root 用戶安裝#創(chuàng)建一個(gè)nginx目錄mkdir /usr/local/src/nginx#進(jìn)入到nginx目錄cd /usr/local/src/nginx#下載或上傳安裝包wget http://nginx.org/download/nginx.tar.gz 或 rz上傳#解壓安裝包tar -xvf nginx.tar.gz#進(jìn)入到解壓后的目錄cd nginx# 下面 才開(kāi)始正式安裝#把nginx安裝到指定用戶的目錄mkdir -p /ucenter/soft/nginx#安裝配置 prefix為安裝目錄 user為用戶 group為 組./configure --prefix=/ucenter/soft/nginx --user=ucenter --group=ucenter#編譯make #安裝make install#在linux系統(tǒng)中由于非root用戶不能占用80端口,所以需要使普通用戶以root身份啟動(dòng)nginx。 cd /ucenter/soft/nginx/sbin#把soft文件下所有的文件所屬者修改為ucener -R 表示遞歸chown ucenter:ucenter ./soft/ -R#修改 ./nginx 的所屬為rootchown root nginx#讓普通用戶可以使用80端口,可以使用root權(quán)限啟用nginxchmod u+s nginx#修改配置文件 在修改配置文件之前 ,要備份該文件cd conf/# 要注意nginx 的工作進(jìn)程,一般根據(jù)cpu的核數(shù)去修改vim nginx.conf#關(guān)閉防火墻,打開(kāi)80端口service iptables stop#啟動(dòng)nginx./nginx#重啟nginx./nginx -s reload#關(guān)閉nginx./nginx -s stop

準(zhǔn)備一臺(tái)tomcat服務(wù)器,先準(zhǔn)備java環(huán)境,安裝jdk步驟省略

然后分別安裝3個(gè)tomcat 服務(wù)器ip地址:192.168.1.143,tomcat1 8080端口,tomcat2 8081端口,tomcat3 8082端口。

apache-tomcat-7.0.64/conf/server.xml配置文件修改這三個(gè)地方,這樣端口就不會(huì)沖突

<Server port="8005" shutdown="SHUTDOWN"><Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" /><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

修改tomcat ROOT目錄下index.jsp,分別增加每個(gè)tomcat的標(biāo)識(shí),以及在頁(yè)面上顯示session ID

<%--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.--%><!DOCTYPE html><%@ page session="true" %><%java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy");request.setAttribute("year", sdf.format(new java.util.Date()));request.setAttribute("tomcatUrl", "http://tomcat.apache.org/");request.setAttribute("tomcatDocUrl", "/docs/");request.setAttribute("tomcatExamplesUrl", "/examples/");%><html lang="en"> <head>  <title><%=request.getServletContext().getServerInfo() %></title>  <link href="favicon.ico" rel="icon" type="image/x-icon" />  <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />  <link href="tomcat.css" rel="stylesheet" type="text/css" /> </head> <body>  <div id="wrapper">   <div id="navigation" class="curved container">    <span id="nav-home"><a href="${tomcatUrl}">Home--<%=request.getSession().getId() %></a></span>    <span id="nav-hosts"><a href="${tomcatDocUrl}">Documentation</a></span>    <span id="nav-config"><a href="${tomcatDocUrl}config/">Configuration</a></span>    <span id="nav-examples"><a href="${tomcatExamplesUrl}">Examples</a></span>    <span id="nav-wiki"><a >Wiki</a></span>    <span id="nav-lists"><a href="${tomcatUrl}lists.html">Mailing Lists</a></span>    <span id="nav-help"><a href="${tomcatUrl}findhelp.html">Find Help</a></span>    <br class="separator" />   </div>   <div id="asf-box">    <h1>${pageContext.servletContext.serverInfo}--8080</h1>   </div>   <div id="upper" class="curved container">    <div id="congrats" class="curved container">     <h2>If you're seeing this, you've successfully installed Tomcat. Congratulations!</h2>    </div>    <div id="notice">     <img src="tomcat.png" alt="[tomcat logo]" />     <div id="tasks">      <h3>Recommended Reading:</h3>      <h4><a href="${tomcatDocUrl}security-howto.html">Security Considerations HOW-TO</a></h4>      <h4><a href="${tomcatDocUrl}manager-howto.html">Manager Application HOW-TO</a></h4>      <h4><a href="${tomcatDocUrl}cluster-howto.html">Clustering/Session Replication HOW-TO</a></h4>     </div>    </div>    <div id="actions">     <div class="button">      <a class="container shadow" href="/manager/status"><span>Server Status</span></a>     </div>     <div class="button">      <a class="container shadow" href="/manager/html"><span>Manager App</span></a>     </div>     <div class="button">      <a class="container shadow" href="/host-manager/html"><span>Host Manager</span></a>     </div>    </div>    <!--    <br class="separator" />    -->    <br class="separator" />   </div>   <div id="middle" class="curved container">    <h3>Developer Quick Start</h3>    <div class="col25">     <div class="container">      <p><a href="${tomcatDocUrl}setup.html">Tomcat Setup</a></p>      <p><a href="${tomcatDocUrl}appdev/">First Web Application</a></p>     </div>    </div>    <div class="col25">     <div class="container">      <p><a href="${tomcatDocUrl}realm-howto.html">Realms & AAA</a></p>      <p><a href="${tomcatDocUrl}jndi-datasource-examples-howto.html">JDBC DataSources</a></p>     </div>    </div>    <div class="col25">     <div class="container">      <p><a href="${tomcatExamplesUrl}">Examples</a></p>     </div>    </div>    <div class="col25">     <div class="container">      <p><a >Servlet Specifications</a></p>      <p><a >Tomcat Versions</a></p>     </div>    </div>    <br class="separator" />   </div>   <div id="lower">    <div id="low-manage" class="">     <div class="curved container">      <h3>Managing Tomcat</h3>      <p>For security, access to the <a href="/manager/html">manager webapp</a> is restricted.      Users are defined in:</p>      <pre>$CATALINA_HOME/conf/tomcat-users.xml</pre>      <p>In Tomcat 7.0 access to the manager application is split between       different users.   <a href="${tomcatDocUrl}manager-howto.html">Read more...</a></p>      <br />      <h4><a href="${tomcatDocUrl}RELEASE-NOTES.txt">Release Notes</a></h4>      <h4><a href="${tomcatDocUrl}changelog.html">Changelog</a></h4>      <h4><a href="${tomcatUrl}migration.html">Migration Guide</a></h4>      <h4><a href="${tomcatUrl}security.html">Security Notices</a></h4>     </div>    </div>    <div id="low-docs" class="">     <div class="curved container">      <h3>Documentation</h3>      <h4><a href="${tomcatDocUrl}">Tomcat 7.0 Documentation</a></h4>      <h4><a href="${tomcatDocUrl}config/">Tomcat 7.0 Configuration</a></h4>      <h4><a >Tomcat Wiki</a></h4>      <p>Find additional important configuration information in:</p>      <pre>$CATALINA_HOME/RUNNING.txt</pre>      <p>Developers may be interested in:</p>      <ul>       <li><a >Tomcat 7.0 Bug Database</a></li>       <li><a href="${tomcatDocUrl}api/index.html">Tomcat 7.0 JavaDocs</a></li>       <li><a >Tomcat 7.0 SVN Repository</a></li>      </ul>     </div>    </div>    <div id="low-help" class="">     <div class="curved container">      <h3>Getting Help</h3>      <h4><a href="${tomcatUrl}faq/">FAQ</a> and <a href="${tomcatUrl}lists.html">Mailing Lists</a></h4>      <p>The following mailing lists are available:</p>      <ul>       <li id="list-announce"><strong><a href="${tomcatUrl}lists.html#tomcat-announce">tomcat-announce</a><br />        Important announcements, releases, security vulnerability notifications. (Low volume).</strong>       </li>       <li><a href="${tomcatUrl}lists.html#tomcat-users">tomcat-users</a><br />        User support and discussion       </li>       <li><a href="${tomcatUrl}lists.html#taglibs-user">taglibs-user</a><br />        User support and discussion for <a href="${tomcatUrl}taglibs/">Apache Taglibs</a>       </li>       <li><a href="${tomcatUrl}lists.html#tomcat-dev">tomcat-dev</a><br />        Development mailing list, including commit messages       </li>      </ul>     </div>    </div>    <br class="separator" />   </div>   <div id="footer" class="curved container">    <div class="col20">     <div class="container">      <h4>Other Downloads</h4>      <ul>       <li><a href="${tomcatUrl}download-connectors.cgi">Tomcat Connectors</a></li>       <li><a href="${tomcatUrl}download-native.cgi">Tomcat Native</a></li>       <li><a href="${tomcatUrl}taglibs/">Taglibs</a></li>       <li><a href="${tomcatDocUrl}deployer-howto.html">Deployer</a></li>      </ul>     </div>    </div>    <div class="col20">     <div class="container">      <h4>Other Documentation</h4>      <ul>       <li><a href="${tomcatUrl}connectors-doc/">Tomcat Connectors</a></li>       <li><a href="${tomcatUrl}connectors-doc/">mod_jk Documentation</a></li>       <li><a href="${tomcatUrl}native-doc/">Tomcat Native</a></li>       <li><a href="${tomcatDocUrl}deployer-howto.html">Deployer</a></li>      </ul>     </div>    </div>    <div class="col20">     <div class="container">      <h4>Get Involved</h4>      <ul>       <li><a href="${tomcatUrl}getinvolved.html">Overview</a></li>       <li><a href="${tomcatUrl}svn.html">SVN Repositories</a></li>       <li><a href="${tomcatUrl}lists.html">Mailing Lists</a></li>       <li><a >Wiki</a></li>      </ul>     </div>    </div>    <div class="col20">     <div class="container">      <h4>Miscellaneous</h4>      <ul>       <li><a href="${tomcatUrl}contact.html">Contact</a></li>       <li><a href="${tomcatUrl}legal.html">Legal</a></li>       <li><a >Sponsorship</a></li>       <li><a >Thanks</a></li>      </ul>     </div>    </div>    <div class="col20">     <div class="container">      <h4>Apache Software Foundation</h4>      <ul>       <li><a href="${tomcatUrl}whoweare.html">Who We Are</a></li>       <li><a href="${tomcatUrl}heritage.html">Heritage</a></li>       <li><a >Apache Home</a></li>       <li><a href="${tomcatUrl}resources.html">Resources</a></li>      </ul>     </div>    </div>    <br class="separator" />   </div>   <p class="copyright">Copyright ©1999-${year} Apache Software Foundation. All Rights Reserved</p>  </div> </body></html>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 双牌县| 平塘县| 宁武县| 拜泉县| 赣榆县| 三门县| 芜湖市| 武安市| 大余县| 宁南县| 广元市| 建水县| 仁布县| 都匀市| 修水县| 汉沽区| 德清县| 大名县| 浦江县| 景德镇市| 吉木萨尔县| 齐河县| 延川县| 江陵县| 西和县| 绥滨县| 揭阳市| 库车县| 水富县| 古浪县| 邻水| 博兴县| 出国| 武山县| 八宿县| 长子县| 嘉兴市| 星子县| 台东市| 八宿县| 商水县|