亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

redis緩存服務器的安裝和部署

發布時間:2020-05-22 14:10:41 來源:億速云 閱讀:334 作者:鴿子 欄目:系統運維

redis緩存服務器

redis是一個key-value存儲系統。和Memcached類似,它支持存儲的value類型相對更多,包括
string(字符串)、list(鏈表)、set(集合)、zset(sorted set --有序集合)和hash(哈希類型)。

1、Redis不僅僅支持簡單的k/v類型的數據,同時還提供list,set,zset,hash等數據結構的存儲。
2、Redis支持數據的備份,即master-slave模式的數據備份。
3、Redis支持數據的持久化,可以將內存中的數據保持在磁盤中,重啟的時候可以再次加載進行使用。
redis緩存服務器的安裝和部署
redis緩存服務器的安裝和部署
nginx+tomcat+redis實現負載均衡、session共享
1,安裝部署nginx負載均衡服務器
安裝zlib-devel、pcre-devel等依賴包
[root@www ~]# yum -y install gcc gcc-c++ make libtool zlib zlib-devel pcre pcre-devel openssl openssl-devel
注:
結合proxy和upstream模塊實現后端web負載均衡
結合nginx默認自帶的ngx_http_proxy_module模塊 和ngx_http_upstream_module模塊實現后
端服務器的健康檢查
創建nginx程序用戶
[root@www ~]# useradd -s /sbin/nologin www
編譯安裝nginx
[root@www ~]# tar zxf nginx-1.10.2.tar.gz
[root@www ~]# cd nginx-1.10.2/
[root@www nginx-1.10.2]# ./configure --prefix=/usr/local/nginx1.10 --user=www --group=www  --with-http_stub_status_module --with-http_realip_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_flv_module
[root@www nginx-1.10.2]# make && make install
優化nginx程序的執行路徑
[root@www nginx-1.10.2]# ln -s /usr/local/nginx1.10/sbin/nginx /usr/local/sbin/
[root@www nginx-1.10.2]# nginx -t
nginx: the configuration file /usr/local/nginx1.10/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx1.10/conf/nginx.conf test is successful
編寫nginx服務腳本:腳本內容如下:
復制進去即可
[root@www ~]# cat /etc/init.d/nginx

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# chkconfig: - 85 15
# pidfile: /usr/local/nginx1.10/logs/nginx.pid
# config: /usr/local/nginx1.10/conf/nginx.conf
nginxd=/usr/local/nginx1.10/sbin/nginx
nginx_config=/usr/local/nginx1.10/conf/nginx.conf
nginx_pid=/usr/local/nginx1.10/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Start nginx daemons functions.
start() {
if [ -f $nginx_pid ] ; then
echo "nginx already running...."
exit 1
fi
echo -n "Starting $prog: "
 $nginxd -c ${nginx_config}
 RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
}
# Stop nginx daemons functions.
stop() {
echo -n "Stopping $prog: "
 $nginxd -s stop
 RETVAL=$?
[ $RETVAL = 0 ] &&rm -f /var/lock/subsys/nginx
}
# reloadnginx service functions.
reload() {
echo -n "Reloading $prog: "
 $nginxd -s reload
}
# statusngnx service functions
status() {
if [ -f $nginx_pid ] ; then
echo "$prog is running"
else
echo "$prog is stop"
fi
}
case "$1" in
start)
start
 ;;
stop)
stop
 ;;
reload)
reload
 ;;
restart)
stop
start
 ;;
status)
status
 ;;
*)
echo "Usage: $prog {start|stop|restart|reload|status}"
exit 1
 ;;
esac

[root@www ~]# chmod +x /etc/init.d/nginx
[root@www ~]# chkconfig --add nginx
[root@www ~]# chk config nginx on
[root@www ~]# systemctl daemon-reload
配置nginx反向代理:反向代理+負載均衡+健康探測,nginx.conf文件內容:
[root@www ~]# cat /usr/local/nginx1.10/conf/nginx.conf

user www www;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
worker_rlimit_nofile 10240;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 4096;
}
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;
server_tokens off;
sendfile on;
tcp_nopush on;
 #keepalive_timeout 0;
