Centos 7 安装和配置es 7.6

https://www.elastic.co/guide/en/elasticsearch/reference/7.6/getting-started-install.html

https://www.elastic.co/guide/index.html

 

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

es 不能用root运行,因此,需要另外建立用户,包括各种目录、文件都要在这个用户权限下。

elasticsearch-7.6.2-linux-x86_64.tar.gz

tar -xvzf ***

es基于java,当然需要安装最新的java

es 目录下包含了一个jdk,es 建议使用这个jdk

因此,centos 配置使用这个jdk:
vim /etc/profile

export JAVA_HOME=/es/jdk
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

使环境变量生效
source /etc/profile


一般来说,centos自带java, /usr/bin/java
删除自带java:
rm -rf /usr/bin/java

ln -s /..../elasticsearch-7.6.2/jdk/java /usr/bin/java

java -version

whereis java
which java

2.配置文件  elasticsearch.yml

如何配置,请看文后

3.启动出现问题,需要修改以下文件

vim /etc/sysctl.conf
在尾部增加一句: vm.max_map_count=655360

Sysctl -p   # 让sysctl.conf 生效


Vim  /etc/security/limits.conf

aganliang soft nofile 65535
aganliang hard nofile 65535
aganliang soft nproc 65535
aganliang hard nproc 65535


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

将上面内容的*号改成用户名  aganliang

以上文件修改后都要source 一下,或者重启

4. 修改JVM  --config/jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

# xms 和xmx 设置成一样的,xmx不要超过内存的50%,总量不要超过30G
-Xms1g
-Xmx1g

5.运行和测试

cd /es-home
bin/elasticsearch

# 后台运行
bin/elasticsearch -d

# 查找es进程号
ps -ef | grep elastic

kill -9 进程号(上面查询到的进程号)

测试:http://localhost:9200

6.安装插件

# 查看已安装的插件
bin/elasticsearch-plugin list

# 安装一个插件
./bin/elasticsearch-plugin install analysis-icu

# 安装中文分词插件
./bin/elasticsearch-plugin install 
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.0/elasticsearch-analysis-ik-6.3.0.zip

# 测试
http://localhost:9200/_cat/plugins

7.单机运行多个实例——生产环境的话,建议一个机器一个节点

./bin/elasticsearch -E node.name=node1 -E cluster.name=mycluster -E path.data=node1.data -d
./bin/elasticsearch -E node.name=node2 -E cluster.name=mycluster -E path.data=node2.data -d
./bin/elasticsearch -E node.name=node3 -E cluster.name=mycluster -E path.data=node3.data -d

# 测试
http://localhost:9200/_cat/nodes

删除进程
ps  | grep elasticsearch

kill pid

 

附件:配置文件

# ======================== 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: /pgs/usr/local/es/data
#
# Path to log files:
#
path.logs: /pgs/usr/local/es/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: 192.168.0.1
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: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:

#cluster.initial_master_nodes: ["node-1", "node-2"]

cluster.initial_master_nodes: ["node-1"]
#
# 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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值