1. 程式人生 > >電商平臺-伺服器部署設計與架構

電商平臺-伺服器部署設計與架構

補充說明:Java開源生鮮電商平臺-伺服器部署設計與架構,指的是通過伺服器正式上線整個專案,進行正式的運營。

              

回顧整個章節,我們涉及到以下幾個方面:

1. 買家端

2. 賣家端。

3. 銷售端

4. 配送端。

5.系統運營端。

6.公司網址

 

目前根據業務的情況,採購了阿里雲伺服器,由於是創業,我身上沒多少錢,只採購了一臺阿里雲.(具體配置如下與域名規劃如下)

 

公司網址: http://www.netcai.com

買家端:  http://buyer.netcai.com

賣家端:  http://seller.netcai.com

配送端:http://delivery.netcai.com

銷售端:http://sales.netcai.com

後臺端:http://admin.netcai.com

 

 具體費用如下:

 

 說明:域名採用二級域名進行轉發與配置。

           伺服器採用nginx進行根據域名轉發。相關的配置我就貼在下面

           如果需要進行業務的處理,比如說,我們發現買家的人數在增加,負載不夠,我們可以把買家的域名繫結在一臺新的伺服器上面進行

           最終也可以實現負載均衡的。

        

          實現的基礎業務邏輯如下:

          域名---》nginx-->tomcat7

 

         nginx的核心配置如下:

#admin port 8080
server
 {
        server_name admin.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-admin/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8080;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#buyer port 8081
server 
 {
        server_name buyer.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-buyer/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8081;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#seller port 8082
server
 {
        server_name seller.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-seller/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8082;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#delivery port 8083
server
 {
        server_name delivery.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-delivery/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8083;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#sales port 8085
server
 {
        server_name sales.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-sales/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8085;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#purchase port 8088
server
 {
        server_name purchase.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-purchase/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:8088;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#tongmei port 7070
server
 {
        server_name tongmei.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-tongmei/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:7070;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}


#users port 7080
server
 {
        server_name users.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/tomcat-users/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:7080;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

#monitor port 19999
server
 {
        server_name monitor.netcai.com;
        index index.html index.htm;
    access_log  /webser/nginx/monitor/access/log/access.log  access;
    location / {
                 proxy_pass        http://localhost:19999;
                 proxy_set_header   Host         $host;
                 proxy_set_header   X-Real-IP        $remote_addr;
                 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

ginx的配置相對而言比較簡單,根據域名找對應的tomcat伺服器即可,然後記錄相關的訪問日誌與路徑即可。

 

tomcat7的配置,那就更加的容易與簡單了。

相關的配置,大家去修改下server.xml,配置不同的埠即可。

最終形成以下的截圖:

 

 對此,有人認為這樣做,如果伺服器掛了,整個伺服器的應用都癱瘓了,我想說的是因為錢不多,只能這樣搞

至於高可用,高負載,高併發等等架構,如果有錢了,可以根據域名進行負載

檔案伺服器一臺

資料庫伺服器一臺

都是可以的,重點不是考慮成本,而是沒有多少成本,需要節約。請各位創業的人明白其中的道理。

 

最終,公司網址,就直接指向一個靜態的地址即可,然後直接用nginx跑

 

整個負載情況,我們可以用top檢視,也可以用monitor監控,都是可以的。

 

記住:我這裡面都是實戰,實戰,實戰,現在還在執行在,域名沒公開,是個隨便寫的域名。