一、前言
安装内容:
elasticsearch-7.10.1-linux-x86_64.tar.gz(依赖,注意版本)
kibana-7.10.1-linux-x86_64.tar.gz(依赖,注意版本)
apm-server-7.10.1-linux-x86_64.tar.gz (服务端包,注意版本)
elastic-apm-agent-1.21.0.jar(终端包,最新版就行)
前两者就不介绍了,网上的博客很多,会开始安装apm的应该也已经实现ELK搭建了。本文主要介绍apm和apm-agent的安装过程
开启Kibana,打开APM界面并setup instructions
网页很友好地给出了具体的配置过程。我在elasticsearch路径下创建了apm文件夹,apm server 和apm agent都放在这个底下
以及官方链接:https://www.elastic.co/guide/en/apm/agent/java/current/index.html
一、安装APM
1.安装包
APM官网安装地址(含完整操作过程):https://www.elastic.co/guide/en/apm/server/7.10/installing.html
或者直接使用链接https://artifacts.elastic.co/downloads/apm-server/apm-server-7.10.1-linux-x86_64.tar.gz(修改相应版本)
下载完安装包后,在elasticsrarch/路径下创建文件夹apm,将压缩包解压到该文件夹下
cd /data/elk-ayers/elasticsearch-7.10.1-node01/
mkdir apm
cd apm
tar -xvf apm-server-7.10.1-linux-x86_64.tar.gz
2.配置apm-server.yml
cd apm-server-7.10.1-linux-x86_64
vim apm-server.yml
################################################ APM Server ################################################
apm-server:
# Defines the host and port the server is listening on. Use "unix:/path/to.sock" to listen on a unix domain socket.
#apm服务端对外提供http访问ip,端口 目前apm-server本身不支持集群,可以通过反向代理的服务来实现
host: "ip:8200"
#允许在kibana中对apm客户端的配置做调整
kibana:
# For APM Agent configuration in Kibana, enabled must be true.
#enabled: false
enabled: true
# Scheme and port can be left out and will be set to the default (`http` and `5601`).
# In case you specify an additional path, the scheme is required: `http://localhost:5601/path`.
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:5601`.
#host: "localhost:5601"
#配置对应kibana的访问地址,
host: "ip:5601"
#================================= Template =================================
# A template is used to set the mapping in Elasticsearch.
# By default template loading is enabled and the template is loaded.
# These settings can be adjusted to load your own template or overwrite existing ones.
# Set to false to disable template loading.
setup.template.enabled: true
# Template name. By default the template name is "apm-%{[observer.version]}"
# The template name and pattern has to be set in case the elasticsearch index pattern is modified.
setup.template.name: "apm-%{[observer.version]}"
# Template pattern. By default the template pattern is "apm-%{[observer.version]}-*" to apply to the default index settings.
# The first part is the version of apm-server and then -* is used to match all daily indices.
# The template name and pattern has to be set in case the elasticsearch index pattern is modified.
setup.template.pattern: "apm-%{[observer.version]}-*"
#================================ Outputs =================================
# Configure the output to use when sending the data collected by apm-server.
#关闭iml策略
setup.ilm.enabled: false
#-------------------------- Elasticsearch output --------------------------
output.elasticsearch:
# Array of hosts to connect to.
# Scheme and port can be left out and will be set to the default (`http` and `9200`).
# In case you specify and additional path, the scheme is required: `http://localhost:9200/path`.
# IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
# hosts: ["localhost:9200"]
hosts: ["http://ip:9200","http://ip:9200"]
index: "apm-%{[observer.version]}-%{+yyyy.MM.dd}"
3、启动和查看
#非后台启动服务方式
./apm-server
#后台启动服务方式
nohup ./apm-server > /dev/null 2>&1 &
运行情况查看
#查看服务进程
ps -ef|grep apm-server
#日志信息查看,以nohup运行时可以查看
# find / -name nohup.out
tail /路径/nohup.out
在Kibana查看,单击check按钮,发现成功检测到我们的APM
二、安装Apm agent (以Java为例)
1.安装包
根据提示,到Maven Centra下载agent:https://search.maven.org/artifact/co.elastic.apm/elastic-apm-agent,我直接下载的是这时的最新版1.21.0版本
关于Agent的官方链接:https://www.elastic.co/guide/en/apm/agent/java/current/index.html
当前apm文件夹下存在apm-server-7.10.1-linux-x86_64,再创建一个apm-agent文件夹
cd /data/elk-ayers/elasticsearch-7.10.1-node01/apm
mkdir apm-agent
cd apm-agent
2.配置
按照官网提示输入下方代码。注意要调整javaagent、server_urls、最后一行,分别是 路径与文件名 、 ip:port 、我们想部署的jar包。
java \
-javaagent:/data/elk-ayers/elasticsearch-7.10.1-node01/apm/apm-agent/elastic-apm-agent-1.21.0.jar\
-Delastic.apm.service_name=my-application\
-Delastic.apm.server_urls=http://172.20.64.5:8200\
-Delastic.apm.application_packages=org.example\
-jar my-application.jar
3.查看进程
ps -ef|grep Delastic
发现有进程产生了,在kibana界面查看,发现生成了my-application
问题小结:
1.data path already locked by another beat.Please make sure that multiple beats not sharing the same data path.
2.unable to access jarfile xx.jar
这个问题一般是文件名或者路径出错了,检查以下路径和文件名,检查该文件是否存在
参考博客: