In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Apache+tomcat
Http version 2.4
1.http+tomcat Communications learn:
Http and tomcat communicate through ajp,http,https protocol
Http and tomcat implement load balancing based on mod_jd and mod_proxy
1. Install http
a. Download: apache http: http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.gzarp:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gzarp-util:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gzb. Compile and install 1. Install pcre-devel yum install pcre-devel2. First install arp > tar-xzf apr-1.5.2.tar.gz > cd apr-1.5.2 >. / configure-- prefix=/usr/local/apr > make & & make install3. Install arp-util > tar-xzf apr-util-1.5.4.tar.gz > cd apr-util-1.5.4 >. / configure-- prefix=/usr/local/apt-util-- with-apr=/usr/local/apr > make & & make insatll4. Install httpd > tar-xzf httpd-2.4.25.tar.gz > cd httpd-2.4. > / configure-- prefix=/usr/local/apache-- sysconfdir=/etc/httpd24-- enable-so-- enable--ssl-- enable-cgi-- enable-rewrite-- with-zlib-- with-pcre-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-util-- enable-modeles=most-- enable-mpms-shared=all-- with-mpm=event-- enable-proxy--enable-proxy-http-- enable-proxy-ajp-- enable-balencer > make & & make install5. Configure the environment for httpd (a). Configure the httpd service startup file vim / etc/init.d/http. / etc/rc.d/init.d/functions if [- f / etc/sysconfig/httpd]; then. / etc/sysconfig/httpd fi HTTPD_LANG=$ {HTTPD_LANG- "C"} INITLOG_ARGS= "" apachectl=/usr/sbin/httpd/bin/apachectl httpd=/usr/local/httpd/bin/httpd} prog=httpd pidfile=$ {PIDFILE-/var/run/httpd/httpd.pid} lockfile=$ {LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=$ {STOP_TIMEOUT-10} start () {echo-n $"Starting $prog: "LANG=$HTTPD_LANG daemon-- pidfile=$ {pidfile} $httpd $OPTIONS RETVAL=$? Echo [$RETVAL = 0] & & touch ${lockfile} return $RETVAL} stop () {status-p ${pidfile} $httpd > / dev/null if [[$? = 0]] Then echo-n $"Stopping $prog:" killproc-p ${pidfile}-d ${STOP_TIMEOUT} $httpd else echo-n $"Stopping $prog:" success fi RETVAL=$? Echo [$RETVAL = 0] & & rm-f ${lockfile} ${pidfile}} reload () {echo-n $"Reloading $prog:" if! LANG=$HTTPD_LANG $httpd $OPTIONS-t > & / dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc-p ${pidfile} $httpd-HUP RETVAL=$? If [$RETVAL-eq 7]; then failure $"httpd shutdown" fi fi echo} case "$1" in start) start;; stop) stop;; status) status-p ${pidfile} $httpd RETVAL=$?;; restart) stop start;; condrestart | try-restart) if status-p ${pidfile} $httpd > & / dev/null Then stop start fi;; force-reload | reload) reload;; graceful | help | configtest | fullstatus) $apachectl $@ RETVAL=$?;; *) echo $"Usage: $prog {start | stop | restart | condrestart | try-restart | force-reload | reload | status | fullstatus | help | configtest}" RETVAL=2 esac exit $RETVAL (b). Export the header file ln-sv / usr/local/httpd/include / usr/include/httpd (c). Export the help file vim / etc/man.config MANPATH / usr/local/htppd/man (d). Modify the environment variable vim / etc/profile.d/httpd export PATH=/usr/local/httpd/bin:$PATH 1234567891011121314151617181920212223242626283031333435363739404142445464748495051535456575859606162636667686970717374757677787828384878889909293949798991001102102232426272929298910101213151617192022325262829303233343535363839404144545454545454545454545454545454545445454545454546464848154545454545454545454545457577676788283848688899097979797948102106999910293910101039101010391010109999910103910109910109910991099103910991029292932424242629293232424244543646484815354565454545454545454545454646464666667686970717277990929294969999999991010110210106123456789101112131516171819202232425262728293032333435353638394041445454545454545454545454545454545454545454545454545454545454646474851535456545454545444646464646566676869707172737707173790929397979998991001011021010610123456789101012131415161718192022324252627282930323334353536383940414454545454545454545454545454545474748481535454545454545454545
two。 Implementation of httd+tomcat based on mod_proxy
a. Based on ajp protocol
ProxyVia off ProxyRequests offProxyPreserveHost off Require all grantedProxyPass / ajp://192.168.100.34:8009/ProxyPa***everse / ajp://192.168.100.34:8009/ Require all granted12345678910111234567891011
b. Based on http protocol
ProxyVia OffProxyRequests OffProxyPass / http://192.168.100.34 ProxyVia OffProxyRequests OffProxyPass / http://192.168.100.34 8080 / Require all grantedRequire all granted1234567891012345678910
c. Detailed explanation of parameters
ProxyVia {On | Off | Full | Block}: it is used to control whether you Via the header of http. It is mainly used to control the flow of proxy requests in multi-level agents. Full means that the version number of the apache server will be added to each request message, and Block means that the Via in each proxy message will be cleared. ProxyPreserveHost {On | Off}: enable this feature. The agent sends the Host line in the user's request message to the backend server instead of using the server address specified by Proxy_pass. This is required if virtual hosts are supported in the reverse proxy. ProxyRequests {On | Off}: whether to enable forward proxy. If you set proxy_pass, you must set this to OffProxyPass path url [key=value key=value..]; associate the backend server url with a local virtual path to provide services; path, where path is a virtual path on the current server, and if path ends with /, the url must also end with /. The commonly used key is as follows: min: the minimum capacity of the connection pool and the capacity at initialization. Max: maximum capacity of connection pool. Loadfactor: used in load balancer cluster configuration to define the weight of the corresponding backend server. When the backend server gets an error response, how long will it take to retry (in seconds). If there is no response, it will be removed, and ProxyPa***everse will be added after re-launch: used to allow apache to adjust the Location in the HTTP redirect response message. The URL corresponding to the Context-Location and URL tags must use this instruction in the reverse proxy to prevent redirected messages from bypassing the proxy server 1234567891012345678910
d. test
3. Implementation of http+tomcat based on mod_jk
a. Compile and install mod_jk
1. Download: http://mirror.bit.edu.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.42-src.tar.gz2. Installation: > tar-xzf tomcat-connectors-1.2.42-src.tar.gz > cd tomcat-connectors-/native/ >. / configure-- with-apxs=/usr/local/http/bin/apxs (if http is a yum installation, install httpd-devel,rpm-ql httpd-devel to find the apxs path) > make & & make install12345671234567
b. Configuration / etc/httpd.d/httpd.conf
1.vim / etc/httpd.d/httpd.confLoadModule jk_module modules/mod_jk.so / / load module JkWorkersFile / etc/httpd/extra/workers.properties / / set workers file JkLogFile logs/mod_jk.log / / define log file JkLogLevel debug / / log level JkMount / * TomcatA / / all paths under the root are forwarded to tomcatAJkMount / status/ stat1 / / View status page 2.vim / etc/httpd/extra/workers.propertiesworker.list=TomcatA Stat1worker.TomcatA.port=8009worker.TomcatA.host=192.168.100.34worker.TomcatA.type=ajp13worker.TomcatA.lbfactor=1worker.stat1.type=status / / status page 12345678910111213141234567891011121314
C.workers.properties details:
Format worker.list = worker.name worker.nameworker.worer_name.property = valueproperty: host port of the host:tomcat instance: Port connection_pool_minsize: minimum number of links in the connection pool connection_pool_timeout: link timeout in the connection pool retries: number of retries when errors occur socket_timeout:mod_jk wait for worker response length, default pseudo 0, infinite wait socket_keepalive: whether to start a long link 1 indicates the weight type with lbfactor:worker enabled: specify type, value pseudo-status indicates status information, ajp13 represents an instance of current worker pseudo-operation, and lb indicates using load balancing 1234567891011121312345678910111213
d. Test result
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.