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: feiguo ## 集群名 node.name: node-master ##节点名 http.cors.enabled: true ## http.cors.allow-origin: "*" ## transport.tcp.port: 9300 ##tcp 连接端口 transport.tcp.compress: true ## http.port: 9200 ## http 端口 http.enabled: true ## 是否可用 node.master: true ## 主节点 node.data: true ##是否存数据节点 network.host: 172.16.139.127 ##host discovery.zen.ping.unicast.hosts: ["172.16.139.127"] ##自动探测拥有相同集群名节点 ##子节点配置: cluster.name: feiguo node.name: node-backup node.master: true node.data: true network.host: 172.16.139.127 http.port: 9201 transport.tcp.port: 9301 discovery.zen.ping.unicast.hosts: ["172.16.139.127:9300"] jvm.option 配置 测试内存改为 512m 比较好测试 最大值 不可超过 30G -Xms512m -Xmx512m 基础配置结束: linux 配置: 建立一个elaseach 的用户和用户组,文件夹 groupadd esuser useradd esuser -g esuser -p xxxxxx -g 是添加到组,-p是密码 把解压出的 elasticsearch5.6文件夹权限给 esuser chown -R esuser:esuser elasticsearch5.6 修改vm.map 限制 vim /etc/sysctl.conf vm.max_map_count=262144 vim /etc/security/limits.conf #用来限制用户对系统资源的使用 esuser hard nofile 65536 #添加esuser用户组对系统资源的最大打开文件数为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 遇到的问题: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk 原因: 这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。 解决: 在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false 安装 head 插件 head 插件 在 es 5.x 版本 中 已经独立出来,所以不用放在 plugin 文件夹中 下载地址:https://github.com/mobz/elasticsearch-head.git 首先安装 nodejs yum remove nodejs yum install nodejs sudo yum install npm node -v npm -v 进入head 插件根目录 执行命令: npm install grunt-cli npm install grunt npm安装不了,尝试npm 换源 npm config set registry https://registry.npm.taobao.org/ npm config get registry 由于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 这个插件依赖可能会比较慢 ,可以直接去官网下 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页 怎么办? ![输入图片说明](https://gitee.com/uploads/images/2017/1110/234735_92ca136a_1227294.png "屏幕截图.png") 可按 上图链接中的方式解决 tak_goods_za 表示索引 x-pack 的安装: es 安装: bin/elasticsearch-plugin install x-pack x-pack 默认 账号:elastic 密码: changeme ------->已修改为 与服务器 root 密码一致 具体详情 : http://www.mamicode.com/info-detail-1865574.html x-pack和head不能很好的兼容 这时再打开head的页面会发现head不能连上集群 解决方法是 修改 es 配置文件添加: xpack.security.enabled: false
elasticsearch在CentOs下环境搭建
最新推荐文章于 2022-03-11 13:19:09 发布