ES集群搭建—基于2.3.0版本

申明,该文档由一个同事提供,手动搭了下,在原基础上添加了一些配置,记录并添加进去


搭建前须知:
1.[主索引所占空间大小] < [原始文本文件大小*3],
因此可以根据原始文件大小来预估索引后的主索引文件大小。
(数据膨胀,通常为2倍左右,根据实际索引数据而定,但是一般会小于3倍)
2.[分片数] = [主索引所占空间大小]/20g,每个分片大小建议限制在30g以内,因此可以算出分片数。
分片数一旦指定,无法改变。

安装部署ES 集群环境
1.部署但节点ES服务
确保每台linux系统的防火墙关闭,并且ssh登录正常。并且有可运行的java环境(1.7以上版本)
1)关闭防火墙
centos6版本:
service iptables stop
chkconfig iptables off
centos7版本:
systemctl stop firewalld.service
systemctl disable firewalld.service
2)安装jdk
3)修改打开文件数
ulimit -n (查看当前打开文件数)
vim /etc/security/limits.conf (在文件最后加入以下内容)
* soft nofile 10240
* hard nofile 20480
su root
ulimit -n
hostnamectl set-hostname 机器名称(自定义)---比如本机主节点192.168.80.101,
设置为:hostnamectl set-hostname node101
2.部署
将elasticsearch-2.3.0.zip 文件夹复制到/opt目录下并解压
rz--->unzip elasticsearch-2.3.0.zip
将/etc/hosts文件添加 ip hostname ,(若部署完spark,则不需重新添加)
进入plugin文件夹下,若该文件夹下为空,则需要下载相应的插件:
/bin/plugin -install mobz/elasticsearch-head
/bin/plugin -install lukas-vlcek/bigdesk/2.5.0
找到config下的elasticsearch.yml ,该文件是es的配置文件
下面打~~的为修改的或添加的内容
~~cluster.name: hunancluster
~~node.name: node-es101

~~network.host: 1 92.168.134.129
~~path.data: /esdata
~~node.master: true
~~discovery.zen.ping.unicast.hosts: ["1 92.168.134.129"]
~~node.data: true

index.number_of_replicas: 0

bootstrap.mlockall: true

index.cache.field.type: soft
index.refresh_interval: 60s
index.merge.policy.merge_factor: 100
index.merge.policy.min_merge_docs: 2000
index.merge.policy.use_compound_file: false
index.translog.flush_threshold: 10000

indices.fielddata.cache.size: 30%

indices.fielddata.cache.expire: 5m

indices.recovery.max_size_per_sec: 100mb

indices.memory.index_buffer_size: 20%

indices.memory.min_shard_index_buffer_size: 16mb

indices.recovery.concurrent_streams: 5
cluster.routing.allocation.cluster_concurrent_rebalance: 4
cluster.routing.allocation.node_concurrent_recoveries: 4
cluster.routing.allocation.disable_allocation: false
~~threadpool.bulk.queue_size: 5000
index:
analysis:
analyzer:
ik:
type: ik
use_smart: true
ik_smart:
type: ik
use_smart: true
ik_max_word:
type: ik
use_smart: false
pinyin_analyzer_term:
type: custom
tokenizer: my_pinyin
filter:
- standard
- lowercase
- trim
pinyin_first_letter_analyzer:
type: custom
tokenizer: pinyin_first_letter
filter:
- standard
- lowercase
pinyin_analyzer:
tokenizer: my_pinyin_analyzer
filter:
- lowercase
- trim
- word_delimiter
pinyin_prefix:
type: custom
tokenizer: my_pinyin_prefix
filter:
- standard
- lowercase
- trim
- nGram
single:
tokenizer: singletoken
filter:
- lowercase
- trim
tokenizer:
my_pinyin:
type: pinyin
keep_first_letter: false
keep_full_pinyin: false
keep_joined_full_pinyin: true
padding_char: ''
my_pinyin_analyzer:
type: pinyin
keep_first_letter: false
padding_char: ''
my_pinyin_prefix:
type: pinyin
keep_first_letter: false
padding_char: ''
pinyin_first_letter:
type: pinyin
keep_first_letter: true
keep_full_pinyin: false
singletoken:
type: nGram
max_gram: 1
~~script.inline: true
~~script.indexed: true
3.修改 /bin/elasticsearch.in.sh文件里的ES_MIN_MEN 和ES_MAX_MEN两个值,一般设置服务器物理内存的60%
ES_MIN_MEM=512m
ES_MAX_MEM=512m
4.通过上述步骤,一个ES节点安装完毕,其他clustername名称相同,进行相同配置
将主节点的elasticsearch的所有内容scp到其他机器上:
scp -r elasticsearch-2.3.0/ root@1 92.168.134.129:/opt
scp -r elasticsearch-2.3.0/ root@1 92.168.134.129:/opt
并修改node.name cluser.name,更改 elasticsearch.in.sh的内存大小
注意:discovery.zen.ping.unicast.hosts:[1 92.168.134.129]不需要修改
5.启动
1)创建/esdata,这是上面config的配置文件里path.data的路径
mkdir /esdata
2)给/esdata,和/opt/elasticsearch 赋权
chmod -R 777 * /esdata
chmod -R 777 * /elasticsearch-2.6.0
3)切换到非root用户下:su - tydic
4) 进入elasticsearch/bin
cd /opt/elasticsearch-2.6.0/bin
setsid ./elasticsearch
5)每个节点都执行以上几个步骤
6)访问:http://192.168.134.129:9200/_plugin/head/
http://1 92.168.134.129:9200/_plugin/head/
http://1 92.168.134.129:9200/_plugin/head/
能看到各自节点即为部署完成
7)关闭服务
1.在浏览器输入:http://ip:9200/_flush
2.ps -ef|grep elasticsearch
找到tydic用户的进程
kill -9 ****
**df:查看磁盘占用空间
ES 启动之前 先查看进程是否有ES启动,如若有,则不需要再启动。

猜你喜欢

转载自blog.csdn.net/qq_30164139/article/details/78557524