zoukankan      html  css  js  c++  java
  • api-gateway实践(07)新服务网关

    应用地址:http://10.110.20.191:8080/api-gateway-engine/

    一、准备工作

    1、xshell登陆云主机

    1.1、配置链接

     

     

    1.2、链接成功

    1.3、关闭防火墙

    查看centos版本号

    命令格式::

    查看状态:service iptables status

    临时开启:service iptables start

    临时关闭:service iptables stop

    临时关闭防火墙

    永久关闭防火墙 

    命令格式::

    永久关闭:chkconfig iptables off 

    永久开启:chkconfig iptables on

    2、xftp登陆云主机

    2.1、配置链接

    2.2、链接成功

    二、安装中间件

    tomcat8.5.15和jetty9.3.15二选一即可!

    tomcat8.0需要验证一下!!

    1、jdk1.8

    1.1、检查是否已安装

    首先判断是否已经安装java

    然后判断是否设置了环境变量,如果已经安装,提示如下:

    然后判断是否设置了环境变量,如果没有安装,提示如下:

    1.2、安装过程

    上传压缩包

    解压缩到指定目录

    tar -zxvf  jdk-8u131-linux-x64.tar.gz

    修改环境变量

    生效配置文件

    1.3、验证安装

    验证java和javac

    查看修改内容

     

    2、tomcat8.5.15

    2.1、检查是否已安装

    2.2、安装过程

    上传压缩文件

    解压到指定目录,修改目录的名字为tomcat8.5

    增加环境变量配置

    生效环境变量配置

     

    2.3、验证安装

    3、jetty9.3.15

    3.1、检查是否已安装

     

    3.2、安装过程

    上传解压

    配置环境变量

    生效修改的配置

    创建jetty的外置发布目录 jettyWebApps

    mkdir /opt/jettyWebApps

    初始化jetty的外置发布目录jettyWebApps

    java -jar $JETTY_HOME/start.jar --add-to-startd=http,plus,annotations,jsp,deploy

    现在,可以往jetWebApps/webapps发布我们的web应用了!

    3.3、验证安装(参见检查是否已安装!)

    三、发布应用

    tomcat8.5.15和jetty9.3.15二选一即可!

    tomcat8.0需要验证一下!!

    1、tomcat8.5

    1.1、发布应用

    更新代码,编译打包

    上传包到tomcat的webapps

    修改war包的名字

    1.2、启动应用

    $TOMCAT_HOME/bin/startup.sh

    1.3、验证应用

    访问应用地址:

    http://10.110.20.191:8080/api-gateway-engine/

    如果失败,查看防火墙是否已经关闭,service iptables status

    临时关闭防火墙:service iptables stop

    永久关闭防火墙:chkconfig iptables off

    访问地址:http://10.110.20.191:8080/api-gateway-engine/ 

    1.4、停止应用

    2、jetty9.3.15

    2.1、发布应用

     

    2.2、启动应用

    如果启动了Tomcat,可以先关闭Tomcat:$TOMCAT_HOME/bin/shutdown.sh

    nohup java -jar $JETTY_HOME/start.jar > /opt/jettyWebApps/ApiGw.log 2>&1 &

    2.3、验证应用

    http://10.110.20.191:9000/api-gateway-engine/ 

    2.4、停止应用 

    ps aux | grep java

    kill -s 9 xxxx

    3、tomcat8.0

    3.1、发布应用

    3.2、验证应用

    四、问题处理

    1、cant resolve localhost address

    Aug 14, 2017 4:33:31 PM redis.clients.jedis.HostAndPort getLocalHostQuietly
    SEVERE: cant resolve localhost address
    java.net.UnknownHostException: e0d0frxd: e0d0frxd: Name or service not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
    at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105)
    at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12)
    at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:37)
    at redis.clients.jedis.JedisPool.<init>(JedisPool.java:185)
    at redis.clients.jedis.JedisPool.<init>(JedisPool.java:162)
    at redis.clients.jedis.JedisPool.<init>(JedisPool.java:109)
    at com.inspur.cloud.apigw.engine.common.RedisConnectionPool.<init>(RedisConnectionPool.java:27)
    at com.inspur.cloud.apigw.engine.common.RedisConnectionPool.<clinit>(RedisConnectionPool.java:18)
    at com.inspur.cloud.apigw.engine.cache.UrlCache.initCache(UrlCache.java:53)
    at com.inspur.cloud.apigw.engine.StartServer.initialize(StartServer.java:147)
    at com.inspur.cloud.apigw.engine.StartServer.contextInitialized(StartServer.java:117)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:843)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:533)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:816)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:345)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1404)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1366)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:520)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
    at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:452)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:561)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
    at org.eclipse.jetty.server.Server.start(Server.java:422)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:389)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1516)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1441)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:214)
    at org.eclipse.jetty.start.Main.start(Main.java:457)
    at org.eclipse.jetty.start.Main.main(Main.java:75)
    Caused by: java.net.UnknownHostException: e0d0frxd: Name or service not known
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
    at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
    ... 54 more

    解决办法:

  • 相关阅读:
    单进程架构数据库谨防隐形杀手
    21.2 超时与重传的简单例子
    19日下午三点直播:DevOps体系中数据库端的四大问题及解决之道
    SQL无所不能:DBA宝妈宝爸系列分享
    用Excel做了7天报表,这个领导喜欢的可视化工具,只用了7小时
    从块结构谈表的存储参数与性能之间的关系
    MYSQL SHELL 到底是个什么局 剑指 “大芒果”
    大数据构架师经典学习宝典
    POJ 3171 区间最小花费覆盖 (DP+线段树
    POJ 3171 区间最小花费覆盖 (DP+线段树
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/7356418.html
Copyright © 2011-2022 走看看