国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
分享一例測(cè)試環(huán)境下nginx+tomcat的視頻業(yè)務(wù)部署記錄

 

需求說明:
在測(cè)試環(huán)境下(192.168.1.28)部署一套公司某業(yè)務(wù)環(huán)境,其中:
該業(yè)務(wù)前臺(tái)訪問地址: http://testhehe.wangshibo.com
該業(yè)務(wù)后臺(tái)訪問地址: http://testhehe.wangshibo.com/admin/

涉及到視頻讀寫需求,要求視頻在測(cè)試機(jī)上寫入,然后在另一臺(tái)圖片服務(wù)器(192.168.1.6)上讀,這就需要做nfs共享。需要給開發(fā)同事提供視頻寫入和讀取的url地址:
視頻寫地址:http://testhehe.wangshibo/static/video
視頻讀地址:http://static.wangshibo.com/video

部署記錄:
一、測(cè)試機(jī)上的操作

(1)nginx的配置
[root@dev-test ~]# cat testhehe.wangshibo.com.conf
server {
          listen 80;

         server_name testhehe.wangshibo.com;

         access_log /var/log/testhehe.log main;

         location / {
             proxy_pass http://127.0.0.1:8383;                            #前臺(tái)訪問
             proxy_connect_timeout 30;
             proxy_send_timeout 60;
             proxy_read_timeout 60;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header REMOTE-HOST $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         }

         location /admin {
             proxy_pass http://127.0.0.1:8484/;   #后臺(tái)訪問跳轉(zhuǎn)(注意這里8484后面的斜杠/要加上,不然訪問跳轉(zhuǎn)會(huì)有問題,8484端口的tomcat目錄下不需要有admin實(shí)際目錄存在)
             proxy_connect_timeout 30;
             proxy_send_timeout 60;
             proxy_read_timeout 60;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header REMOTE-HOST $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         }

         location /static/video {                     #視頻寫地址,這里不需要另啟tomcat進(jìn)程進(jìn)行nginx跳轉(zhuǎn)設(shè)置(沒有war包數(shù)據(jù)),直接nginx設(shè)置訪問地址即可
             root /Data/app/tomcat-7-hehe/static/video;
         }

         } ##end server

 

啟動(dòng)nginx
[root@dev-test ~]# /Data/app/nginx/sbin/nginx -t
[root@dev-test ~]# /Data/app/nginx/sbin/nginx -s reload

以上nginx的配置說明:
1)該業(yè)務(wù)前臺(tái)http://testhehe.wangshibo.com訪問轉(zhuǎn)向8383端口的tomcat,代碼放到/Data/app/tomcat-7-hehe/webapp目錄下
2) 該業(yè)務(wù)后臺(tái)http://testhehe.wangshibo.com/admin/訪問轉(zhuǎn)向8484端口的tomcat,代碼放到/Data/app/tomcat-7-admin-hehe/webapp目錄下
3)視頻寫入的地址是:http://testhehe.wangshibo.com/static/video,根目錄為/Data/app/tomcat-7-hehe/static/video,由于tomcat和nginx進(jìn)程權(quán)限不一樣,最好將此目錄設(shè)置成777權(quán)限。

[root@dev-test ~]# chmod -R 777 /Data/app/tomcat-7-hehe/static/video

(2)tomcat設(shè)置

1)前臺(tái)訪問跳轉(zhuǎn)的tomcat設(shè)置(8383端口)
[root@dev-test ~]# cd /Data/app/tomcat-7-hehe/conf/
[root@dev-test conf]# cat server.xml
.......
<Server port="8785" shutdown="SHUTDOWN">
......
<Connector port="8383" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
.....
<Connector port="8789" protocol="AJP/1.3" redirectPort="8443" />
.....
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
</Host>
.....
</Server>

注意:tomcat默認(rèn)的根目錄是webapps/ROOT,所以現(xiàn)將webapps目錄下默認(rèn)的文件都刪除
[root@dev-test webapps]# pwd
/Data/app/tomcat-7-hehe/webapps
[root@dev-test webapps]# rm -rf ./*

將前臺(tái)代碼的war包拷貝到webapps下,war包名稱最好是ROOT.war,如果不是這個(gè)名稱,可以手動(dòng)將war包改成這個(gè)ROOT.war名稱.這樣訪問的時(shí)候就直接使用tomcat的默認(rèn)目錄了,比如 http://127.0.0.1:8383;(當(dāng)然如果不改成ROOT.war也無妨,比如war包名叫hehe.war,需要提前將webapps目錄清空,那么tomcat啟動(dòng)后,訪問就是http://127.0.0.1:8383/hehe,這樣在nginx反向代理里的proxy_pass配置也要改成proxy_pass http://127.0.0.1:8383/hehe; )
例如開發(fā)提供的業(yè)務(wù)代碼war包名稱是hehe.war,將其上傳到webapp下,并更名為ROOT.war
[root@dev-test webapp]# ll hehe.war
-rw-r--r-- 1 root root 52673678 11月 21 17:40 hehe.war
[root@dev-test webapp]# mv hehe.war ROOT.war                                     
[root@dev-test webapp]# ll
-rw-r--r-- 1 root root 124491469 11月 22 17:59 ROOT.war      

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
這里注意一下:
tomcat默認(rèn)的根目錄是webapp/ROOT,為了方便tomcat訪問時(shí)采用默認(rèn)目錄(并且前端nginx反向代理里直接是轉(zhuǎn)到tomcat默認(rèn)的端口訪問上),所以需要將業(yè)務(wù)代碼war包改成ROOT.war放到webapp下,如果war包名不是ROOT.war,那么重啟tomcat后,訪問會(huì)失?。?04頁面)。
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

