Skywalking安装部署
一、准备工作
1、安装部署ES
参考:es安装部署.
2、下载Skywalking安装包
官网地址:下载地址.
3、安装jdk配置环境变量
二、安装部署
// 上传到该目录下
cd /usr/local;
// 解压
tar -zxvf apache-skywalking-apm-es7-8.4.0.tar.gz
//重命名文件夹
mv apache-skywalking-apm-es7-8.4.0 skywalking
安装后进入config目录修改启动配置
vim skywalking/config/application.yml
主要修改存储配置,配置为准备好的es服务
selector: ${SW_STORAGE:elasticsearch7}
nameSpace: ${SW_NAMESPACE:“my-application”}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:10.154.7.101:9200}
storage:
selector: ${SW_STORAGE:elasticsearch7}
elasticsearch7:
nameSpace: ${SW_NAMESPACE:"my-application"}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:10.154.7.101:9200}
protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""}
trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""}
dayStep: ${SW_STORAGE_DAY_STEP:1} # Represent the number of days in the one minute/hour/day index.
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:1} # Shard number of new indexes
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:1} # Replicas number of new indexes
# Super data set has been defined in the codes, such as trace segments.The following 3 config would be improve es performance when storage super size data in es.
superDatasetDayStep: ${SW_SUPERDATASET_STORAGE_DAY_STEP:-1} # Represent the number of days in the super size dataset record index, the default value is the same as dayStep when the value is less than 0
superDatasetIndexShardsFactor: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_SHARDS_FACTOR:5} # This factor provides more shards for the super data set, shards number = indexShardsNumber * superDatasetIndexShardsFactor. Also, this factor effects Zipkin and Jaeger traces.
superDatasetIndexReplicasNumber: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_REPLICAS_NUMBER:0} # Represent the replicas number in the super size dataset record index, the default value is 0.
user: ${SW_ES_USER:""}
password: ${SW_ES_PASSWORD:""}
secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""} # Secrets management file in the properties format includes the username, password, which are managed by 3rd party tool.
bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the async bulk record data every ${SW_STORAGE_ES_BULK_ACTIONS} requests
syncBulkActions: ${SW_STORAGE_ES_SYNC_BULK_ACTIONS:50000} # Execute the sync bulk metrics data every ${SW_STORAGE_ES_SYNC_BULK_ACTIONS} requests
flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests
concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200}
oapAnalyzer: ${SW_STORAGE_ES_OAP_ANALYZER:"{\"analyzer\":{\"oap_analyzer\":{\"type\":\"stop\"}}}"} # the oap analyzer.
oapLogAnalyzer: ${SW_STORAGE_ES_OAP_LOG_ANALYZER:"{\"analyzer\":{\"oap_log_analyzer\":{\"type\":\"standard\"}}}"} # the oap log analyzer. It could be customized by the ES analyzer configuration to support more language log formats, such as Chinese log, Japanese log and etc.
advanced: ${SW_STORAGE_ES_ADVANCED:""}
如果设置错误会启动报错
// 查看报错日志
cat ../logs/skywalking-oap-server.log
启动服务
cd ../bin
sh startup.sh
这时候会有两个服务启动,oapService&webappService
启动后都会提示success,如果配置错误需要查看上述日志排查问题
打开页面 ip:8080端口(默认)
三、启动服务加入agent
1、根据需要将插件移动到bootstrap-plugins目录
2、启动服务脚本加入以下内容
export SW_AGENT_NAME=dev-case # 配置 Agent 名字
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800 # 配置 Collector 地址
JAVA_AGENT=-javaagent:/usr/local/skywalking/agent/skywalking-agent.jar # 配置 Agent 启动指令
java $JAVA_OPTS $JAVA_AGENT -jar $JAR_NAME >> "$LOG_FILE" 2>&1
完整脚本如下
#!/bin/bash
export SW_AGENT_NAME=dev-case # 配置 Agent 名字
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800 # 配置 Collector 地址
IFS_old=$IFS
IFS=$'\n'
JAR_NAME=service.jar
LOG_FILE=service.log
JAVA_AGENT=-javaagent:/usr/local/skywalking/agent/skywalking-agent.jar # 配置 Agent 启动指令
JAVA_OPTS="-server -Xms1024m -Xmx1024m"
rm -f $LOG_FILE
#shut jar use kill
for line in $(ps -ef|grep "$JAR_NAME")
do
if [[ $line == *-jar* ]];then
ins_pid=$(echo $line|awk '{print $2}')
kill -9 $ins_pid
echo "========$JAR_NAME shutdown it's pid is $ins_pid"========
fi
done
#start jar
eval "nohup java $JAVA_OPTS $JAVA_AGENT -jar $JAR_NAME >> "$LOG_FILE" 2>&1 &"
echo "========$JAR_NAME startup success and logfile in $(pwd)/$LOG_FILE"========
IFS=$IFS_old
// 启动服务
sh service.sh
查看web页面
可能出现的问题
1、查看/agent/logs/里的日志,报插件不存在
WARN 2021-03-12 10:29:58:365 main AbstractClassEnhancePluginDefine : enhance class org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController by plugin org.apache.skywalking.apm.plugin.spring.mvc.v5.define.reactive.ReactiveControllerInstrumentation is not working. Because witness class org.springframework.web.reactive.result.method.InvocableHandlerMethod is not existed.
解决方法,将需要的插件移入bootstrap-plugins目录即可
2、es连接错误
org.elasticsearch.ElasticsearchStatusException: method [HEAD], host [http://localhost:9200], URI [/_template/yutao_alarm_record?master_timeout=30s], status line [HTTP/1.1 503 Service Unavailable]
可能是es集群名称或者节点没有配置正确