麒麟V10系统安装部署elasticsearch

官方下载地址 :Download ElasticSearch
示例使用版本为7.17.18,jDK1.8

一、上传tar包

elasticsearch-7.17.18-linux-x86_64.tar.gz

二、解压服务包

复制代码
tar -xzf elasticsearch-7.17.18-linux-x86_64.tar.gz

[root@localhost elasticsearch-7.17.18]# ll
总用量 652
drwxr-xr-x  2 elasticsearch elasticsearch   4096  2月  2  2024 bin
drwxr-xr-x  3 elasticsearch elasticsearch    240 12月 11 10:23 config
drwxrwxr-x  3 elasticsearch elasticsearch     19 12月 11 10:25 data
drwxr-xr-x  8 elasticsearch elasticsearch     96  2月  2  2024 jdk
drwxr-xr-x  3 elasticsearch elasticsearch   4096  2月  2  2024 lib
-rw-r--r--  1 elasticsearch elasticsearch   3860  2月  2  2024 LICENSE.txt
drwxr-xr-x  2 elasticsearch elasticsearch   4096 12月 11 10:33 logs
drwxr-xr-x 61 elasticsearch elasticsearch   4096  2月  2  2024 modules
-rw-r--r--  1 elasticsearch elasticsearch 642830  2月  2  2024 NOTICE.txt
drwxr-xr-x  2 elasticsearch elasticsearch      6  2月  2  2024 plugins
-rw-r--r--  1 elasticsearch elasticsearch   2710  2月  2  2024 README.asciidoc
[root@localhost elasticsearch-7.17.18]# 

三、修改配置文件

conf/elasticsearch.yml

注意配置修改:
path.data:数据目录
path.logs:日志文件目录
network.host:网络地址
http.port:通信端口

固定写法配置:

复制代码
xpack.ml.enabled: false
ingest.geoip.downloader.enabled: false
discovery.type: single-node

完整配置:

复制代码
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/elasticsearch/data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 19250
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don't have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
xpack.ml.enabled: false
ingest.geoip.downloader.enabled: false
discovery.type: single-node

四、创建elasticsearch用户

elasticsearch不支持使用root用户启动,故而需要新增一个用户启动

复制代码
# 创建用户组
sudo groupadd elasticsearch
# 创建用户并加入用户组
sudo useradd -g elasticsearch elasticsearch
# 配置用户目录权限
sudo chown -R elasticsearch:elasticsearch /path/to/elasticsearch

五、注册service服务

创建elasticsearch.service

注意修改elasticsearch目录:/opt/service/elasticsearch/bin/elasticsearch

将编辑好的elasticsearch.service上传至/etc/systemd/system目录下

复制代码
[Unit]
Description=elasticsearch
After=network.target

[Service]
Type=forking
User=elasticsearch
Group=elasticsearch
ExecStart=/opt/service/elasticsearch/bin/elasticsearch -d 
PrivateTmp=true
LimitNOFILE=65535
LimitNPROC=4096
LimitMEMLOCK=infinity
TimeoutStopSec=0
KillSignal=SIGTERM
SendSIGKILL=no
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

注册并启动服务

复制代码
# 加载systemd配置
sudo systemctl daemon-reload

# 启动服务
sudo systemctl start elasticsearch

# 查看服务状态
sudo systemctl status elasticsearch

# 停止服务
sudo systemctl stop elasticsearch

# 重启服务
sudo systemctl restart elasticsearch

六、验证服务

浏览器访问:http://ip:19250

输出以下信息证明服务正常

复制代码
{
  "name": "localhost.localdomain",
  "cluster_name": "elasticsearch",
  "cluster_uuid": "1wMz0HsrQRWAHLAEv7pSdA",
  "version": {
    "number": "7.17.18",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "8682172c2130b9a411b1bd5ff37c9792367de6b0",
    "build_date": "2024-02-02T12:04:59.691750271Z",
    "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"
}
相关推荐
深紫色的三北六号4 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash8 小时前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
Elasticsearch18 小时前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
哈基咪怎么可能是AI18 小时前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行1 天前
Linux和window共享文件夹
linux
Sinclair2 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
Elasticsearch2 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
木心月转码ing2 天前
WSL+Cpp开发环境配置
linux
Rockbean3 天前
用40行代码搭建自己的无服务器OCR
服务器·python·deepseek
蝎子莱莱爱打怪3 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes