SSM系统架构
系统架构图
2 工程部署
2.1 部署分析
理论上服务器数量分析:
应用服务器(安装war包的服务器)
E3-manager 2
E3-cms 2
E3-search 2
E3-sso 2
E3-order 2
E3-cart 2
E3-manager-web 2
E3-search-web 2
E3-item-web 2
E3-portal-web 2
E3-sso-web 2
E3-order-web 2
E3-cart-web 2
总计:26台
中间件服务器
SVN+bug服务器(bugfree\bugzilia)+maven私服 1
Zookeeper注册中心 3
http服务器 Nginx + FastDFS 的storage 4
FastDFS 的tracker 2
Redis 2或者6
Solr服务器 1或者7
Activemq 2
反向代理服务器Nginx 2
Mysql 2
总计:19或者29台
Failover:容错
服务器数量总计:45或者55台
2.2 部署规划
应用服务器 |
|
|
|
|
工程名称 |
ip地址 |
端口 |
|
域名 |
E3-manager |
195 |
8080 |
20880 |
无 |
E3-cms |
195 |
8081 |
20881 |
无 |
E3-search |
195 |
8082 |
20882 |
无 |
|
||||
E3-sso |
196 |
8080 |
20883 |
无 |
E3-order |
196 |
8081 |
20884 |
无 |
E3-cart |
196 |
8082 |
20885 |
无 |
|
||||
E3-manager-web |
197 |
8080 |
|
manager.e3mall.cn |
E3-portal-web |
197 |
8081 |
|
|
E3-search-web |
197 |
8082 |
|
search.e3mall.cn |
|
||||
E3-item-web |
198 |
8080 |
|
item.e3mall.cn |
E3-sso-web |
198 |
8081 |
|
sso.e3mall.cn |
E3-order-web |
198 |
8082 |
|
order.e3mall.cn |
E3-cart-web |
198 |
8083 |
|
cart.e3mall.cn |
中间件服务器 |
|
|
|
服务器名称 |
ip地址 |
端口 |
域名 |
zookeeper注册中心 |
139 |
||
dubbo监控中心 |
139 |
|
|
redis |
139 |
|
|
solr |
139 |
|
|
activemq |
139 |
|
|
图片服务器 |
140 |
|
|
nginx反向代理 |
130 |
||
mysql |
130 |
2.3 部署步骤
使用maven实现tomcat的热部署。
前提:jdk1.7和tomcat都需要预先安装好。
2.3.1 Tomcat热部署配置
第一步:启动linux中的tomcat,然后访问tomcat首页中的manager-webapp链接,发现访问不了,需要进行第二步的配置。
第二步:需要配置tomcat的角色和用户,在tomcat的conf/tomcat-users.xml 这个文件中进行配置。
<role rolename="manager-gui" /> <role rolename="manager-script" /> <user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/> |
第三步:重启tomcat,再访问就可以使用tomcat本身的热部署配置
2.3.2 Maven+tomcat热部署使用方法
使用maven+tomcat对e3-manager工程进行热部署。
前提:需要启动dubbo的监控中心,来监测服务层服务是否发布成功。
第一步:需要在maven工程的pom文件中添加tomcat7插件,然后配置以下属性:
<build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId>
<configuration> <port>8080</port> <path>/</path> <!-- 配置tomcat服务器的配置URL --> <url>http://192.168.242.195:8080/manager/text</url> <username>tomcat</username> <password>tomcat</password> </configuration> </plugin> </plugins> </build> |
第二步:执行maven命令,进行热部署。
第一次部署命令:tomcat7:deploy
第二次部署命令:tomcat7:redeploy。
跳过单元测试命令:tomcat7:redeploy -DskipTests
第三步:访问dubbo注册中心,查看是否将sso服务发布成功。
2.3.3 工程部署
先启动所有服务器中间件
第一步:sql数据库需要在linux系统进行安装,并且将淘淘商城的数据库脚本创建数据表
第二步:修改工程中的相应的POM文件,配置tomcat热部署,参考部署规划的Excel表格。
第三步:需要修改工程中的数据库连接配置
第四步:修改工程中所有localhost的代码,改成对应的域名。
8082 |
www.e3mall.cn |
|
8085 |
search.e3mall.cn |
|
8086 |
item.e3mall.cn |
|
8088 |
sso.e3mall.cn |
|
8090 |
cart.e3mall.cn |
|
8092 |
order.e3mall.cn |
|
|
|
|
|
|
|
|
|
|
第五步:启动linux系统中的所有tomcat,因为通过maven进行热部署,需要tomcat是启动状态的。
第六步:执行maven命令上传war包。
2.4 配置hosts域名映射
使用switchHost工具配置
2.5 Nginx反向代理
130服务器中/usr/local/nginx/conf/nginx.conf,对tomcat服务进行反向代理配置。
#user nobody; worker_processes 1;
#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;
#pid logs/nginx.pid;
events { worker_connections 1024; }
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;
sendfile on; #tcp_nopush on;
#keepalive_timeout 0; keepalive_timeout 65;
#gzip on;
upstream manager.e3mall.cn { server 192.168.242.197:8080; } upstream www.e3mall.cn { server 192.168.242.197:8081; } upstream search.e3mall.cn { server 192.168.242.197:8082; } upstream item.e3mall.cn { server 192.168.242.198:8080; } upstream sso.e3mall.cn { server 192.168.242.198:8081; } upstream order.e3mall.cn { server 192.168.242.198:8082; }
server { listen 80; server_name manager.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://manager.e3mall.cn; index index.html index.htm; } } server { listen 80; server_name www.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://www.e3mall.cn; index index.html index.htm; } } server { listen 80; server_name search.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://search.e3mall.cn; index index.html index.htm; } } server { listen 80; server_name item.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://item.e3mall.cn; index index.html index.htm; } } server { listen 80; server_name sso.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://sso.e3mall.cn; index index.html index.htm; } } server { listen 80; server_name order.e3mall.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_pass http://order.e3mall.cn; index index.html index.htm; } }
} |