es 集群搭建

tech2023-01-07  110

实验环境:三台虚拟机、配置Java环境 [root@localhost ~]# tar -zxf jdk-8u201-linux-x64.tar.gz -C /usr/local/ [root@localhost ~]# vim /etc/profile java version “1.8.0_201” Java™ SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot™ 64-Bit Server VM (build 25.201-b09, mixed mode)

[root@localhost ~]# source /etc/profile [root@localhost ~]# java -version 三台同样的操作:

[root@localhost ~]# mkdir -p /es/{data,log} 注:/es/data 数据目录 /es/log 日志目录 [root@localhost ~]# groupadd es [root@localhost ~]# useradd es -g es [root@localhost ~]# chown -R es:es /es/ [root@localhost ~]# vim /etc/hosts

[root@localhost ~]# scp /etc/hosts 192.168.43.8:/etc/hosts root@192.168.43.8’s password: hosts 100% 210 0.2KB/s 00:00 [root@localhost ~]# scp /etc/hosts 192.168.43.8:/etc/hosts root@192.168.43.8’s password: hosts 100% 212 0.2KB/s 00:00 [root@localhost ~]# scp /etc/hosts 192.168.43.9:/etc/hosts root@192.168.43.9’s password: hosts 100% 212 0.2KB/s 00:00 查看下其他两台主机的hosts文件: [root@localhost ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.43.7 bao1 192.168.43.8 bao2 192.168.43.9 bao3 每台主机都是同样的操作 Nofile:最大打开文件个数 [root@localhost ~]# ulimit -n 默认1024 1024 [root@localhost ~]# echo ‘* soft nofile 819200’ >>/etc/security/limits.conf [root@localhost ~]# echo ‘* hard nofile 819200’ >>/etc/security/limits.conf [root@localhost ~]# echo ‘* soft nprox 2048’ >> /etc/security/limits.conf [root@localhost ~]# echo ‘* hard nproc 4096’ >> /etc/security/limits.conf [root@localhost ~]# echo ‘vm.max_map_count = 655360’ >> /etc/sysctl.conf [root@localhost ~]# sysctl -p vm.max_map_count = 655360 三台主机安装es: [root@localhost ~]# tar -zxf elasticsearch-6.3.2.tar.gz [root@localhost ~]# mv elasticsearch-6.3.2 /usr/local/es [root@localhost ~]# vim /usr/local/es/config/elasticsearch.yml

84 gateway.recover_after_nodes: 3 当节点达到3个开始复制 85 gateway.recover_after_time: 5m 等待时间有5分钟,开始复制 86 gateway.recover_after_data_nodes: 2 如果超过等待时间,达到多少数据节点,启动recovery [root@localhost ~]# scp /usr/local/es/config/elasticsearch.yml bao2:/usr/local/es/config/elasticsearch.yml [root@localhost ~]# scp /usr/local/es/config/elasticsearch.yml bao2:/usr/local/es/config/elasticsearch.yml 其他两台主机只需要把节点名称和IP修改下就可以了:

三个集群启动es su es su到普通用户才能启动 /usr/local/es/bin/elasticsearch

查看集群状态: http://localhost:9200/_cluster/health?pretty

查看master

查看集群: curl -XGET http://192.168.43.100:9200/_cat/nodes 创建索引: curl -XPUT http://192.168.43.8:9200/kgc 创建映射:

添加纪录:

2.head插件—>图形界面的集群操作和管理工具 三台一样: 安装node.js: [root@bao2 ~]# tar -zxf node-v10.6.0-linux-x64.tar.gz [root@bao2 ~]# mv node-v10.6.0-linux-x64 /usr/local/node/ [root@bao2 ~]# vim /etc/profile

[root@bao2 ~]# source /etc/profile [root@bao2 ~]# node -v v10.6.0 [root@bao2 ~]# unzip elasticsearch-head-master.zip Archive: elasticsearch-head-master.zip f1b28e84151abddd178ce21b859ce33621cf5620

安装grunt工具: [root@bao2 ~]# npm install -g grunt --registry=https://registry.npm.taobao.org es-head代码进行编译 [root@bao2 es-head]# npm install -g cnpm --registry=https://registry.npm.taobao.org [root@bao2 es-head]# cnpm install

[root@bao2 es-head]# vim Gruntfile.js

[root@bao2 es-head]# vim /usr/local/es/config/elasticsearch.yml [root@bao2 es-head]# grunt server 启动 先启动es集群

最新回复(0)