elasticsearch 单机多节点配置

ES 选择版本 5.5.3 安装包地址 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.3.tar.gz 下载解压: 第一步修改 conf 文件夹中 elasticsearch.yml 和 jvm.option 具体配置 可如下 elasticsearch.yml:

主节点配置:

cluster.name: ***** ## 集群名

node.name: node-master ##节点名

http.cors.enabled: true ##

http.cors.allow-origin: "*" ##

transport.tcp.port: 9300 ##tcp 连接端口

transport.tcp.compress: true ## 是否允许 tcp协议访问 (走内网)

http.port: 9200 ## http 端口

http.enabled: true ## 是否允许 http 协议访问 (禁止则为内网)

node.master: true ## 主节点

node.data: true ##是否存数据节点

network.host: ************(一般设置为本机机器的内网IP)

host discovery.zen.ping.unicast.hosts: ["111.11.111.127"] ##自动探测拥有相同集群名节点

子节点配置:

cluster.name: ***** ## 集群名 (注意与主节点一致)

node.name: node-backup ##节点名

node.master: true

node.data: true

network.host: ************(一般设置为本机机器的内网IP)

http.port: 9201

transport.tcp.port: 9301

discovery.zen.ping.unicast.hosts: "111.11.111.127:9300"]

配置文件配置:

在conf 文件夹下:

jvm.option 配置 测试内存改为 512m 比较好测试 最大值 不可超过 30G

-Xms512m -Xmx512m

基础配置结束

centos配置:

建立一个elaseach 的用户和用户组,文件夹 命令: groupadd esuser useradd esuser -g esuser -p xxxxxx -g 是添加到组,-p是密码

把解压出的 elasticsearch5.6文件夹权限给 命令: esuser chown -R esuser:esuser elasticsearch5.6

如果出现错误 to low 错误

修改vm.map 限制

vim /etc/sysctl.conf vm.max_map_count=262144 vim /etc/security/limits.conf esuser hard nofile 65536 esuser soft nofile 65536 vim /etc/security/limits.d/20-nproc.conf *soft nproc 65535 * *hard nproc 65535

cat /etc/sysctl.conf | grep -v "vm.max_map_count" > /tmp/system_sysctl.conf echo "vm.max_map_count=262144" >> /tmp/system_sysctl.conf mv /tmp/system_sysctl.conf /etc/sysctl.conf

cat /etc/sysctl.conf vm.max_map_count=262144

sysctl -p ##重新加载配置命令 最后调用命令 sysctl -p

chown -R esuser:esuser /elasticsearch5.5.3 ##给予 用户 esuser 操作 elasticsearch5.5.3 文件夹 权限

su esuser 切换到 esuser 用户

cd /elasticsearch5.5.3/bin ./elasticsearch & 启动 es

head插件:

(head 插件不支持 x-pack 若安装 x-pack 记住换 kibana 注意:kibana 的 x-pack 服务是要付费的)

安装 head 插件 head 插件 在 es 5.x 版本 中 已经独立出来,所以不用放在 plugin 文件夹中

下载地址:https://github.com/mobz/elasticsearch-head.git

进入head 插件根目录 执行命令: npm install grunt-cli npm install grunt 由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要用户修改两个地方:

修改服务器监听地址

目录:head/Gruntfile.js

connect: { server: { options: { port: 9100, hostname: '', base: '.', keepalive: true } } } 增加hostname属性,设置为

修改head的连接地址:

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200"; 把localhost修改成你es的服务器地址,如:

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://*******:9200"; 第五步,运行head

首先开启5.0 ES。

然后在head目录中,执行npm install 下载以来的包: 如果下载慢 则手动下载

phamJS 是一种无头浏览器,注意自己下载安装配置 并添加环境变量 ---

phamJS 这个插件依赖可能会比较慢 ,可以直接去官网下 npm install 最后,启动 grunt server

此时 访问 *****:9100 即可 进入控制台

健康状态 为 YELLOW 如何解决:

一般来说 ,如果要建立 一个分片 一个 副本 则 需要建立两个节点集群 具体计算 :节点数<=主分片数*(副本数+1) 如果节点数量不够,或者副本没有分配个对应节点 则会出现 YELLOW 结局方案 :直接 在建立一个节点 加入 集群即可

分词器:

使用的是 IK 中文分词器 •ik_max_word:会将文本做最细粒度的拆分,例如「中华人民共和国国歌」会被拆分为「中华人民共和国、中华人民、中华、华人、人民共和国、 人民、人、民、共和国、共和、和、国国、国歌」,会穷尽各种可能的组合; • ik_smart:会将文本做最粗粒度的拆分,例如「中华人民共和国国歌」会被拆分为「中华人民共和国、国歌」; •”store”项了store项表示该项是否存储到倒索索引中去,并不是_source, •Index_analzyer:指的是索引过程中采用的分词器 •Search_analyzer:指的是检索过程中采用的分词器

自定义分词配置,以及自定义词库热更新配置 下次发出

spring-boot-es 项目中具体 产生 mapping 映射 可查看 spring-boot-es 项目中 entity/TbkGoods.java 文件 中 注释

如果查询 的返回结果分页 超过 10000页 怎么办?

可按 上图链接中的方式解决 tak_goods_za 表示索引

x-pack 的安装:

es 安装: bin/elasticsearch-plugin install x-pack x-pack 默认 账号:elastic 密码: changeme ------->

具体详情 : http://www.mamicode.com/info-detail-1865574.html

x-pack和head不能很好的兼容 这时再打开head的页面会发现head不能连上集群 解决方法是 修改 es 配置文件添加: xpack.security.enabled: false

elasticsearch 单机多节点配置


分享到:


相關文章: