当前位置:   article > 正文

skywalking-3-存储改为elasticsearch

skywalking-3-存储改为elasticsearch

使用banyandb的standalone模式时,文件是存储到/tmp目录下,有点不方便,还是改回用es吧。

安装es

步骤一:下载和解压Elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.0-linux-x86_64.tar.gz
tar -xzf elasticsearch-7.17.0-linux-x86_64.tar.gz
sudo mv elasticsearch-7.17.0 /usr/local/elasticsearch
  • 1
  • 2
  • 3

步骤二:创建Elasticsearch用户和目录

创建用户和组:

groupadd elasticsearch
useradd -g elasticsearch -d /usr/local/elasticsearch -s /sbin/nologin elasticsearch
  • 1
  • 2

设置目录权限:

chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
  • 1

步骤三:创建Elasticsearch的数据和日志目录

mkdir -p /var/lib/elasticsearch
mkdir -p /var/log/elasticsearch
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
chown -R elasticsearch:elasticsearch /var/log/elasticsearch
  • 1
  • 2
  • 3
  • 4

步骤四:创建systemd服务文件

创建一个新的systemd服务文件:

vi /etc/systemd/system/elasticsearch.service
  • 1

在文件中添加以下内容:

[Unit]
Description=Elasticsearch
Documentation=https://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=elasticsearch
Group=elasticsearch
ExecStart=/usr/local/elasticsearch/bin/elasticsearch -d
StandardOutput=journal
StandardError=inherit
TimeoutStopSec=20
LimitNOFILE=65536
LimitNPROC=4096
TimeoutStartSec=75
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
WorkingDirectory=/

[Install]
WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

步骤五:重新加载systemd并启动Elasticsearch

重新加载systemd配置:

systemctl daemon-reload
  • 1

步骤六:调整vm.max_map_count

检查当前的大小:

sysctl vm.max_map_count
  • 1

如果小于262144则执行如下步骤

  1. 打开并编辑 /etc/sysctl.conf 文件:
vi /etc/sysctl.conf
  • 1
  1. 在文件末尾添加以下行:
vm.max_map_count=262144
  • 1

保存并关闭文件。

  1. 应用配置更改:
sysctl -p
  • 1

步骤七:限制Elasticsearch的内存

es很吃内存,限制下

vi /usr/local/elasticsearch/config/jvm.options
  • 1

在文件中找到以下两行,或在文件末尾添加它们:

-Xms4g
-Xmx4g
  • 1
  • 2

这表示将最小和最大堆内存都设置为4GB

步骤八:启用并启动Elasticsearch服务

systemctl enable elasticsearch
systemctl start elasticsearch
  • 1
  • 2

检查Elasticsearch服务状态:

 systemctl status elasticsearch
  • 1

你应该会看到Elasticsearch服务的运行状态。如果一切正常,Elasticsearch应该已经成功安装并在后台运行。

通过发送HTTP请求验证Elasticsearch是否成功启动:

curl -X GET "localhost:9200/"
  • 1

你应该会看到Elasticsearch的相关信息,表明它已成功启动并运行。

{
  "name" : "node-1",
  "cluster_name" : "my-cluster",
  "cluster_uuid" : "YiFrowgmQ5OMNVhiBH24Yw",
  "version" : {
    "number" : "7.17.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "bee86328705acaa9a6daede7140defd4d9ec56bd",
    "build_date" : "2022-01-28T08:36:04.875279988Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

将skywalking的存储配置改为es

回到apache-skywalking-apm-bin目录,打开config/application.yml文件,找到以下部分,并进行修改:

storage:
  selector: ${SW_STORAGE:elasticsearch}
  elasticsearch:
    nameSpace: ${SW_NAMESPACE:""}
    clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
    protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
    connectTimeout: ${SW_STORAGE_ES_CONNECT_TIMEOUT:3000}
    socketTimeout: ${SW_STORAGE_ES_SOCKET_TIMEOUT:30000}
    user: ${SW_ES_USER:""}
    password: ${SW_ES_PASSWORD:""}
    trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""}
    trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""}
    dayStep: ${SW_STORAGE_ES_DAY_STEP:1}
    indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:1}
    indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:1}
    bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:2000}
    flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10}
    concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2}
    metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
    segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
    advanced:
      - ${SW_STORAGE_ES_ADVANCED:""}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

修改完成后重启下:由于之前是直接nohup启动的,所以要先找到进程kill掉,再执行启动命令:

nohup ./bin/oapService.sh start &
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/903701
推荐阅读
相关标签
  

闽ICP备14008679号