centos7下elasticsearch 集群安装、配置及示例
2017-12-24 17:10
591 查看
简介
本文是在两台centos7虚拟机下,安装了三个节点。本次搭建es同时实践了两种模式——单机模式和分布式模式。条件允许的话,可以在多台机器上配置es节点,如果你机器性能有限,那么可以在一台虚拟机上完成多节点的配置。
如图,是本次3个节点的分布。
注:es的主节点是选出来的,它不一定在master 机器上,也就是es主节点不一定非得是node1或node2,也可能是node3.
下载后,放到对应的目录下并解压.
因为我们要配置包含三个节点的集群,可以先将其重命名为elasticsearch-node1。比如存放路径及命名如: /home/zkpk/elasticsearch-node1。
(1) 初步修改
打开/home/zkpk/elasticsearch-node1/config目录下的elasticsearch.yml 文件 ,修改以下属性值并取消该行的注释:
(2) 进一步修改
拷贝 elasticsearch-node1 整个文件夹,两份,一份elasticsearch-node2,一份elasticsearch-node3.
将elasticsearch-node2 文件夹copy到另外一台IP为192.168.8.105的机器上。而在 192.168.8.104 机器上有 node1和node3.
对于node3: node3和node1在一台机器上,node1的配置文件里端口默认分别是9300和9200,所以要改一下node3配置文件里的端口,elasticsearch.yml 文件修改如下:
对于node2: 对 elasticsearch.yml 修改如下:
1、运行elasticsearch:
前台运行命令:
后台运行命令:
2、关闭elasticsearch:
前台运行:可以通过”CTRL+C”组合键来停止运行
后台运行,可以通过”kill -15 进程号”停止.也可以通过REST API接口:
通过如下语句关闭整个集群:
本文是在两台centos7虚拟机下,安装了三个节点。本次搭建es同时实践了两种模式——单机模式和分布式模式。条件允许的话,可以在多台机器上配置es节点,如果你机器性能有限,那么可以在一台虚拟机上完成多节点的配置。
如图,是本次3个节点的分布。
hostname | IP | es节点 |
---|---|---|
master | 192.168.8.100 | node1、node3 |
slave | 192.168.8.101 | node2 |
1、下载
名称 | 版本 | 下载地址 |
---|---|---|
elasticsearch | 6.1.1 | https://www.elastic.co/downloads/elasticsearch/elasticsearch-6.1.1.tar.gz |
因为我们要配置包含三个节点的集群,可以先将其重命名为elasticsearch-node1。比如存放路径及命名如: /home/zkpk/elasticsearch-node1。
2、修改配置文件
(1) 初步修改 打开/home/zkpk/elasticsearch-node1/config目录下的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: elasticsearch # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: es-node3 # # 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: 192.168.8.100 # # 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.8.104", "192.168.8.105", "192.168.8.104:9301"] # # 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 network.bind_host: 192.168.8.104 #设置绑定的ip地址,这是master虚拟机的IP network.publish_host: 192.168.8.104 #设置其它节点和该节点交互的ip地址
(2) 进一步修改
拷贝 elasticsearch-node1 整个文件夹,两份,一份elasticsearch-node2,一份elasticsearch-node3.
将elasticsearch-node2 文件夹copy到另外一台IP为192.168.8.105的机器上。而在 192.168.8.104 机器上有 node1和node3.
对于node3: node3和node1在一台机器上,node1的配置文件里端口默认分别是9300和9200,所以要改一下node3配置文件里的端口,elasticsearch.yml 文件修改如下:
node.name: "es-node3"
# 在配置文件最后添加下面配置信息 transport.tcp.port: 9301 http.port: 9201
对于node2: 对 elasticsearch.yml 修改如下:
node.name: "es-node2" network.bind_host: 192.168.8.105 network.publish_host: 192.168.8.105 network.host: 192.168.8.105
二、运行 & 关闭 elasticsearch
1、运行elasticsearch:前台运行命令:
[lyz@localhost /]$ sh /home/zkpk/elasticsearch-node1/bin/elasticsearc
后台运行命令:
[lyz@localhost /]$ sh /home/zkpk/elasticsearch-node1/bin/elasticsearch -d
2、关闭elasticsearch:
前台运行:可以通过”CTRL+C”组合键来停止运行
后台运行,可以通过”kill -15 进程号”停止.也可以通过REST API接口:
通过如下语句关闭整个集群:
curl -XPOST http://主机IP:9200/_cluster/nodes/_shutdown通过如下语句关闭单个节点:
curl -XPOST http://主机IP:9200/_cluster/nodes/节点标示符(如es-node1)/_shutdown[/code] 三、错误解决
1、启动es过程这若报以下错误:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root这是因为elasticsearch默认是不支持用root用户来启动的,会报错。解决方案为添加其他用户:chown -R lyz:lyz elasticsearch-node12、对于以下错误:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方式如下:ulimit -n 65536 or set nofile to 65536 in /etc/security/limits.conf3、对如下错误max number of threads [1024] for user [xxx] is too low, increase to at least [2048]解决方式:ulimit -u 2048 Or set the nproc value to 2048 or above in /etc/security/limits.conf before starting elasticsearch.4、对于错误:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]解决:set vm.max_map_count=262144 in /etc/sysctl.conf then do sysctl -p
相关文章推荐
- Centos7下安装配置elasticsearch 6.3.1
- CentOS 7下安装 redis 3.0.6并配置集群的过程详解
- CentOS7下安装配置Spark-2.0.1集群
- CentOS7下安装配置zookeeper集群
- centos7下elasticSearch安装配置
- CentOS7下分布式系统GlusterFS安装配置
- centos7下安装配置redis3.0.4
- centos6.8下emqtt集群安装配置与测试验证
- centOS7下DNS服务器的安装与配置
- (一)Centos7下 Tengine安装和配置
- CentOS系统下的Hadoop集群(第1期)_CentOS安装配置
- CentOS 7下Apache HTTP Server安装配置
- Centos7下FastDFS 集群配置及添加storage节点+nginx
- Centos7下python3的安装,virtualenv、virtualenvwrapper隔离环境的配置
- Hadoop集群(第1期)_CentOS安装配置
- CentOS7下安装配置LAMP详细教程
- Centos中安装配置local/standalone模式和伪分布式模式hadoop集群
- CentOS7下Mysql Cluster 7.4安装配置
- CentOS下 elasticsearch集群安装
- Hadoop集群安装配置教程_Hadoop2.6.0_Ubuntu/CentOS