系统相关
首页 > 系统相关> > 银河麒麟V10(Kylin Linux V10)安装ElasticSearch

银河麒麟V10(Kylin Linux V10)安装ElasticSearch

作者:互联网

前言

操作系统:Kylin Linux Advanced Server release V10 (Tercel)

elasticsearch-7.15.2


只允许普通用户操作,不允许root用户

注意:因为elasticsearch有远程执行脚本的功能所以容易中木马病毒,所以不允许用root用户启动,root用户是起不来的,赋权限,用一般的用户启动

要配置network.host才能别的机器或者网卡访问,否则只能是127.0.0.1或者localhost访问,这里配置成自己的局域网ip

注意:配置yml结尾的配置文件都需要冒号后面加空格才行


一、下载与解压

官网下载:https://www.elastic.co/cn/downloads/elasticsearch

image

image

image

注意下载的是aarch64版本的,并不是x86的。

将elasticsearch-7.15.2-linux-aarch64.tar.gz上传到服务器,并进行解压。

上传安装包:

将elasticsearch-7.15.2-linux-aarch64.tar.gz上传到 /usr/local/src
用Xftp软件连接登录部署es的服务器,进行安装包的上传
将安装包elasticsearch-7.15.2-linux-aarch64.tar.gz拖动到/usr/local/src文件夹中

Centos中查看有哪些用户

cut -d : -f 1 /etc/passwd

创建一个新用户

adduser elasticsearch

为新用户创建初始化密码

passwd elasticsearch

root用户解压文件

tar -zxvf elasticsearch-7.15.2-linux-aarch64.tar.gz

复制到指定目录下

cp -R elasticsearch-7.15.2 /usr/local/

设置授权范围

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


二、修改配置文件

1、修改 elasticsearch.yml 设置elastic

命令:

vi /usr/local/elasticsearch-7.15.2/config/elasticsearch.yml

使用上面命令打开elasticsearch.yml,在此文件编辑如下所示相应配置:

# ======================== 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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: 9200
#
# 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: ["127.0.0.1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

2、配置文件说明:

#集群名称
cluster.name: my-application
#节点名称
node.name: node-1
#当前节点所绑定的本机IP
network.host: 0.0.0.0
#初始化集群主节点
cluster.initial_master_nodes: ["node-1"]

注意:如果要配置集群需要两个节点上的elasticsearch配置的cluster.name相同,都启动可以自动组成集群,

这里如果不改cluster.name则默认是cluster.name=elasticsearch,nodename随意取但是集群内的各节点不能相同。

3、编辑 /etc/security/limits.conf,追加以下内容:

* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096

image

此文件修改后需要重新登录用户,才会生效

4、修改/etc/sysctl.conf:

vi /etc/sysctl.conf

使用上面命令打开/etc/sysctl.conf ,在此文件最下面加入如下所示配置:
vm.max_map_count=655360
保存后如下图所示:

image

执行如下所示命令:

sysctl -p
重新启动,成功。

三、启动ES

切换用户:

su elasticsearch

启动ES:

sh /usr/local/elasticsearch-7.15.2/bin/elasticsearch

后台启动:

sh /usr/local/elasticsearch-7.15.2/bin/elasticsearch -d

查看ES日志:

tail -f /usr/local/elasticsearch-7.15.2/logs/my-application.log

四、测试访问

本机访问:

[root@localhost ~]# curl 127.0.0.1:9200

image

局域网访问,注意:关闭防火墙
systemctl status firewalld

image


五、设置开机启动

1、建立服务文件

vi /lib/systemd/system/elasticsearch.service
[Unit]
Description=elasticsearch
[Service]
LimitNOFILE=100000
LimitNPROC=100000
ExecStart=/usr/local/elasticsearch-7.15.2/bin/elasticsearch
User=elasticsearch
Group=elasticsearch
[Install]
WantedBy=multi-user.target

2、设置开机自启动

重新加载systemd的守护线程:systemctl daemon-reload

systemctl enable elasticsearch

3、其它

启动elasticsearch.service:
systemctl start elasticsearch.service

查看elasticsearch.serivce状态:
systemctl status elasticsearch.service
ps aux|grep 

java如果出现错误可以使用如下命令查看日志:
journalctl -u elaticsearch.service

标签:node,7.15,Kylin,name,V10,cluster,ElasticSearch,usr,elasticsearch
来源: https://www.cnblogs.com/haolb123/p/16531406.html