1. 程式人生 > >Centos7 安裝skywalking+elasticsearch,實現java web程式鏈路追蹤

Centos7 安裝skywalking+elasticsearch,實現java web程式鏈路追蹤

skywalking+elasticsearch實現java web程式鏈路追蹤

原始碼:聯絡作者1782800572

Skywalking暫不支援elasticsearch版本6.0.0以上

安裝elastic search5.6.13:
tar -xzvf elasticsearch-5.6.13.tar.gz --解壓安裝包
mv elasticsearch-5.6.13 /usr/local/elasticsearch --移動安裝包到指定目錄
cd /usr/local/elasticsearch --進入目錄
groupadd elsearch --建立elsearch組
useradd elsearch -g elsearch --建立elsearch使用者
mkdir -p /path/to/data
mkdir -p /path/to/logs
chown -R elsearch:elsearch /path/to/
chmod -R 776 /path/to/
chown -R elsearch:elsearch /usr/local/elasticsearch
chmod -R 776 /usr/local/elasticsearch
su elsearch
cd /usr/local/elasticsearch
vi config/elasticsearch.yml --修改配置檔案:

cluster.name: application ##叢集名稱
node.name: “node-1” ##節點名稱,同一叢集下名稱不同
node.master: true ##是否可選為主節點
node.data: true ##是否存放資料
path.data: /path/to/data ##資料目錄
path.logs: /path/to/logs ##日誌目錄
transport.tcp.port: 9300 ##tcp埠
http.port: 9200 ##http埠
discovery.zen.ping.unicast.hosts: [“節點ip”,”節點IP”] ##初始化節點
network.host: 0.0.0.0 ##預設0.0.0.0
network.bind_host: 0.0.0.0
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

瀏覽器檢視啟動狀態:
在這裡插入圖片描述

安裝skywalking 5.0.0-GA

官網下載:http://skywalking.apache.org/downloads/

解壓:tar –zxvf apache-skywalking-apm-incubating-5.0.0-GA.tar.gz
在這裡插入圖片描述
修改配置檔案:collector連線檔案
在這裡插入圖片描述

#cluster:
#  zookeeper:
#    hostPort: localhost:2181
#    sessionTimeout: 100000
naming:
  jetty:
    host: 192.168.37.130  #虛擬機器地址
    port: 10800
    contextPath: /
cache:
#  guava:
  caffeine:
remote:
  gRPC:
    host: 192.168.37.130
    port: 11800
agent_gRPC:
  gRPC:
    host: 192.168.37.130
    port: 11800
    #Set these two setting to open ssl
    #sslCertChainFile: $path
    #sslPrivateKeyFile: $path

    #Set your own token to active auth
    #authentication: xxxxxx
agent_jetty:
  jetty:
    host: 192.168.37.130
    port: 12800
    contextPath: /
analysis_register:
  default:
analysis_jvm:
  default:
analysis_segment_parser:
  default:
    bufferFilePath: ../buffer/
    bufferOffsetMaxFileSize: 10M
    bufferSegmentMaxFileSize: 500M
    bufferFileCleanWhenRestart: true
ui:
  jetty:
    host: 192.168.37.130
    port: 12800
    contextPath: /
storage:
  elasticsearch:
    clusterName: CollectorDBCluster
    clusterTransportSniffer: true
    clusterNodes: 192.168.37.130:9300
    indexShardsNumber: 2
    indexReplicasNumber: 0
    highPerformanceMode: true
    ttl: 7
#storage:
#  h2:
#    url: jdbc:h2:~/memorydb
#    userName: sa
configuration:
  default:
#     namespace: xxxxx
# alarm threshold
    applicationApdexThreshold: 2000
    serviceErrorRateThreshold: 10.00
    serviceAverageResponseTimeThreshold: 2000
    instanceErrorRateThreshold: 10.00
    instanceAverageResponseTimeThreshold: 2000
    applicationErrorRateThreshold: 10.00
    applicationAverageResponseTimeThreshold: 2000
# thermodynamic
    thermodynamicResponseTimeStep: 50
    thermodynamicCountOfResponseTimeSteps: 40

配置sky walking 視覺化介面
在這裡插入圖片描述
啟動skywalking:
在這裡插入圖片描述
瀏覽器檢視:
在這裡插入圖片描述
或者linux端:
ps –ef|grep collector 檢視是否啟動collector
ps –ef|grep web 檢視是否啟動web端
配置web介面:

server:
  port: 8080
collector:
  path: /graphql
  ribbon:
    ReadTimeout: 10000
    listOfServers: 192.168.37.130:10800  #192.168.37.130需要同collector配置檔案中一致

security:
  user:
    admin:
      password: admin   # 預設登陸名及密碼 user:admin pws:admin

訪問web介面
在這裡插入圖片描述
配置java專案:
在這裡插入圖片描述
進入agent資料夾配置java專案
在這裡插入圖片描述

vi agent.config

agent.application_code=CollectorDBCluster  #同es配置檔案中的cluster_name的值一致
collector.servers=192.168.37.130:10800  #同webapp.yml中配置一致

# Collector 接受追蹤資訊REST-Service 服務名稱.
# 預設不需要修改
collector.service_name=/segments
# 向collector傳送資料時,單次呼叫的最大容量
collector.batch_size=50
# 內部緩衝池大小,此值必須是2的指數倍。
buffer.size=512
# 日誌檔名稱字首
logging.file_name=skywalking-agent.log
# 日誌檔案最大大小
# 如果超過此大小,則會生成新檔案。
# 預設為300M
logging.max_file_size=314572800
# Logging level
logging.level=DEBUG

啟動命令:java -javaagent:/usr/local/project/springboot-es/agent/skywalking-agent.jar -jar springboot_es_demo.jar

**:標紅部分說明:這裡的sky walking-agent.jar是拷貝出來的agent目錄中的。