改进文档格式
diff --git "a/source/_posts/\344\270\200\345\215\241\351\200\232v5\347\263\273\347\273\237\345\256\211\350\243\205\351\203\250\347\275\262\346\211\213\345\206\214.md" "b/source/_posts/\344\270\200\345\215\241\351\200\232v5\347\263\273\347\273\237\345\256\211\350\243\205\351\203\250\347\275\262\346\211\213\345\206\214.md"
index 1093a0f..d6f5d5f 100644
--- "a/source/_posts/\344\270\200\345\215\241\351\200\232v5\347\263\273\347\273\237\345\256\211\350\243\205\351\203\250\347\275\262\346\211\213\345\206\214.md"
+++ "b/source/_posts/\344\270\200\345\215\241\351\200\232v5\347\263\273\347\273\237\345\256\211\350\243\205\351\203\250\347\275\262\346\211\213\345\206\214.md"
@@ -9,37 +9,88 @@
| 修改日期 | 版本 | 修改内容 | 修改人 |
|----------|-------|--------|--------|
| 2015-10-06| v1.0 | 建立 | 夏凯祥 |
-| 2016-06-22| v1.1 | 增加服务环境配置要求等内容 | 汤成 |
+| 2016-06-22| v1.1 | 增加服务器环境配置要求等内容 | 汤成 |
+| 2016-10-28| v1.2 | 增加服务器 ulimit 配置要求 | 汤成 |
## 部署环境
* **系统拓扑图**

* **数据库**
-数据库包括一卡通核心交易数据库(Oracle 11g)和缓存服务数据库(Redis)。交易数据库安装配置有专门DBA负责;缓存数据库由实施工程师负责安装配置,缓存服务器要求 4核CPU,8G 内存,500G 硬盘,一块千兆网卡。
+
+ 数据库包括一卡通核心交易数据库(Oracle 11g)和缓存服务数据库(Redis)。交易数据库安装配置有专门DBA负责;缓存数据库由实施工程师负责安装配置,缓存服务器要求 4核CPU,8G 内存,500G 硬盘,一块千兆网卡。
+
+ Redis 缓存服务安装采用 yum 从软件中心安装。
* **应用服务器**
-应用服务器提供一卡通服务门户、一卡通管理平台业务功能。一般需要部署两台服务器作为应用集群。服务器要求 4核CPU,8G 内存,200G硬盘,一块千兆网卡。操作系统为 [`CentOS 7`](http://www.centos.org) 或 [`OracleLinux 7`](https://www.oracle.com/linux/index.html) 64 位。
+
+ 应用服务器提供一卡通服务门户、一卡通管理平台业务功能。一般需要部署两台服务器作为应用集群。服务器要求 4核CPU,8G 内存,200G硬盘,一块千兆网卡。操作系统为 [`CentOS 7`](http://www.centos.org) 或 [`OracleLinux 7`](https://www.oracle.com/linux/index.html) 64 位。
* **API 服务器**
-API 服务器提供一卡通平台业务服务API,提供给包括设备前置、第三方应用前置、支付宝微信等充值服务前置接入的 API 服务。至少部署两台服务器作为应用集群,现场需要根据实际负载情况考虑增加 API 服务器数量。服务器要求 4核CPU,8G 内存,200G硬盘,一块千兆网卡。操作系统为 `CentOS 7` 或 `OracleLinux 7` 64 位。
+
+ API 服务器提供一卡通平台业务服务API,提供给包括设备前置、第三方应用前置、支付宝微信等充值服务前置接入的 API 服务。至少部署两台服务器作为应用集群,现场需要根据实际负载情况考虑增加 API 服务器数量。服务器要求 4核CPU,8G 内存,200G硬盘,一块千兆网卡。操作系统为 `CentOS 7` 或 `OracleLinux 7` 64 位。
* **nginx 代理服务器**
-nginx 代理服务器提供了对应用服务、API服务的反向代理服务。从安全性的要求,需要提供一卡通外网访问地址,并且服务器需要启用 HTTPS 安全访问方式。推荐使用学校申请的 HTTPS 安全证书,如果环境不具备可以选择自行颁发不受信证书。
- 服务器要求 2核CPU,4G 内存,200G硬盘,两块千兆网卡。操作系统为 `CentOS 7` 或 `OracleLinux 7` 64 位。
+ nginx 代理服务器提供了对应用服务、API服务的反向代理服务。从安全性的要求,需要提供一卡通外网访问地址,并且服务器需要启用 HTTPS 安全访问方式。推荐使用学校申请的 HTTPS 安全证书,如果环境不具备可以选择自行颁发不受信证书。
+
+ 服务器要求 2核CPU,4G 内存,200G硬盘,两块千兆网卡。操作系统为 `CentOS 7` 或 `OracleLinux 7` 64 位。nginx 服务使用 yum 从软件中心安装。
nginx 服务必须提供容错和负载功能,有两种部署方案:
* CDN 域名解析
* LVS + Keepalived 容错服务
-
-* **各种前置服务**
+* **前置服务**
前置服务包括消费前置、门禁前置、微信支付宝充值服务前置、圈存前置等等。前置服务需要根据现场使用情况进行配置,无特殊要求下,前置服务器配置:2核CPU,4G 内存,200G硬盘,一块千兆网卡,操作系统为 `CentOS 7` 或 `OracleLinux 7` 64 位。
`消费前置`- 消费前置可以部署两台实现容错。消费网关可以配置连接两台消费前置,网关会自动判断请求正常的消费前置。
+## 服务器要求
+**所有**的服务器必须按照下面要求进行配置。
+
+* **字符集**
+
+ 要求所有服务器必须采用 UTF-8 字符集。
+
+* **SELinux**
+
+ 服务器需要关闭 SELinux 。修改 /etc/selinux/config 文件, 将SELINUX=enforcing改为SELINUX=disabled,然后重启服务器。
+ **注意**:需要仔细检查是否拼写正确,否则服务器将无法启动。
+
+* **系统参数 ulimit**
+
+ 需要调整服务器 ulimit 限制参数, 可以修改 /etc/security/limits.conf 增加以下几行:
+
+~~~bash
+* soft nofile 65536
+* hard nofile 65536
+* soft nproc 131072
+* hard nproc 131072
+~~~
+
+修改完成后需要重新登录服务器,然后通过 ulimit -a 命令检查配置,正确的配置如下, 只要注意检查 open files 和 max user processes 参数值即可。
+
+```
+$ ulimit -a
+core file size (blocks, -c) 0
+data seg size (kbytes, -d) unlimited
+scheduling priority (-e) 0
+file size (blocks, -f) unlimited
+pending signals (-i) 62620
+max locked memory (kbytes, -l) 64
+max memory size (kbytes, -m) unlimited
+open files (-n) 65536
+pipe size (512 bytes, -p) 8
+POSIX message queues (bytes, -q) 819200
+real-time priority (-r) 0
+stack size (kbytes, -s) 10240
+cpu time (seconds, -t) unlimited
+max user processes (-u) 131072
+virtual memory (kbytes, -v) unlimited
+file locks (-x) unlimited
+```
+
## 安装说明
### Redis 服务安装配置
@@ -87,7 +138,7 @@
export JAVA_HOME=/usr/java/jdk7
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
-export JAVA_ENV=-Dfile.encoding=utf-8
+export JAVA_ENV=-Dfile.encoding=UTF-8
~~~
为了简化配置,我们提供了标准配置好的 Tomcat 包,请通[这里下载](http://localhost/)。下载后安装步骤如下:
@@ -129,16 +180,12 @@
~~~bash
#user nobody;
-worker_processes 2;
-
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
+worker_processes auto;
events {
+ use epoll;
worker_connections 1024;
+ multi_accept on;
}
http {
@@ -148,13 +195,14 @@
proxy_headers_hash_bucket_size 6400;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
+ '$status $request_time "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx-access.log main;
+ access_log /var/log/nginx/access.log main;
- sendfile on;
+ sendfile on;
tcp_nopush on;
+ tcp_nodelay on;
keepalive_timeout 65;
@@ -162,15 +210,16 @@
upstream epay_balance {
# 每个server表示一个服务地址
- server app1:8080 weight=5;
- server app2:8080 weight=5;
+ ip_hash;
+ server app1:8080;
+ server app2:8080;
keepalive 20;
}
upstream epayapi_balance {
# 每个server表示一个服务地址
- server api1:8080 weight=5;
- server api2:8080 weight=5;
+ server api1:8080 fail_timeout=30s;
+ server api2:8080 fail_timeout=30s;
keepalive 20;
}
@@ -190,7 +239,7 @@
ssl_prefer_server_ciphers on;
location = / {
- rewrite ^ https://$host:$server_port/epay/ permanent;
+ rewrite ^ /epay/ permanent;
}
rewrite ^/epayapi/services/api/(.*)$ /epay/api/$1 break;
@@ -201,7 +250,9 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://epay_balance;
+ proxy_next_upstream;
proxy_redirect http:// https://;
+ proxy_connect_timeout 25s;
}
location /epayapi {
@@ -211,9 +262,14 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://epayapi_balance;
+ proxy_next_upstream;
proxy_redirect http:// https://;
+ proxy_connect_timeout 25s;
}
}
+ match server_ok {
+ status 200;
+ }
}
~~~
@@ -239,8 +295,6 @@
在服务器上安装好tomcat,上传epayapi的发布包,并解压生成epayapi文件夹。
-修改epayapi配置文件。路径:tomcat/webapps/epayapi/WEB-INF/classes下的ksconfig.properties文件。修改对应前面安装的redis的ip和端口信息。
-
正常启动后,打开浏览器输入`http://ip:port/epayapi/services/common/getsystemversion`(ip为部署服务器的ip,端口port为默认8080的端口)会返回主机名+"-version"字样。
* **发布epay**