SpringCloud Alibaba microservice operation and maintenance one-integrated SkyWalking

Overview

Everyone knows that a request under the microservice architecture involves multiple services, and the service itself may also depend on other services. The entire request path constitutes a meshed call chain, and once a node in the entire call chain If an exception occurs, the stability of the entire call chain will be affected. If it is not handled in time, the entire system may crash.

In the face of the above situation, we need some tools that can help understand system behavior and analyze performance problems, so that when a failure occurs, we can quickly locate and solve the problem.

In this chapter, let's integrate SkyWalking monitoring for our microservices. After all, it's 2021. Few people in the production environment should use zipkin as a call chain monitoring.

 
I have already written a series of articles on SkyWalking in the "Operation and Maintenance Monitoring" series of articles, and interested students can visit the following link to view.

http://javadaily.cn/category/devops

This time I will write it again in the series of microservices for two reasons:

  • The original version uses SkyWalking 6.x, the new version has reached 8.3, the version is quite different.

  • Maintain the integrity of this series of articles

Version description: ElasticSearch7.10.1 + Skywalking8.3
Prerequisites: Prepare a virtual machine with JDK8

ElasticSearch installation and deployment

  • download

The download link of the official website is very slow, here is a recommended download address in China: https://www.newbe.pro/Mirrors/Mirrors-Elasticsearch/

  • unzip

Upload the file to the server directory/app/elasticsearch and unzip

cd /app/elasticsearch
tar -zxvf elasticsearch-7.7.0-linux-x86_64.tar.gz
  • Modify system memory configuration

In /etc/sysctl.confadd the following configuration

vm.max_map_count = 655360

The /etc/security/limits.confincrease follows the back

# End of file
*       soft    memlock   unlimited
*       hard    memlock   unlimited
*       hard    nofile    65536
*       soft    nofile    65536

After editing and use the command sysctl -preload the configuration

  • Create ElasticSearch launch user

ElasticSearch is not allowed to be started by the root user, so we need to create an elastic user to start ElasticSearch and grant the user corresponding permissions.

useradd elastic
chown -R elastic:elastic /app/elasticsearch/elasticsearch-7.10.1
  • Modify es configuration/app/elasticsearch/elasticsearch-7.10.1/config/elasticsearch.yml

cluster.name: sw-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]
  • Modify the JVM parameters of es/app/elasticsearch/elasticsearch-7.10.1/config/jvm.options

-Xms4g
-Xmx4g
  • Switch elastic user and start elastic

su elastic  # 切换用户
cd /app/elasticsearch/elasticsearch-7.10.1/bin
# 启动
./elasticsearch
# 后台启动
./elasticsearch -d

At this time, you will see the following prompt

future versions of Elasticsearch will require Java 11; your Java version from [/app/java/jdk1.8.0_18 1/jre] does not meet this requirement

ElasticSearch7 and above versions require JDK11 support, but our system is installed with JDK8 and the JAVA_HOME set by the environment variable is also JDK8.

[root@tymonitor bin]# which java
/app/java/jdk1.8.0_181/bin/java

[root@tymonitor bin]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

"This needs to be modified to use the JDK that comes with ES. Of course, if you install the JDK11+ version, the next step can be ignored."

  • 配置elsaticsearch jdk

Open the file /app/elasticsearch/elasticsearch-7.10.1/bin/elasticsearch-envand modify the following configuration

if [ ! -z "$JAVA_HOME" ]; then
  JAVA="$JAVA_HOME/bin/java"
  JAVA_TYPE="JAVA_HOME"
else
  if [ "$(uname -s)" = "Darwin" ]; then
     # macOS has a different structure
   JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
  else
      JAVA="$ES_HOME/jdk/bin/java"
  fi
    JAVA_TYPE="bundled jdk"
fi

change into:

if [ "$(uname -s)" = "Darwin" ]; then
    # macOS has a different structure
    JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
  else
    JAVA="$ES_HOME/jdk/bin/java"
  fi
  JAVA_TYPE="bundled jdk"
  • Restart, observe es startup log

  • Browser to view the running status of ElasticSearch http://xx.xx.xx.xx:9200/

{
  "name" : "node-1",
  "cluster_name" : "sw-application",
  "cluster_uuid" : "AOvOVaqWQ6uWDGQRx1l4nA",
  "version" : {
    "number" : "7.10.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
    "build_date" : "2020-12-05T01:00:33.671820Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

SkyWalking build

Download and install

  • download

Download the latest version of SkyWalking 8.3 from the official website. Because we need to use the ES7.x version, we need to download the ES7 version.

Download link: https://skywalking.apache.org/downloads/

version:apache-skywalking-apm-es7-8.3.0.tar.gz

  • Upload and unzip

Upload the downloaded file to the server /app/skywalking/

Use the command to unzip and rename the folder:

tar -zxvf apache-skywalking-apm-es7-8.3.0.tar.gz
mv apache-skywalking-apm-bin-es7/ apache-skywalking-apm

Configuration

  • Modify the UI page access port

Modify /app/skywalking/apache-skywalking-apm/webapp/webapp.yml, change the default port 8080 to other ports 8768

server:
  port: 8768
  • Modify storage mode

SkyWalking uses h2 as the storage database by default, we need to replace it with elasticsearch7;

storage:
  selector: ${SW_STORAGE:elasticsearch7}
  • Modify elasticsearch7 related configuration

Modify the nameSpace to the name of the current ES cluster, the nameSpace needs to be consistent with the previous ES configuration; clusterNodes is the node name

storage:
  elasticsearch7:
    nameSpace: ${SW_NAMESPACE:"sw-application"}
    clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
  • Start Skywalking

cd /app/skywalking/apache-skywalking-apm/bin
sh startup.sh
...
SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!

We can start after the completion of the command netstat -aptnto view the port occupancy

Port occupancy
  • Visit SkyWalking addresshttp://xx.xx.xx.xx:8768/

 

Service configuration

After the SkyWalking unzip agentfolder to the application server, such as /app/service/ltc/skywalking-agent/agent, modify the application server start command, the java -jarincrease between -javaagentinstruction.

Such as:

java -Xms4g -Xmx4g -javaagent:/app/service/skywalking-agent/agent/skywalking-agent.jar=agent.service_name=auth-service,agent.instance_name=auth-service-01,collector.backend_service=xx.xx.xx.xx:11800

Mainly configure three parameters

  • agent.service_name=auth-service

"Required" to specify the service name

  • collector.backend_service=xx.xx.xx.xx:11800

"Required" , used to specify the address of the back-end oap

  • agent.instance_name=auth-service-01

"Optional" for instance name, if not specified on the UI map will show UUID@IPformat

"Note: SpringCloud Gateway access SkyWalking need to be /agent/optional-plugins/apm-spring-cloud-gateway-2.x.x-plugin-8.3.0.jarcopied to / agent / plugins / directory."

After adding the SkyWalking probe to all services and starting it, visit the UI address of SKyWalking again, the effect is as follows:

 

 

 

Above, I hope to help you!

 

 

Guess you like

Origin blog.csdn.net/jianzhang11/article/details/112301082