Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Chapter 1 Installing Elasticsearch
1. Download the elasticsearch – 7.15.0, download address: www.elastic.co/cn/download…
2. Upload the downloaded package to the Linux server and decompress the package
#Decompression packageTar - ZXVF elasticsearch 7.15.0 - Linux - x86_64. Tar. Gz#Enter the directoryCD elasticsearch - 7.15.0#Create a data folder to save the data
mkdir data
Copy the code
3. Run the config/ elasticSearch.yml command to configure Elasticsearch
Cluster. Name: apm - application node. The name: node - 1 path. Data: / app/elasticsearch/elasticsearch - 7.2.0 / data path. The logs: / app/elasticsearch/elasticsearch - 7.2.0 / logs#The IP address monitored by ESNetwork. The host: 0.0.0.0#The Node-2 node needs to be deleted
cluster.initial_master_nodes: ["node-1"]
#Elasticsearch -head, Kibana, etc
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
Copy the code
4. Es does not allow Linux to be started as user root because of system security considerations. For Elasticsearch, you can receive and execute scripts from user root. So we create an elsearch user and set permissions
#Create a user
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
#Set the permissionsChown -r elsearch: elsearch elasticsearch - 7.15.0Copy the code
5. Set parameters
#1, modify the/etc/security/limits file, add or modify the following line
elsearch hard nofile 65535
elsearch soft nofile 65535
#2. Modify the /etc/sysctl.conf file and add the following lines
vm.max_map_count=262144
#Select * from Elasticsearch where available: config/jvm.options
-Xms200m
-Xms200m
Copy the code
Or more basic configuration is completed, no problem, here I met a special problem, I am use yum to install the JDK, at the time of launch es always can’t read the JDK, finally have the local installation jdk11, and configured in the bin folder/elasticsearch has solved the problem.
#Specify jdk11Export JAVA_HOME = / usr/local/JDK - 11.0.12 export PATH = $JAVA_HOME/bin: $PATH#Add JDK judgmentif [ -x "$JAVA_HOME/bin/java" ]; Then JAVA="/usr/local/ jdK-11.0.12 /bin/ JAVA "else JAVA= 'which JAVACopy the code
6. Run the start command to switch to user elsearch in the elasticSearch -7.15.0 directory
su elsearch
./bin/elasticsearch -d
Copy the code
7. Check whether the IP address is 9200. The startup is successful if the following information is displayed
{ "name": "node-1", "cluster_name": "my-application", "cluster_uuid": "", "version": { "number": "" build_flavor 7.15.0", ":" default ", "build_type" : "tar", "build_hash" : "79 d629", "build_date" : "The 2021-09-16 T03:05:29. 143308416 z", "build_snapshot" : false, "lucene_version" : "" minimum_wire_compatibility_version 8.9.0", ":" 6.8.0 ", "minimum_index_compatibility_version" : "6.0.0-beta1"}, "tagline": "You Know, for Search"}Copy the code
Chapter ii SkyWalking Installation
1. Download SkyWalking installation package, download address: skywalking.apache.org/downloads/
Apache -skywalking-apm-es7-8.7.0.tar.gz – Elasticsearch7
2. Upload and download the compressed file to the Linux server and decompress the file
Tar ZXVF - apache - skywalking - apm - es7-8.7.0. Tar. GzCopy the code
3. SkyWalking OAP
3.1 Modifying the OAP configuration file config/application.yml
vim config/application.yml
#The default option in the configuration file is H2 data source, switch to ElasticSearch7, and configure elasticSearch7 to install your own information
storage:
selector: ${SW_STORAGE:elasticsearch7}
Copy the code
3.2 start the OAP
$ bin/oapService.sh
SkyWalking OAP started successfully!
Copy the code
3. SkyWalking UI
3.1 Modifying the SkyWalking UI port, the default is 8080
#Modify the webapp/webapp. Yml
server:
port: 18080
Copy the code
3.2 Starting the SkyWalking UI service
$ bin/webappService.sh
SkyWalking Web Application started successfully!
Copy the code
4.SkyWalking Agent
4.1 modify probe default configuration agent/config/agent. The config
The collector. Backend_service = ${11800} SW_AGENT_COLLECTOR_BACKEND_SERVICES: 192.168.0.4: agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:1}Copy the code
4.2 To place the probe, we need to copy the Agent directory to the server where the Java application is located, so that the Java application can be configured to use the SkyWalking Agent to detect the system by starting parameters without code intrusion
#Added in the service of startup command parameter javaagent, Dskywalking. Agent. The service_name
nohup java -javaagent:agent/skywalking-agent.jar -Dskywalking.agent.service_name=a -jar a.jar > a.log 2>&1 &
Copy the code
The principle of continuous update and other operations, including database monitoring, log monitoring, alarm function implementation.