发表于: 2018-03-01 22:17:40
1 692
今天完成的事情:
1.部署2个client到linux服务器.
https://www.cnblogs.com/shihaiming/p/5896283.html
照着教程装了第2个tomcat在服务器上,并配置相关信息。
并设置nginx通过负载均衡配置代理2个tomcat。
upstream orderapp {
server 127.0.0.1:8080 weight=1;
server 127.0.0.1:8081 weight=1;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://orderapp;
}
这样就实现了2个client的随机调用。
2.部署一个service到linux服务器,一个放在本地windows,模拟多太service服务器的效果。
修改rmi的配置为服务器ip和端口。
然后在服务端打开端口1199,并启动jar包。
启动2个srevice
3.随机关闭一个service,运行正常。
1.什么是rmi?为什么要使用rmi框架?
rmi(remote method invocation 远程方法调用)可以编写分布式对象,定义了一组远程接口,可以用于生成远程对象。client可以像调用本地对象一样用同样的语法调用远程对象。
使用rmi框架可以很容易的实现分布式。
2.什么是SCA?什么是分布式?分布式有什么优点?
SCA:软件通信体系框架(Software Communication Architecture,SCA)
分布式:将一个软件系统拆分成子系统,并散布到不同的设备上。
分布式的优点:
1.性能扩展,系统负载高。单台机器无法承载,使用多台机器提高负载能力。
2.增加可靠性,软件不是完美的,网络不是完美的,甚至机器本身也不可能是完美的,随时可能会出错,为了避免故障,需要将业务分散开保留一定的冗余度
3.为什么要把web和service分离?应用了哪些概念?
遇到的问题:
1.使用mava 把service打包为jar并运行的时候报错:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [applicationContext.xml]
资料:http://chenzhou123520.iteye.com/blog/1971322
解决方法,添加下面两条。
2.部署一个service到linux服务器,一台在windows本机运行,linux中的service会出现拒绝连接的错误。
找了一下资料,原因是,service的端口配置问题,servicePort如果不配置,则会使用随机端口,由于linux只开了有限的几个端口,所以被拒绝连接。
解决办法:在配置文件中指定serviceport为一个开启的端口。
<!--注册表 默认端口1099-->
<property name="registryPort" value="8080"/>
<!--指定服务使用接口,如果不指定则为随机-->
<property name="servicePort" value="80" />
https://www.mscharhag.com/java/java-rmi-things-to-remember
registryPort指定的端口为rmi的注册端口,只供连接使用,但是实际传输使用的端口是servicePort,servicePort不指定的话是一个随意端口。
明天的计划:
1.开始任务9.
评论