elasticsearch2.0集群安装配置
来源:互联网 发布:淘宝卖家被处罚的原因 编辑:程序博客网 时间:2024/05/21 10:03
背景
原来项目中我们主要用solr作为hbase的二级索引,这样来增强命中率,现在实时插入solr那一块感觉已经有点扛不住了,而solr集群配置后扩展也是一个问题,而他的一个竞争产品就是而是,原来在做日志分析的时候有尝试用elk,所以现在打算尝试使用一下es,看一下压测下的具体表现,最主要是es的去中心化对我们很有吸引力,动态扩展起来很方便
开始
一切的开始都是从集群的安装配置开始,原来使用elk的时候我配置的是单机,这次由于要做压力测试,所以打算用三台服务器
先解压,进入config目录,进行配置文件的更改,不得不说现在网上的教程大部分还是1.x版本的,2.x版本的教程不算多,而且2.x版本关于局域网内自动加入集群的配置和1.x也不太相同
# ======================== 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 see the documentation for further information on configuration options:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.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.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.mlockall: true## Make sure that the `ES_HEAP_SIZE` environment variable 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 adress to a specific IP (IPv4 or IPv6):## network.host: 192.168.0.1## Set a custom port for HTTP:## http.port: 9200## For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>## ---------------------------------- Gateway -----------------------------------## Block initial recovery after a full cluster restart until N nodes are started:## gateway.recover_after_nodes: 3## For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>## --------------------------------- Discovery ----------------------------------## Elasticsearch nodes will find each other via unicast, by default.## 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 nodes / 2 + 1):## discovery.zen.minimum_master_nodes: 3## For more information, see the documentation at:# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>## ---------------------------------- Various -----------------------------------## Disable starting multiple nodes on a single system:## node.max_local_storage_nodes: 1## Require explicit names when deleting indices:## action.destructive_requires_name: true
这个配置文件中主要要修改的几个参数是:
第一个是cluster.name,这个相当于集群的名字
在同一个集群中应该使用统一的cluster.name
第二个就是区分自己身份的node.name,相当于集群里的的唯一标识
第三个就是最重要的一个,也是和1.x版本有本质区别的参数discovery.zen.ping.unicast.hosts
这个参数主要将集群内所有机器的地址加入进去,这样就可以动态的进行扩展和平衡
第四个参数是对地址的绑定network.host,我们将对应ip绑定到该参数就可以
所以最后我们的配置是
ip机器名映射
配置参数
接下来进行启动,为了省事,我是直接以root启动的,不过一个大大的Error告诉我们不能用root启动
这类错误解决起来也相当easy,创建一个新的用户es,启动,注意的是要将路径中的data,log的权限也改成es可操作的,最简单的就是将整个文件夹的所有者指定为es,所以说linux就是一只权限狗
chown -R es:es es的安装路径
下面写一个简单的脚本简化启动
#!/bin/bashsu - es -c "espath/bin/elasticserach"
下次我们启动就直接执行脚本了
如果你观察到如下信息,恭喜你,集群已经可以运行了
下面查看集群信息:
在浏览器执行http://localhost:9200/_cat/node?V
注意把localhost换成集群中的任意一台
我们下面关掉node1,再次查看
再次运行,查看
发现现在master已经变成了node-3,所以说这个动态的扩展很有吸引力
插件安装
我主要安装一个head插件
执行的命令是
elasticsearch/bin/plugin install mobz/elasticsearch-head
很多教程都写成-install,但我发现其实正确的是install,这种方式是去github上clone项目安装,需要网络,如果我们没有网络,那可以选择离线安装,这里给个传送门
我们查看一下安装的效果,
执行http://localhost:9200/_plugin/head
end
后面的一段时间打算仔细研究一下这个技术,在研究后再和大家讨论交流
- elasticsearch2.0集群安装配置
- Elasticsearch2.0搭建集群及配置
- elasticsearch2.3.5集群配置
- elasticsearch2.3.1 集群安装
- elasticsearch2.0学习之路(一)es在linux中的安装和集群配置
- Elasticsearch2.3.4集群安装指南
- elasticsearch2.3安装以及集群部署
- elasticsearch2.3安装以及集群部署
- Elasticsearch2.4.X 搜索引擎框架 安装配置
- Elasticsearch2.4学习(二)------Elasticsearch2.4.1集群部署及elasticsearch.yml配置
- Elasticsearch2.4.1——安装配置######附带kibana/sense安装
- 单机模式下的elasticsearch2.3.4安装配置
- 虚拟机搭建Elasticsearch2.4.1集群
- Hadoop2.0集群安装配置
- elasticsearch2.1.1 安装
- ElasticSearch2.2.0安装(win7)
- CentOS 安装ElasticSearch2.x
- elasticsearch2.21 windows安装
- 秒杀多线程第一篇 多线程笔试面试题汇总 http://blog.csdn.net/morewindows/article/details/7392749
- hadoop2.6配置文件设置
- nyoj 蚂蚁的难题(二) 745 (DP+技巧转化)
- 实现BaseViewcontroller的滑动返回按钮效果
- 读取手机相册,获取选中的某张图片的路径
- elasticsearch2.0集群安装配置
- Note one
- Linux下软件开发RPC框架
- [LeetCode] Implement strStr()[字符串hash]
- 进程与线程
- adb start-server * daemon not running. starting it now on port 5037 * ADB ser
- A+B Again
- 秒杀多线程第二篇 多线程第一次亲密接触 CreateThread与_beginthreadex本质区别
- IOS-27-iOS/OS X内存管理:基本概念与原理/内存泄露分析