keepalive_timeout 65;
 #Compression Settings
gzip on;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_proxied any;
gzip_min_length 1k;
gzip_buffers 16 8k;
gzip_types text/plain text/css text/javascript application/json application/javascript
application/x-javascript application/xml;
gzip_vary on;
 #end gzip
 # http_proxy Settings
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 75;
proxy_send_timeout 75;
proxy_read_timeout 75;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
 #load balance Settings
upstream backend_tomcat {
server 192.168.31.83:8080 weight=1 max_fails=2 fail_timeout=10s;     #要改
server 192.168.31.250:8080 weight=1 max_fails=2 fail_timeout=10s;   #要改
 }
 #virtual host Settings
server {
listen 80;
server_name www.benet.com;
charset utf-8;
location / {
root html;
index index.jsp index.html index.htm;
 }
location ~ \.(jsp|do)$ {
          proxy_pass http://backend_tomcat;
          proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           }
           location /nginxstatus {
           stub_status on;
           access_log off;
           allow 192.168.1.0/24;     #要改
           deny all;
            }
             }
             }

重啟nginx服務,使修改生效
[root@www ~]# service nginx restart
配置防火墻規測   容許 tcp/80端口出去
[root@www ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@www ~]# firewall-cmd --reload
success


2,安裝部署tomcat應用程序服務器
在tomcat-1和tomcat-2節點上安裝JDK
在安裝tomcat之前必須先安裝JDK,JDK的全稱是java development kit,是sun公司免費提
供的java語言的軟件開發工具包,其中包含java虛擬機(JVM),編寫好的java源程序經過
編譯可形成java字節碼,只要安裝了JDK,就可以利用JVM解釋這些字節碼文件,從而保證了
java的跨平臺性。
安裝JDK,配置java環境:
將jdk-7u65-linux-x64.gz解壓
[root@tomcat-1 ~]# tar zxf jdk-7u65-linux-x64.gz
將解壓的jdk1.7.065目錄移致動到/usr/local/下并重命名為java
[root@tomcat-1 ~]# mv jdk1.7.065/ /usr/local/java
在/etc/profile文件中添加內容如下:
export JAVAHOME=/usr/local/java
export PATH=$JAVAHOME/bin:$PATH