接著啟動(dòng)8383端口的tomcat進(jìn)程,這個(gè)ROOT.war包就會(huì)自動(dòng)解壓
[root@dev-test webapps]# ../bin/startup.sh
Using CATALINA_BASE: /Data/app/tomcat-7-hehe
Using CATALINA_HOME: /Data/app/tomcat-7-hehe
Using CATALINA_TMPDIR: /Data/app/tomcat-7-hehe
Using JRE_HOME: /usr/java/jdk1.7.0_79
Using CLASSPATH: /Data/app/tomcat-7-hehe/bin/bootstrap.jar:/Data/app/tomcat-7-hehe/bin/tomcat-juli.jar
Tomcat started.

[root@dev-test webapps]# ll
總用量 121580
drwxr-xr-x 10 root root 4096 11月 22 17:57 ROOT
-rw-r--r-- 1 root root 124491469 11月 22 17:59 ROOT.war

[root@dev-test webapps]# lsof -i:8383
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 26155 root 43u IPv6 214715915 0t0 TCP *:m2mservices (LISTEN)

由于業(yè)務(wù)代碼每次發(fā)版都需要重啟tomcat,而tomcat沒有自帶的重啟腳本,重啟需要先kill,然后start啟動(dòng),這樣很不方面。
這里分享一個(gè)簡(jiǎn)單的發(fā)版后的tomcat重啟腳本:
[root@dev-test tomcat-7-hehe]# pwd
/Data/app/tomcat-7-hehe
[root@dev-test tomcat-7-hehe]# cat start.sh
#!/bin/bash

