最近在网上看到很多ElasticSearch集群的搭建方法,本人在这人使用Elasticsearch5.0.1版本,介绍如何搭建ElasticSearch集群并安装head插件和其他插件安装方法。

一、搭建环境(2台CentOS 7系统服务器)

所需软件

  Elasticsearch-5.0.1.tar.gz
  node-v4.2.2-linux-x64.tar.gz

基础环境JAVA

  yum -y install java-1.8*
  java -version #检查java是否安装成功

测试环境关闭防火墙和selinux

    关闭防火墙
systemctl stop firewalld
systemctl diable firewalld
关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #需要重启系统

配置主机名和hosts文件

  配置hostname
sed -i 's/localhost/es1/g' /etc/hostname
     sed -i 's/localhost/es1/g' /etc/hostname
  配置hosts vi /etc/hosts #添加一下内容 
     172.16.81.133 es1
     172.16.81.134 es2

创建用户

        useradd elasticsearch
passwd elasticsearch #然后输入两次密码即可!

二、安装es软件(tar.gz解压安装)

         tar -zxvf elasticsearch-5.0.1.tar.gz
mv elasticsearch-5.0.1 elasticsearch5
cd elasticsearch5

创建data和logs目录

         mkdir -p es
mkdir -p es/data
mkdir -p es/logs

修改配置文件

            cd /opt/elasticsearch5/config
vi elasticsearch.yml
es1配置文件如下:
cluster.name: es-cluster #集群名,不同名称代表不同集群
node.name: es1 #节点名称,自定义
path.data: /opt/elasticsearch5/es/data #数据路径
path.logs: /opt/elasticsearch5/es/logs #日志路径
bootstrap.memory_lock: false #关闭锁内存
network.host: 172.16.81.133 #绑定IP地址
http.port: 9200 #绑定端口
discovery.zen.ping.unicast.hosts: ["es1", "es2"] #集群列表,类型数组,可以是IP或域名
discovery.zen.minimum_master_nodes: 2 #节点数不能超过节点总数量
http.cors.enabled: true #开启http网络节点发现
http.cors.allow-origin: "*" #允许所有同网段节点发现
es2配置文件如下:
cluster.name: es-cluster #集群名,不同名称代表不同集群
node.name: es2 #节点名称,自定义
path.data: /opt/elasticsearch5/es/data #数据路径
path.logs: /opt/elasticsearch5/es/logs #日志路径
bootstrap.memory_lock: false #关闭锁内存
network.host: 172.16.81.134 #绑定IP地址
http.port: 9200 #绑定端口
discovery.zen.ping.unicast.hosts: ["es1", "es2"] #集群列表,类型数组,可以是IP或域名
discovery.zen.minimum_master_nodes: 2 #节点数不能超过节点总数量
http.cors.enabled: true #开启http网络节点发现
http.cors.allow-origin: "*" #允许所有同网段节点发现

配置内核参数

            vi /etc/security/limits.conf    #添加以下内容
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p

修改文件权限

            chown -R elasticsearch:elasticsearch elasticsearch5

切换到elasticsearch启动程序

            su - elasticsearch
cd /opt/elasticsearch5/bin
./elasticsearch #观察输出信息
./elasticsearch & #后台运行

查看端口

            netstat -lntp
结果:
tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN 8892/grunt
tcp6 0 0 172.16.81.133:9200 :::* LISTEN 5250/java
tcp6 0 0 172.16.81.133:9300 :::* LISTEN 5250/java
存在9100、9200、9300上述上个端口即可!

三、安装elasticsearch-head插件

安装依赖包和工具包

yum -y install wget git bizp2

git项目到本地

cd /opt
git clone git://github.com/mobz/elasticsearch-head.git

安装node、npm、grunt

wget https://nodejs.org/dist/v4.2.2/node-v4.2.2-linux-x64.tar.gz
tar -zxvf node-v4.2.2-linux-x64.tar.gz

