Centos7环境ElasticSearch5.2.2集群安装

原创
2017/03/14 17:17
阅读数 1.9K

注意:测试环境是两个节点,ip分别是:

192.168.3.5    pd-elk-01

192.168.3.6    pd-elk-02

1、下载ElasticSearch5.2.2

请自行下载。

2、把ES上传到服务器/usr/local/src目录下(root用户)

3、解压(root用户)

tar -zxvf elasticsearch-5.2.2.tar.gz

4、创建目录

mkdir -p /data/es-data
mkdir /usr/local/elasticsearch/logs
chown -R es:es /data

5、移动(root用户)

把elasticsearch-5.2.2到/usr/local/,并且创建软连接,创建es用户,把elasticsearch授权给es用户

mv /usr/local/src/elasticsearch-5.2.2 /usr/local/
ln -s /usr/local/elasticsearch-5.2.2/ /usr/local/elasticsearch
useradd es
passwd es
mv /
cd /usr/local
chown -R es:es elasticsearch*

6、设置系统参数(root用户)

vim /etc/security/limits.conf 
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/sysctl.conf
添加下面配置: 
vm.max_map_count=262144 
保存后执行命令
sysctl -p 

7、配置(es用户)

切换到es用户配置:/usr/local/elasticsearch/config/elasticsearch.yml,

配置内容如下:

cluster.name: elasticsearch
node.name: linux-node1
path.data: /data/es-data
path.logs: /usr/local/elasticsearch/logs
network.host: 192.168.3.5
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.3.5", "192.168.3.6"]
discovery.zen.minimum_master_nodes: 2

如模板:

# ======================== 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: elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: linux-node1
#
# 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: /data/es-data
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: 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):
#
network.host: 192.168.3.5
#
# 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: ["192.168.3.5", "192.168.3.6"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 2
#
# 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

8、启动(es用户)

9、测试

10、配置node2

同样的方式把服务器192.168.3.6的elasticsearch配置好集群就搭建成功了,主要区别是配置文件的node名称和ip的设置不同

展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部