分布式linux下的dubbo+zookeeper+tomcat
安装JDKcd /usr/localtar -zxvf jdk-7u80-linux-x64.gz配置环境变量复制下列参数至/etc/profile结尾vi /etc/profile#set java environmentJAVA_HOME=/usr/local/jdk1.7.0_80CLASSPATH=.:$JAVA_HOME/lib.tools.jarPATH=$JAVA_HO
·
安装JDK
cd /usr/local
tar -zxvf jdk-7u80-linux-x64.gz
配置环境变量
复制下列参数至/etc/profile结尾
vi /etc/profile
#set java environment
JAVA_HOME=/usr/local/jdk1.7.0_80
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
运行:source /etc/profile 使配置文件生效
安装Zookeeper
cd /usr/local
tar -zxvf zookeeper-3.4.6.tar
mv zookeeper-3.4.6 zookeeper-3.4.6-2181
mkdir -p /data/logs/zookeeper-2181/
mkdir -p /data/zookeeper-3.4.6-2181/data
修改环境变量
vi /usr/local/zookeeper-3.4.6-2181/bin/zkEnv.sh
#配置zookeeper日志打印zookeeper.out输出路径
ZOO_LOG_DIR="/data/logs/zookeeper-2181/"
#增加内存,在文件底部增加(生产可增加4096)
export JVMFLAGS="-Xms1024m -Xmx4096m $JVMFLAGS"
查询实例堆内存大小
ps -ef|grep zookeeper
#查询pid
jmap --heap pid
单实例配置
vi /usr/local/zookeeper-3.4.6-2181/conf/zoo.cfg
#心跳时间
tickTime=5000
initLimit=10
syncLimit=5
maxClientCnxns=0
#数据保存目录
dataDir=/data/zookeeper-3.4.6-2181/data
#客户端连接端口
clientPort=2181
#快照副本数量,默认为3
autopurge.snapRetainCount=5
#定时1个小时清除快照与事务日务
autopurge.purgeInterval=1
集群配置
复制/usr/local/zookeeper-3.4.6到备用服务2、3(需保持奇数个节点)
在部署zookeeper节点的各服务器data目录下新建myid标识节点编号
#节点1
echo 1 > /data/zookeeper-3.4.6-2181/data/myid
#节点2
echo 2 > /data/zookeeper-3.4.6-2181/data/myid
#节点3
echo 3 > /data/zookeeper-3.4.6-2181/data/myid
#各节点添加server信息
vi /usr/local/zookeeper-3.4.6-2181/conf/zoo.cfg
#心跳时间
tickTime=5000
initLimit=10
syncLimit=5
maxClientCnxns=0
#数据保存目录
dataDir=/data/zookeeper-3.4.6-2181/data
#客户端连接端口
clientPort=2181
#快照副本数量,默认为3
autopurge.snapRetainCount=5
#定时1个小时清除快照与事务日务
autopurge.purgeInterval=1
#(server.1 : 1代表机器ID,对应上述节点标识myid)
server.1=x.x.x.x:2555:3555
server.2=x.x.x.x:2555:3555
server.3=x.x.x.x:2556:3556
服务启动与停止
/usr/local/zookeeper-3.4.6-2181/bin/zkServer.sh start
/usr/local/zookeeper-3.4.6-2181/bin/zkServer.sh stop
如果是集群多节点依次启动
验证启动状态
telnet 127.0.0.1 2181
安装Tomcat
unzip apache-tomcat-7.0.63.zip -d /usr/local/
cd /usr/local/
mv apache-tomcat-7.0.63 apache-tomcat-7.0.63-4000
cd apache-tomcat-7.0.63-4000
chmod -R +x *
mv webapps/ROOT webapps/ROOT.bak
容器内存配置:
vi bin/catalina.sh
Catalina.sh头部增加语句
JAVA_OPTS='-Xms1024m -Xmx4096m -XX:PermSize=256M -XX:MaxPermSize=256M'
#修改容器端口
vi /usr/local/apache-tomcat-7.0.63-4000/conf/server.xml
<Server port="4005" shutdown="SHUTDOWN">
<Connector port="4000" protocol="HTTP/1.1"
connectionTimeout="20000"
minSpareThreads="64"
maxSpareThreads="128"
maxThreads="500"
redirectPort="4003" URIEncoding="UTF-8"/>
<Connector port="4009" protocol="AJP/1.3" redirectPort="4003" />
部署Dubbo监控中心
tar zxvf dubbo-monitor-simple-2.5.3-assembly.tar.gz
mv dubbo-monitor-simple-2.5.3 /usr/local/dubbo-monitor-simple-4010
配置
cd /usr/local/dubbo-monitor-simple-4010
vi conf/dubbo.properties
dubbo.container=log4j,spring,registry,jetty
dubbo.application.name=simple-monitor
dubbo.application.owner=
#需改为当前部署的主机IP
dubbo.registry.address=zookeeper://xx.xx.xx.xx:2181?backup=xx.xx.xx.xx:2181,xx.xx.xx.xx:2182
dubbo.protocol.port=4012
dubbo.jetty.port=4010
dubbo.jetty.directory=${user.home}/monitor
dubbo.charts.directory=${dubbo.jetty.directory}/charts
dubbo.statistics.directory=${user.home}/monitor/statistics
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN
启动
./bin/start.sh
停止
./bin/stop.sh
重启
./bin/restart.sh
调试
./bin/start.sh debug
系统状态
./bin/dump.sh
总控入口
./bin/server.sh start
./bin/server.sh stop
./bin/server.sh restart
./bin/server.sh debug
./bin/server.sh dump
标准输出
tail -f logs/stdout.log
验证启动状态
telnet 127.0.0.1 4012
help
Or:
echo status | nc -i 1 127.0.0.1 4012
服务访问
http://x.x.x.x:4010/
部署Dubbo管理控制台.
4.5.5 部署Dubbo管理控制台
unzip dubbo-admin-2.5.3.war -d /usr/local/wonhigh/dubbo-admin
修改server.xml
vi /usr/local/apache-tomcat-7.0.63-4000/conf/server.xml
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="dubbo-admin_access_log_4000." suffix=".txt" pattern="%t %h %l %u %r %s %b %I %D %{X-Real-Ip}i" resolveHosts="false" />
<Context path="" docBase="/usr/local/wonhigh/dubbo-admin" debug="0" reloadable="false"/>
</Host>
修改dubbo控制台配置
vi /usr/local/wonhigh/dubbo-admin/WEB-INF/dubbo.properties
dubbo.registry.address=zookeeper://xx.xx.xx.xx:2181?backup=xx.xx.xx.xx:2181,xx.xx.xx.xx:2182
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
启动
./bin/startup.sh
停止
./bin/shutdown.sh
访问
(用户:root,密码:root 或 用户:guest,密码:guest)
http://x.x.x.x:4000/
5 回退机制
rm -Rf /usr/local/apache-tomcat-7.0.63-4000
rm -Rf /usr/local/wonhigh/dubbo-admin
rm -Rf /usr/local/dubbo-monitor-simple-4010
4.3 端口规划
系统 http https shutdown ajp jmx dubbo
Tomcat原端口 8080 8443 8005 8009
Dubbo-admin 4000 4003 4005 4009
Dubbo-monitor 4010 4012
更多推荐
已为社区贡献1条内容
所有评论(0)