(注:安装之前请先确认服务器已安装好jdk1.8并配置好环境变量)
Elasticsearch 6.5.3 地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.3.tar.gz
其他版本的直接改为对应版本号下载即可下载
用的filezilla将下载好的elasticsearch-6.5.3.tar.gz上传至服务器指定目录,我上传到自建目录:/www/server
解压:
[root@localhost ~]# cd /www/server
[root@localhost server]# tar -zxvf elasticsearch-6.5.3.tar.gz
[root@localhost server]# adduser hoey
[root@localhost server]# mkdir -p esdata/data
[root@localhost server]# mkdir -p esdata/log
[root@localhost server]# chown -R hoey elasticsearch-6.5.3
[root@localhost server]# chown -R hoey esdata
创建用户是为了防止以root身份启动时报如下错误:
Exception in thread “main” java.lang.RuntimeException: don’t run elasticsearch as root。
# ======================== 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):
#注意这里的路径是第三步创建的目录路径 /www/server/esdata/data
path.data: /www/server/esdata/data
#
# Path to log files:
#注意这里的路径是第三步创建的目录路径 /www/server/esdata/log
path.logs: /www/server/esdata/log
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#0.0.0.0代表任何IP都可访问
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#开启端口
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
action.destructive_requires_name: true
在上述文件加上
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
是为了解决以下报错:
unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
在文件中加上
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
修改limits.conf是为了解决以下报错:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
在文件最后加上:
vm.max_map_count = 2621441
让配置文件生效:
[root@localhost server]# sudo sysctl -p /etc/sysctl.conf
修改sysctl.conf是为了解决以下报错:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
将文件改为:
* soft nproc 4096
root soft nproc 4096
修改上述文件是为了解决以下报错:(注意我这里报的是4096,配置文件中的数据应根据报错的来改,改成大于等于报错数据即可)
[3]: max number of threads [2048] for user [tongtech] is too low, increase to at least [4096]
修改/etc/security/limits.conf文件需要重新登录才生效,所以我退出连接重新登录了一下.
1.启动前先关闭防火墙:(该命令是centos6.x版本永久关闭防火墙命令,centos7防火墙命令对应的是firewalld)
[root@localhost server]# chkconfig iptables off
2.进入elasticsearch的bin目录
[root@localhost server]# cd /www/server/elasticsearch-6.5.3/bin
3.切换为第三步创建的用户hoey
[root@localhost bin]# su hoey
4.启动elasticsearch(确认当前命令目录是在bin目录下)
[hoey@localhost bin]$ ./elasticsearch