进入到idea的tomcat的run/debug配置,新建个remote tomcat,然后填写相关信息,如上图(注意远程调试端口)。

再选择Startup/Connection,如下图所示:

到此,idea已经配置好了,接下来将图上说的那段拷贝到远程的tomcat的catalina.sh文件中。

登陆到远程服务器,进入到tomcat的bin目录下,vi打开catalina.sh文件:

找到第一个JAVA_OPTS,添加:

JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,address=54531,suspend=n,server=y"或者

CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=54531,suspend=n,server=y"
填一个即可。

重启下tomcat。

netstat -an | grep 55555,查看下55555端口是否打开,打开说民设置成功。

这样既可以使用idea远程调试了。

另外最好的方式就是不要去改动默认的sh文件,那就是自己写的debug.sh。

将startup.sh拷贝一份,改名为debug.sh.

打开,内容如下:

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# -----------------------------------------------------------------------------

# Better OS/400 detection: see Bugzilla 31132
os400=false
case "`uname`" in
OS400*) os400=true;;
esac

# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh

# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "The file is absent or does not have execute permission"
    echo "This file is needed to run this program"
    exit 1
  fi
fi
export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=55555,suspend=n,server=y"

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

增加红色部分即可。

root@×××:/usr/local/tomcat/bin# sh debug.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/lib/jdk/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
root@×××:/usr/local/tomcat/bin# netstat -ano|grep 55555
tcp        0      0 0.0.0.0:55555           0.0.0.0:*               LISTEN      off (0.00/0/0)
root@×××:/usr/local/tomcat/bin#
如果按上面步骤执行后,看见设置的端口已经被监听,说明配置成功。

idea14远程调试linux下的tomcat的更多相关文章

  1. idea远程调试linux下的tomcat

    要远程调试代码,首先的保障本地的代码和远程tomcat的代码是同一份 首先在本地idea配置一个远程tomcat服务器 host就填写远程主机ip port填写访问的端口(不是调试端口) 然后在Sta ...

  2. 使用Windows上的Eclipse 远程调试 linux下的Tomcat

    1:修改Linux上Tomcat的catalina.sh,第一行添加declare -x CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_sock ...

  3. 转载:JProfiler远程监控LINUX上的Tomcat过程细讲

    来源于xuwanbest的博客   所谓"工欲善其事,必先利其器",好的工具确能起到事半工倍的作用.我用到的最多的就两个JConsole 和JProfiler .JConsole监 ...

  4. Linux下配置Tomcat服务器

    Linux下配置Tomcat服务器和Windows下其实差不多,可以去官网下载安装包释放或者在线下载,只是当时下载的windows.zip文件,现在下载.tar.gz格式的即可,下面使用命令行的方式安 ...

  5. Linux下部署tomcat

    在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...

  6. Linux下安装Tomcat服务器和部署Web应用

    一.上传Tomcat服务器

  7. linux下查看tomcat和jdk版本号

    linux下查看tomcat和jdk版本号的命令: 这个需要进入到bin目录下面 ,执行"./version.sh"命令 [root@hncsweb bin]# ./version ...

  8. 转】Linux下安装Tomcat服务器和部署Web应用

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4097608.html 感谢! 一.上传Tomcat服务器

  9. jmeter测试本地myeclips调试状态下的tomcat程序死锁

    在myeclipse调试状态下的tomcat程序,用jmeter测试,居然发生死锁,调试两天无果,直接运行tomcat而不通过myeclipse,无死锁,真是又好气又好笑..

随机推荐

  1. [翻译]NUnit---String && Collection && File && Directory Assert (七)

    StringAssert (NUnit 2.2.3) StringAssert类提供一系列检查字符串的方法. CollectionAssert (NUnit 2.4 / 2.5) Collection ...

  2. IDEA 单元测试

    下载所需的两个 jar 包,下载地址:Download and Install · junit-team/junit4 Wiki · GitHub junit-4.12.jar hamcrest-co ...

  3. 求欧拉回路 UOJ117

    传送门什么是欧拉回路呢……?欧拉回路的定义就是从vi出发到vi,经过每条边有且只有一次的路径. 就很像一笔画. 欧拉回路的性质较多……定理也很多……直接证明很长……我们还是直接说怎么判定,怎么求欧拉回 ...

  4. SPI操作flash MX25L64读写数据

    STM32F10X SPI操作flash MX25L64读写数据 简单的一种应用,ARM芯片作为master,flash为slaver,实现单对单通信.ARM主控芯片STM32F103,flash芯片 ...

  5. 微信公众平台appid和appsecret在哪

    1.appid和appsecret是微信公众平台服务号才有的,如果自己家的公众平台不是服务号,需要升级为服务号. 2.登录服务号,登录“服务”条目,“服务中心”如图. 3.点击“自定义菜单”-“开发模 ...

  6. 为了一个句号,写了好多行的代码——值!(html 表单的处理)

    个人信息表 <span style="font-size:18px;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML ...

  7. Java源码——Integer

    最近在研究java的源代码,但是由于自己英语水平有限,所以想使用中文注释的方式把源码里的方法全部重写 一遍,下面是楼主整理出来的一小部分.我把整体的项目托管到GitHub上了,欢迎大家前去交流学习. ...

  8. 为什么JavaWeb项目要分层

    首先让我们坐着时光机回到n年前的web开发.那个时候最早都是静态的html页面,后来有了数据库,有了所谓的动态页面,然后程序猿在编码的时候,会把所有的代码都写在页面上,包括数据库连接,包括事务控制,接 ...

  9. Akka源码分析-Cluster-Distributed Publish Subscribe in Cluster

    在ClusterClient源码分析中,我们知道,他是依托于“Distributed Publish Subscribe in Cluster”来实现消息的转发的,那本文就来分析一下Pub/Sub是如 ...

  10. 数组去重----es6&es5&数组对象去重

    es6方法: 普通数组: 1.使用Array.from(new Set(arr)); /* * @param oldArr 带有重复项的旧数组 * @param newArr 去除重复项之后的新数组 ...