通過source命令執行profile文件,使其生效。
[root@tomcat-1 ~]# source /etc/profile
[root@tomcat-1 ~]# echo $PATH
/usr/local/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
按照相同方法在tomcat-2也安裝JDK
分別在在tomcat-1和tomcat-2節點運行java -version命令查看java版本是否和之前安裝的
一致。
[root@tomcat-1 ~]# java -version
java version "1.7.065"
Java(TM) SE Runtime Environment (build 1.7.065-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
至此java環境已經配置完成
在tomcat-1和tomcat-2節點安裝配置tomcat
解壓apache-tomcat-7.0.54.tar.gz包
[root@tomcat-1 ~]# tar zxf apache-tomcat-7.0.54.tar.gz
將解壓生成的文件夾移動到/usr/local/下,并改名為tomcat7
[root@tomcat-1 ~]# mv apache-tomcat-7.0.54 /usr/local/tomcat7
配置tomcat環境變量
/etc/profile文件內容如下:
export JAVAHOME=/usr/local/java
export CATALINAHOME=/usr/local/tomcat7
export PATH=$JAVAHOME/bin:$CATALINAHOME/bin:$PATH

通過source命令執行profile文件,使其生效。
[root@tomcat-1 ~]# source /etc/profile
[root@tomcat-1 ~]# echo $PATH
/usr/local/java/bin:/usr/local/tomcat7/bin:/usr/local/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/
bin:/root/bin
查看tomcat的版本信息
[root@tomcat-1 ~]# catalina.sh version
Using CATALINABASE: /usr/local/tomcat7
Using CATALINAHOME: /usr/local/tomcat7
Using CATALINATMPDIR: /usr/local/tomcat7/temp
Using JREHOME: /usr/local/java
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.54
Server built: May 19 2014 10:26:15
Server number: 7.0.54.0
OS Name: Linux
OS Version: 3.10.0-327.el7.x8664
Architecture: amd64
JVM Version: 1.7.065-b17
JVM Vendor: Oracle Corporation
啟動tomcat
[root@tomcat-1 ~]# /usr/local/tomcat7/bin/startup.sh
Using CATALINABASE: /usr/local/tomcat7
Using CATALINAHOME: /usr/local/tomcat7
Using CATALINATMPDIR: /usr/local/tomcat7/temp
Using JREHOME: /usr/local/java
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
Tomcat默認運行在8080端口,運行netstat命令查看8080端口監聽的信息
[root@tomcat-1 ~]# netstat -anpt | grep java
tcp6 0 0 :::8009 ::: LISTEN 42330/java
tcp6 0 0 :::8080 ::: LISTEN 42330/java
防火墻規則配置:
[root@tomcat-1 ~]# firewall-cmd --permanent --add-port=8080/tcp
success
[root@tomcat-1 ~]# firewall-cmd --reload
success
按照相同方法在tomcat-2也安裝
打開瀏覽器分別對tomcat-1和tomcat-2訪問測試
如果想關閉tomcat則運行/usr/local/tomcat7/bin/shutdown.sh命令
好了,大家可以看到訪成功。說明我們的tomcat安裝完成,下面我們來修改配置文件
[root@tomcat-1 ~]# vim /usr/local/tomcat7/conf/server.xml
設置默認虛擬主機,并增加jvmRoute*
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat-1">
修改默認虛擬主機,并將網站文件路徑指向/web/webapp1,在host段增加context段
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context docBase="/web/webapp1" path="" reloadable="true"/>
</Host>
redis緩存服務器的安裝和部署
增加文檔目錄與測試文件
[root@tomcat-1 ~]# mkdir -p /web/webapp1
[root@tomcat-1 ~]# cd /web/webapp1/
[root@ tomcat-1 webapp1]# vi index.jsp
index.jsp內容如下:

<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>tomcat-1</title>
</head>
<body>
<h2><font color="red">Session serviced by tomcat</font></h2>
<table aligh="center" border="1">
<tr>
<td>Session ID</td>
<td><%=session.getId() %></td>
<% session.setAttribute("abc","abc");%>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
<html>

停止tomcat運行,檢查配置文件并啟動tomcat
[root@tomcat-1 ~]# shutdown.sh
[root@tomcat-1 ~]# netstat -anpt | grep java
[root@tomcat-1 ~]# catalina.sh configtest
Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /usr/local/java
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Nov 16, 2016 1:04:05 AM org.apache.catalina.core.AprLifecycleListenerinit
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production
environments was not found on the java.library.path:
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Nov 16, 2016 1:04:05 AM org.apache.coyote.AbstractProtocolinit
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 16, 2016 1:04:05 AM org.apache.coyote.AbstractProtocolinit
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 16, 2016 1:04:05 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 534 ms
[root@tomcat-1 ~]# startup.sh
Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /usr/local/java
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
[root@tomcat-1 ~]# netstat -anpt | grep java
tcp6 0 0 :::8009 ::: LISTEN 8180/java
tcp6 0 0 :::8080 :::
LISTEN 8180/java
Tomcat-2節點與tomcat-1節點配置基本類似,只是jvmRoute不同,另外為了區分由哪個節點
提供訪問,測試頁標題也不同(生產環境兩個tomcat服務器提供的網頁內容是相同的)。其
他的配置都相同。
用瀏覽器訪問nginx主機,驗證負載均衡
redis緩存服務器的安裝和部署

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

中江县| 石嘴山市| 齐齐哈尔市| 克什克腾旗| 万安县| 南乐县| 宜都市| 通辽市| 伊通| 龙南县| 临汾市| 英德市| 海盐县| 芷江| 辉南县| 常宁市| 白银市| 博湖县| 嘉祥县| 祥云县| 深水埗区| 亳州市| 建阳市| 乐陵市| 蓬莱市| 合肥市| 山西省| 怀柔区| 安龙县| 竹溪县| 临汾市| 比如县| 廉江市| 海安县| 尼木县| 讷河市| 车致| 乐陵市| 方山县| 天门市| 廊坊市|