设置链接

ln -s /opt/node-v4.2.2-linux-x64/bin/node /usr/sbin/node
ln -s /opt/node-v4.2.2-linux-x64/bin/npm /usr/sbin/npm

设置npm代理镜像

npm config set registry https://registry.npm.taobao.org

安装、配置grunt

npm install -g grunt
ln -s /opt/node-v4.2.2-linux-x64/lib/node_modules/grunt/bin/grunt /usr/sbin/grunt

修改elasticsearch-head配置文件

                cd /opt/elasticsearch-head
vi _site/app.js
// 把localhost改为ip
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.16.81.89:9200";
修改Gruntfile.js
connect: {
server: {
options: {
hostname: "0.0.0.0", #添加这里
port: 9100,
base: '.',
keepalive: true
}
}
}

安装head

 cd /opt/elasticsearch-head
npm install

启动head

grunt server &

浏览器访问(最好是谷歌浏览器)

接口:
http://172.16.81.133:9200/
集群:
http://172.16.81.133:9100/   #五角星代表主节点,圆点代表数据节点
查看主master是谁:
http://172.16.81.133:9200/_cat/master
更多URL信息
http://172.16.81.133:9200/_cat

最后在介绍下5.x安装插件的方法,这儿我们举例安装!

我们将安装geoip的插件(可以解析外网地址显示在地图上)

cd /opt/elasticsearch5/bin

[root@es1 bin]# ./elasticsearch-plugin install --help   #我们看到了所支持的插件
Install a plugin

The following official plugins may be installed by name:
analysis-icu
analysis-kuromoji
analysis-phonetic
analysis-smartcn
analysis-stempel
discovery-azure-classic
discovery-ec2
discovery-file
discovery-gce
ingest-attachment
ingest-geoip
ingest-user-agent
lang-javascript
lang-Python
mapper-attachments
mapper-murmur3
mapper-size
repository-azure
repository-gcs
repository-hdfs
repository-s3
store-smb
x-pack

Non-option arguments:

安装插件:

[root@es1 bin]# ./elasticsearch-plugin install ingest-geoip
-> Downloading ingest-geoip from elastic
[=================================================] 100%  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission accessDeclaredMembers
See http://docs.Oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed ingest-geoip

验证:

cd /opt/elasticsearch5/plugins
[root@es1 plugins]# ls
ingest-geoip #会看到刚刚安装的插件,需要重启es集群配置生效

ElasticSearch集群到此就完成了!

CentOS 7下ElasticSearch集群搭建案例的更多相关文章

  1. CentOS 7 下 RabbitMQ 集群搭建

    环境 10.0.0.20 node1 10.0.0.21 node2 10.0.0.22 node3 搭建(在所有节点执行) 添加EPEL源 [root@node1 ~]# rpm -Uvh http ...

  2. elasticsearch集群搭建实例

    elasticsearch集群搭建实例 下个月又开始搞搜索了,几个月没动这块还好没有落下. 晚上在自己虚拟机上搭建了一个简易搜索集群,分享一下. 操作系统环境: Red Hat 4.8.2-16 el ...

  3. Elasticsearch学习总结 (Centos7下Elasticsearch集群部署记录)

    一.  ElasticSearch简单介绍 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticse ...

  4. 和我一起打造个简单搜索之ElasticSearch集群搭建

    我们所常见的电商搜索如京东,搜索页面都会提供各种各样的筛选条件,比如品牌.尺寸.适用季节.价格区间等,同时提供排序,比如价格排序,信誉排序,销量排序等,方便了用户去找到自己心里理想的商品. 站内搜索对 ...

  5. Linux环境下Hadoop集群搭建

    Linux环境下Hadoop集群搭建 前言: 最近来到了武汉大学,在这里开始了我的研究生生涯.昨天通过学长们的耐心培训,了解了Hadoop,Hdfs,Hive,Hbase,MangoDB等等相关的知识 ...

  6. [Kubernetes]CentOS7下Etcd集群搭建

    Etcd简要介绍 Etcd是Kubernetes集群中的一个十分重要的组件,用于保存集群所有的网络配置和对象的状态信息 Etcd构建自身高可用集群主要有三种形式: ①静态发现: 预先已知 Etcd 集 ...

  7. Linux下zookeeper集群搭建

    Linux下zookeeper集群搭建 部署前准备 下载zookeeper的安装包 http://zookeeper.apache.org/releases.html 我下载的版本是zookeeper ...

  8. windows下Nacos集群搭建与nginx集成

    前言: nacos集群至少需要三个(一般为奇数个)nacos实 例,其前面顶nginx,外界入口从nginx入 一.windows下Nacos集群搭建 将Nacos的解压包复制分成3份,分别是: na ...

  9. CentOS下 elasticsearch集群安装

    1.进入root目录并下载elasticsearch cd /root wget https://download.elastic.co/elasticsearch/elasticsearch/ela ...

