微服务spring-cloud 链路追踪skywalking6.x引入的示例分析,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
目前创新互联建站已为近1000家的企业提供了网站建设、域名、雅安服务器托管、网站托管维护、企业网站设计、德宏州网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
一、准备工作
环境:
1.jdk1.8,高于不支持
2.elasticsearch7.5.4搜索引擎:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.tar.gz
解压:tar -zxvf elasticsearch-6.5.4.tar.gz
配置:
vim elasticsearch-6.5.4/config/elasticsearch.yml
修改以下内容
cluster.name: myskywalking
path.data: /opt/data/es/data
path.logs: /opt/data/es/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 127.0.0.1 #推荐本机IP,
http.port: 9200
启动es
二、安装skywalking服务端
1.官网下载:http://skywalking.apache.org/
#wget http://mirror.bit.edu.cn/apache/skywalking/6.1.0/apache-skywalking-apm-6.1.0.tar.gz
#解压:tar -zxvf apache-skywalking-apm-6.1.0.tar.gz
2.修改webapp端口由默认8080,改成13800:
cd /home/wshop/skywalking/apache-skywalking-apm-bin/webapp
vi webapp.yml
server:
port: 13800
3.修改es配置
cd /home/wshop/skywalking/apache-skywalking-apm-bin/config
vi application.yml
4.启动
cd /home/wshop/skywalking/apache-skywalking-apm-bin/bin
./startup.sh
将启动两个服务:收集器11800端口和监控ui界面13800端口
访问:http://192.168.60.235:13800/
说明服务端已经启动成功;
三、客户端引入:
192.168.60.235:11800属于收集器
本地服务器,只要对应上"skywalking-agent.jar"
其他服务只要将agent目录复制过去,然后启动对应该服务接口,即能进行监控;
相应jar工程,在启动脚本前增加“ -javaagent:/home/wshop/skywalking/apache-skywalking-apm-bin/agent/skywalking-agent.jar -Dskywalking.agent.service_name=${APPNAME} -Dskywalking.collector.backend_service=192.168.60.235:11800” 即可。
完整客户端run脚本
#!/bin/bash
#########################################################################
# File Name: run.sh
# Function:
# Author: Mason
# Version: V1.0
# Created Time: 28/1/2019 11:41:48
#########################################################################
# chkconfig: - 98 33
# description: Starts and stops the java project daemon \
# used to provide some java jar packet services.
source /etc/profile
# base env parameters setting
BASEDIR=$(dirname $(readlink -f $0))
APPNAME=user-manager
VERSION=1.0.0
PORT=8710
JAVAOPT="-Xms256m -Xmx512m -XX:PermSize=128M -XX:MaxPermSize=256M"
# define some functions
get_pid(){
PID=$(ps -ef|grep ${APPNAME} |grep "java" |grep -v grep |awk '{print $2}')
}
start(){
if [ -z ${PID} ];then
nohup java ${JAVAOPT} -Dlogging.config=${BASEDIR}/logback-spring.xml -D$APPNAME -javaagent:/home/wshop/skywalking/apache-skywalking-apm-bin/agent/skywalking-agent.jar -Dskywalking.agent.service_name=${APPNAME} -Dskywalking.collector.backend_service=192.168.60.235:11800 -jar ${BASEDIR}/${APPNAME}-${VERSION}.jar --spring.config.location=${BASEDIR}/application.yml,/home/wshop/service/config/bootstrap.yml &>/dev/null &
inter=1
time=10
i=0
while ((i < time));do
get_pid
#if [ $(netstat -lntup|grep -c $PID) -le 1 ];then
if((i>(time-2)));then
if [ ${PID} ];then
echo "${APPNAME} started OK."
break
else
sleep ${inter}
let i++
fi
else
sleep ${inter}
let i++
fi
done
if ((i == time));then
echo "${APPNAME} started FAIL in $((inter*time)) second!"
exit 1
fi
else
echo "${APPNAME} is still running with pid ${PID}!"
exit 1
fi
}
stop(){
if [ ! -z ${PID} ];then
kill -9 ${PID} && echo "${APPNAME} was killed."
else
echo "${APPNAME} is not running!"
exit 0
fi
}
restart(){
stop
start
}
status(){
if [ ! -z ${PID} ];then
echo "${APPNAME} is running with pid ${PID}"
else
echo "${APPNAME} is not running."
fi
}
# the main program started
get_pid
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac
exit $?
看完上述内容,你们掌握微服务spring-cloud 链路追踪skywalking6.x引入的示例分析的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!