安装步骤:
# 安装es7.8
cd /data
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-linux-x86_64.tar.gz
tar zxf elasticsearch-7.8.0-linux-x86_64.tar.gz
# es启动需要webops用户
useradd webops
chown webops:webops -R elasticsearch-7.8.0
su webops
# es7内置jdk,修改启动脚本
export JAVA_HOME=/data/els/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
#关闭防火墙、selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
[root@tata-search01 ~]# source /etc/profile
# 检查或修改文件句柄数
[root@tata-search01 limits.d]# vim /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 65535
root soft nproc unlimited
[root@tata-search01 security]# vim /etc/security/limits.conf
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
#修改虚拟内存
[root@tata-search01 limits.d]# vim /etc/sysctl.conf
vm.max_map_count=655360
[root@tata-search01 limits.d]# sysctl -p
vim ./config/jvm.options #这里的4g不能超过最大内存的一半,需要给lucene留内存
-Xms4g
-Xmx4g
:wq
# 启动
./bin/elasticsearch -d
# 查看日志
vim ./logs/elasticsearch.log
# 验证是否成功启动
curl localhost:9200
# es可视化插件,elasticsearch-head
head插件安装:
1.node.js 安装
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs
npm config set registry https://registry.npm.taobao.org/
检查是否更新成功
npm config get registry
2.安装elasticsearch-head
yum install -y git bzip2
git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install
npm install
nohup npm start &
ik安装:
cd /data/elas
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.8.0/elasticsearch-analysis-ik-7.8.0.zip
参考:
https://github.com/mobz/elasticsearch-head
https://github.com/medcl/elasticsearch-analysis-ik
https://www.cnblogs.com/ray-mmss/p/10591787.html
附件:配置文件:
[webops@tata-search03 config]$ vim 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: tata-www-elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: tata-www-node-3
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
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 this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["172.19.120.167","172.19.120.158","172.19.120.162"]
discovery.zen.ping.unicast.hosts: ["172.19.120.167","172.19.120.158","172.19.120.162"]
# Bootstrap the cluster using an initial set of master-eligible nodes:
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["172.19.120.167","172.19.120.158","172.19.120.162"]
#
# For more information, consult the discovery and cluster formation module documentation.
[webops@tata-search03 config]$
[webops@tata-search03 config]$
[webops@tata-search03 config]$
[webops@tata-search03 config]$
[webops@tata-search03 config]$ cat 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: tata-www-elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: tata-www-node-3
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
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 this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["172.19.120.167","172.19.120.158","172.19.120.162"]
discovery.zen.ping.unicast.hosts: ["172.19.120.167","172.19.120.158","172.19.120.162"]
# Bootstrap the cluster using an initial set of master-eligible nodes:
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["172.19.120.167","172.19.120.158","172.19.120.162"]
#
# For more information, consult the discovery and cluster formation 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
#node.master: true
http.cors.enabled: true
http.cors.allow-origin: "*"