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

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

创建用户和组:

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

设置目录权限:

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

步骤三:创建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

步骤四:创建systemd服务文件

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

vi /etc/systemd/system/elasticsearch.service

在文件中添加以下内容:

[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

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

重新加载systemd配置:

systemctl daemon-reload

步骤六:调整vm.max_map_count

检查当前的大小:

sysctl vm.max_map_count

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

  1. 打开并编辑 /etc/sysctl.conf 文件:

    vi /etc/sysctl.conf

  2. 在文件末尾添加以下行:

    vm.max_map_count=262144

保存并关闭文件。

  1. 应用配置更改:

    sysctl -p

步骤七:限制Elasticsearch的内存

es很吃内存,限制下

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

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

-Xms4g
-Xmx4g

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

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

systemctl enable elasticsearch
systemctl start elasticsearch

检查Elasticsearch服务状态:

 systemctl status elasticsearch

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

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

curl -X GET "localhost:9200/"

你应该会看到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"
}

将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:""}

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

nohup ./bin/oapService.sh start &
相关推荐
晨欣2 小时前
Elasticsearch和Lucene之间是什么关系?(ChatGPT回答)
elasticsearch·chatgpt·lucene
筱源源8 小时前
Elasticsearch-linux环境部署
linux·elasticsearch
Elastic 中国社区官方博客19 小时前
释放专利力量:Patently 如何利用向量搜索和 NLP 简化协作
大数据·数据库·人工智能·elasticsearch·搜索引擎·自然语言处理
Shenqi Lotus1 天前
ELK-ELK基本概念_ElasticSearch的配置
elk·elasticsearch
yeye198912241 天前
10-Query & Filtering 与多字符串多字段查询
elasticsearch
Narutolxy1 天前
精准优化Elasticsearch:磁盘空间管理与性能提升技巧20241106
大数据·elasticsearch·jenkins
谢小涛2 天前
ES管理工具Cerebro 0.8.5 Windows版本安装及启动
elasticsearch·es·cerebro
LKID体2 天前
Elasticsearch核心概念
大数据·elasticsearch·搜索引擎
晨欣2 天前
Elasticsearch里的索引index是什么概念?(ChatGPT回答)
大数据·elasticsearch·jenkins
许苑向上2 天前
最详细【Elasticsearch】Elasticsearch Java API + Spring Boot集成 实战入门(基础篇)
java·数据库·spring boot·elasticsearch