随机推荐

  1. Ubuntu 16.04 GNOME无法使用拼音输入法问题

    说明:添加好之后重启!不然会出现输入错乱的问题. 参考: http://forum.ubuntu.org.cn/viewtopic.php?t=477765

  2. Sqlserver数据库发送邮件

    目录 1. Sqlserver数据库发送邮件 1.1. 概念了解 1.2. 配置 1.3. 测试发送邮件 1.3.1. 代码测试 1.3.2. 工具测试 1.4. 查看邮件日志 1. Sqlserve ...

  3. How to enable Google Play App Signing

    how to enable google play app signing  ------------------------------------------------------------- ...

  4. Windows Server2008 R2 设置NAT 让Hyper-V连接Internet

    1.添加虚拟网卡,设置为内部,并且固定IP地址192.168.1.1 255.255.255.0 此为内网网卡 2.添加服务器角色:DHCP服务器,DNS服务器,网络策略和访问服务 3."网 ...

  5. A* Pathfinding Project (Unity A*寻路插件) 使用教程

    Unity4.6 兴许版本号都已经内置了寻路AI了.之前的文章有介绍 Unity3d 寻路功能 介绍及项目演示 然而两年来项目中一直使用的是 A* Pathfinding 这个插件的.所以抽时间来写下 ...

  6. Ckeditor通过Ajax更新数据

    之前在表单中对ckeditor的赋值就直接是 $("#theadEditor").val(result); 而如今我想通过点击不同选项来使用Ajax在后台訪问数据.对ckedito ...

  7. react 项目实战(七)用户编辑与删除

    添加操作列 编辑与删除功能都是针对已存在的某一个用户执行的操作,所以在用户列表中需要再加一个“操作”列来展现[编辑]与[删除]这两个按钮. 修改/src/pages/UserList.js文件,添加方 ...

  8. C# MVC 用户登录状态判断 【C#】list 去重(转载) js 日期格式转换(转载) C#日期转换(转载) Nullable<System.DateTime>日期格式转换 (转载) Asp.Net MVC中Action跳转(转载)

    C# MVC 用户登录状态判断   来源:https://www.cnblogs.com/cherryzhou/p/4978342.html 在Filters文件夹下添加一个类Authenticati ...

  9. 卷积神经网络-进化史】从LeNet到AlexNet

    目录视图 摘要视图 订阅 [置顶] [卷积神经网络-进化史]从LeNet到AlexNet 标签: cnn 卷积神经网络 深度学习 2016年05月17日 23:20:3046038人阅读 评论(4)  ...

  10. 关于MacBook怎么更新Android SDK

    昨天公司的人给了我一个VPN,可是还是无法更新SDK,后来发现将下图: 通过VPN发送全部流量勾选以后就能够连接更新了,哎.处处皆学问,特此分享一下此经验. 喜欢的朋友关注我哦! 多谢支持