cd /Data/app/tomcat-7-hehe/
#pkill -9 java
kill -9 `ps -ef|grep java|grep -v grep|grep tomcat-7-hehe |awk -F" " '{print $2}'`
rm -rf temp/*
rm -rf work/*
rm -rf webapps/ROOT

sh bin/startup.sh

2)同理,設(shè)置后臺(tái)訪問跳轉(zhuǎn)的tomcat設(shè)置(8484端口)
[root@dev-test ~]# cd /Data/app/tomcat-7-admin-hehe/conf
[root@dev-test conf]# cat server.xml
.......
<Server port="8886" shutdown="SHUTDOWN">
......
<Connector port="8484" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
.....
<Connector port="8889" protocol="AJP/1.3" redirectPort="8443" />
.....
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
</Host>
.....
</Server>

注意:tomcat默認(rèn)的根目錄是webapps/ROOT,所以現(xiàn)將webapps目錄下默認(rèn)的文件都刪除
[root@dev-test webapps]# pwd
/Data/app/tomcat-7-admin-hehe/webapps
[root@dev-test webapps]# rm -rf ./*

然后將前臺(tái)代碼的war包拷貝到webapps下,war包名稱最好是ROOT.war,如果不是這個(gè)名稱,就手動(dòng)改成這個(gè)ROOT.war名稱.
[root@dev-test webapps]# ll
總用量 121580
-rw-r--r-- 1 root root 124491469 11月 22 17:59 ROOT.war

接著啟動(dòng)8383端口的tomcat進(jìn)程,這個(gè)ROOT.war包就會(huì)自動(dòng)解壓
[root@dev-test webapps]# ../bin/startup.sh
Using CATALINA_BASE: /Data/app/tomcat-7-admin-hehe
Using CATALINA_HOME: /Data/app/tomcat-7-admin-hehe
Using CATALINA_TMPDIR: /Data/app/tomcat-7-admin-hehe
Using JRE_HOME: /usr/java/jdk1.7.0_79
Using CLASSPATH: /Data/app/tomcat-7-admin-hehe/bin/bootstrap.jar:/Data/app/tomcat-7-admin-hehe/bin/tomcat-juli.jar
Tomcat started.

[root@dev-test webapps]# ll
總用量 121580
drwxr-xr-x 10 root root 4096 11月 22 17:57 ROOT
-rw-r--r-- 1 root root 124491469 11月 22 17:59 ROOT.war

[root@dev-test webapps]# lsof -i:8383
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 26155 root 43u IPv6 214715915 0t0 TCP *:m2mservices (LISTEN)

由于業(yè)務(wù)代碼每次發(fā)版都需要重啟tomcat,而tomcat沒有自帶的重啟腳本,重啟需要先kill,然后start啟動(dòng),這樣很不方面。
這里分享一個(gè)簡(jiǎn)單的發(fā)版后的tomcat重啟腳本:
[root@dev-test tomcat-7-admin-hehe]# pwd
/Data/app/tomcat-7-admin-hehe
[root@dev-test tomcat-7-admin-hehe]# cat start.sh
#!/bin/bash

cd /Data/app/tomcat-7-admin-hehe/
#pkill -9 java
kill -9 `ps -ef|grep java|grep -v grep|grep tomcat-7-admin-hehe |awk -F" " '{print $2}'`
rm -rf temp/*
rm -rf work/*
rm -rf webapps/ROOT

sh bin/startup.sh

接著說下掛載nfs共享:
即將視頻寫入到本機(jī)的/Data/app/tomcat-7-hehe/static/video目錄下(寫地址是http://testhehe.wangshibo/static/video),然后共享給圖片服務(wù)器192.168.1.6的/usr/local/nginx/html/hehe/video
[root@dev-test webapp]# /bin/mount -t nfs 192.168.1.6:/usr/local/nginx/html/hehe/video /Data/app/tomcat-7-hehe/static/video
[root@dev-test webapp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 12G 36G 26% /
tmpfs 32G 72K 32G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-lv_home 844G 69G 732G 9% /home
192.168.1.6:/usr/local/nginx/html/hehe/video 97G 64G 28G 70% /home/Data/app/tomcat-7-hehe/static/video

設(shè)置開機(jī)掛載
[root@dev-test webapp]# cat /etc/rc.local
......
/bin/mount -t nfs 192.168.1.6:/usr/local/nginx/html/hehe/video /Data/app/tomcat-7-hehe/static/video

nfs的部署參考:nfs服務(wù)部署記錄

二、圖片服務(wù)器上的操作
(1)nginx的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@static ~]# cat /usr/loca/nginx/conf/vhost/static.conf
server {
      listen  80;
        server_name  static.wangshibo.com;
        root   /usr/local/nginx/html/hehe;
  error_page 403 /403.html;
         
  location = /403.html {
           root   html;
           allow all;
        }
        location ~ \.mp4(.*)$  {                   #針對(duì)mp4格式的視頻讀取限制
            mp4;
            mp4_buffer_size 4M;
            mp4_max_buffer_size 10M;
        }
}
[root@static ~]# /usr/loca/nginx/sbin/nginx -t
[root@static ~]# /usr/loca/nginx/sbin/nginx
[root@static ~]# mkdir /usr/local/nginx/html/hehe/video

-----------------------------------------------------------------------------------
下面隨便說下該業(yè)務(wù)前后臺(tái)代碼發(fā)版腳本:

腳本在svn機(jī)器上:
[root@svn-server ~]# pwd
/Data/webroot_svncode/wangshibo

前臺(tái)代碼發(fā)版腳本
[root@svn-server ~]# cat up_pub_test_wangshibo.sh
#!/bin/bash
REMOTE_SERVER_IP="192.168.1.28"                           #測(cè)試服務(wù)器,ssh端口是25791
DEST_DIR="/Data/app/tomcat-7-hehe/webapps"
cd /Data/webroot_svncode/wangshibo/test/front            #在svn本機(jī)下載前臺(tái)代碼的存放路徑,第一次svn下載需要用戶名和密碼,后面就只需要update更新代碼即可

/usr/bin/svn update

/usr/bin/ssh -p25791 ${REMOTE_SERVER_IP} "rm -rf /Data/app/tomcat-7-hehe/webapps/ROOT*";                       #svn里面的war包名次是ROOT.war,具體理由上面已說明
/usr/bin/rsync -av -e "/usr/bin/ssh -p25791" --rsync-path="/usr/bin/rsync" --progress /Data/webroot_svncode/wangshibo/test/front/ROOT.war ${REMOTE_SERVER_IP}:${DEST_DIR};
sleep 10

/usr/bin/ssh -p25791 ${REMOTE_SERVER_IP} "/bin/sh /Data/app/tomcat-7-hehe/start.sh"; 

后臺(tái)代碼發(fā)版腳本
[root@svn-server ~]# cat up_pub_testadmin_wangshibo.sh
#!/bin/bash
REMOTE_SERVER_IP="192.168.1.28"
DEST_DIR="/Data/app/tomcat-7-admin-hehe/webapps"
cd /Data/webroot_svncode/wangshibo/test/bg

/usr/bin/svn update

/usr/bin/ssh -p25791 ${REMOTE_SERVER_IP} "rm -rf /Data/app/tomcat-7-admin-hehe/webapps/ROOT*";
/usr/bin/rsync -av -e "/usr/bin/ssh -p25791" --rsync-path="/usr/bin/rsync" --progress /Data/webroot_svncode/wangshibo/test/bg/ROOT.war ${REMOTE_SERVER_IP}:${DEST_DIR};
sleep 10

/usr/bin/ssh -p25791 ${REMOTE_SERVER_IP} "/bin/sh /Data/app/tomcat-7-admin-hehe/start.sh";

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Docker 常見應(yīng)用部署
Tomcat介紹
Docker筆記(2)
在linux下搭建NFS服務(wù)器實(shí)現(xiàn)文件共享
Nginx Resin高性能Java平臺(tái)搭建
yum安裝Tomcat
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服