elasticsearch-6.0.1安装

0. 介绍:
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎;是目前全文搜索引擎的首选。
Elastic 的底层是开源库 Lucene。但是,没法直接用 Lucene,必须自己写代码去调用它的接口。Elastic 是 Lucene 的封装,提供了 REST API 的操作接口,开箱即用。
Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
1. 环境准备:
    系统:CentOS Linux release 7.4.1708 (Core)
    Java环境:JDK1.8(若未安装,需先安装)
集群环境:
172.16.64.137 (默认master node)
172.16.64.138
172.16.64.147
2.下载elasticsearch-6.0.1:
     官网:https://www.elastic.co/downloads/elasticsearch
    下载链接:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.1.tar.gz
    解压、移动
Python
1
2

tar -zxvf elasticsearch-6.0.1.tar.gz
mv elasticsearch-6.0.1.tar.gz /usr/local/elasticsearch

3. 配置主配置文件:
vim /usr/local/elasticsearch/config/elasticsearch.yml
Python
1
2
3
4
5
6
7
8
9
10
11
12
13

cluster.name: cluster-es
node.name: es-node1
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs
network.host: 172.16.64.137
http.port: 9200
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["172.16.64.137", "172.16.64.138", "172.16.64.147"]
node.master: true
node.data: false
discovery.zen.fd.ping_timeout: 180s
discovery.zen.fd.ping_retries: 10
discovery.zen.fd.ping_interval: 30s

配置文件详解:
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

cluster.name: cluster-es
# 集群名称
node.name: es-node1
# 节点名称,其余两台为es-node2、es-node3
path.data: /usr/local/elasticsearch/data
# 数据目录
path.logs: /usr/local/elasticsearch/logs
# 日志目录
network.host: 172.16.64.137
# 本机IP
http.port: 9200
# 本机http端口
discovery.zen.minimum_master_nodes: 1
# 指定集群中的节点中有几个有master资格的节点
discovery.zen.ping.unicast.hosts: ["172.16.64.137", "172.16.64.138", "172.16.64.147"]
# 指定集群中其他节点的IP
node.master: true
# 是否为master
node.data: false
# 是否为数据节点
discovery.zen.fd.ping_timeout: 180s
# 设置集群中自动发现其它节点时ping连接超时时间
discovery.zen.fd.ping_retries: 10
# 集群中节点之间ping的次数
discovery.zen.fd.ping_interval: 30s
# 集群中节点之间ping的时间间隔

4. 配置足够内存
Python
1
2
3

vim /usr/local/elasticsearch/config/jvm.options
-Xms2g
-Xmx2g

5. 启动
ES有执行脚本的能力,因安全因素,不能在root用户下运行,强行运行会报如下错误:
org.elasticsearch.bootstrap.StartupException:
java.lang.RuntimeException: can not run elasticsearch as root
Python
1
2
3
4
5
6
7
8
9

# 创建用户
useradd ela
# 赋予ela用户所有者权限
chown -R ela:ela /usr/local/elasticsearch
su - ela
[ela@test1 ~]$/usr/local/elasticsearch/bin/elasticsearch -d  # -d参数是后台运行
# 建议按以下命令启动
[ela@test1 ~]$ nohup /usr/local/elasticsearch/bin/elasticsearch &

正常情况下,启动后,网页访问172.16.16.206:9200会有以下内容显示
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

{
  "name" : "dcV-DRJ",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "N6qGE15TQqq9-RQedQqqEw",
  "version" : {
    "number" : "6.1.1",
    "build_hash" : "bd92e7f",
    "build_date" : "2017-12-17T20:23:25.338Z",
    "build_snapshot" : false,
    "lucene_version" : "7.1.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

启动错误收集:
    错误一:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
    解决:
Python
1
2
3
4
5
6
7

vi /etc/security/limits.conf
#添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

    错误二:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    解决:最大虚拟内存太小
Python
1
2
3
4
5

vim /etc/sysctl.conf 添加一行
vm.max_map_count=655360
# 执行命令:
sysctl -p

7. head插件安装
安装head插件前,需要先安装Node.js,需要手动安装,yum安装的版本太低
    7.1安装Node.js
    官网:https://nodejs.org/en/download/
    下载链接:wget https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz
Python
1
2
3
4
5

tar node-v8.9.3.tar.gz
cd node-v8.9.3
./configure --prefix=/usr/local/node/
make # make时间较长
make install

    添加系统变量:
Python
1
2
3
4
5
6

vim /etc/profile
export NODEJS_HOME=/usr/local/node/
export PATH=$PATH:$NODEJS_HOME/bin
# 使变量生效
source /etc/profile

    验证:
Python
1
2

[root@test1 bin]# node -v
v8.9.3

在安装node的同时,会将npm模块一起安装
    7.2 安装head插件
    下载
Python
1
2

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

    安装(方法1)
Python
1
npm install

    安装(方法2)
使用cnpm安装,因为在npm安装时,因为有些依赖的问题,速度慢且容易出错中断。
Python
1
2
3
4
5

#安装国内镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 安装插件(在elasticsearch-head目录下)
cnpm install

    安装成功后,修改配置Gruntfile.js
Python
1
2
3
4
5
6
7
8
9
10
11

vi Gruntfile.js
connect: {
     server: {
         options: {
         hostname: "0.0.0.0",  #新增的一行
         port: 9100,
         base: '.',
         keepalive: true
         }
     }
}

    修改_site/app.js配置
Python
1
2
3
4

# 搜索
http://localhost:9200
# 修改为本机IP
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.138:9200";

    elasticSearch整合elasticsearch-head插件:
Python
1
2
3
4
5
6
7

# 在配置文件的最后加上运行head插件跨域访问rest接口
vim /usr/local/elasticsearch/config/elasticsearch.yml
# 添加如下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true

    重启elasticsearch
重启elasticsearch需要kill掉进程,然后再启动
    运行elasticsearch-head
Python
1
npm run start &

方法3(离线安装)
在离线情况下,需要在有网络的环境里安装好,然后将整个elasticsearch-head目录压缩拷贝过来。
   重要:head插件目录不能放在es的目录里,需要单独放(es从版本5以上不支持直接安装head)
    首先,安装grunt,将整个elasticsearch-head目录包括目录下的node_models内容一起拷贝过来
 然后,修改方法2中的两个配置文件Gruntfile.js 和_site/app.js
    最后,使用../elasticsearch-head/node_models/grunt/bin/grunt  server  & 来启动 
    正常运行elasticsearch-head会有以下结果输出:
Python
1
2
3
4
5
6
7
8
9
10
11

[root@test1 elasticsearch-head]# npm run start
> elasticsearch-head@0.0.0 start /usr/local/elasticsearch-head
> grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
(node:16304) ExperimentalWarning: The http2 module is an experimental API.
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

按照屏幕提示通过浏览器访问:http://172.16.64.137:9100/
最后:如果在服务器上安装Elasticsearch,而想在本地机器上进行开发,这时候就需要在关闭终端的时候,让Elasticsearch继续保持运行。

最简单的方法就是使用nohup。先按Ctrl + C,停止当前运行的Elasticsearch,改用下面的命令运行Elasticsearch

Python
1
nohup ./bin/elasticsearch &

附:es启动脚本

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

#!/bin/sh
#chkconfig: 2345 80 05
#description: es
export JAVA_HOME=/usr/local/jdk1.8.0_151
export JAVA_BIN=/usr/local/jdk1.8.0_151/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case $1 in
start)
    su ela<<!
    cd /usr/local/elasticsearch
    ./bin/elasticsearch -d
exit
!
    echo "es startup"
    ;;  
stop)
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
    kill -9 $es_pid
    echo "es stopup"
    ;;  
restart)
    es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
    kill -9 $es_pid
    echo "es stopup"
    su ela<<!
    cd /usr/local/elasticsearch
    ./bin/elasticsearch -d
!
    echo "es startup"
    ;;  
*)
    echo "start|stop|restart"
    ;;  
esac

根据实际情况,修改jdk目录,ela安装目录
 写进启动文件/etc/init.d/ela,给予x权限,添加到启动菜单:
    vim /etc/init.d/ela 
    chmod 755 /etc/init.d/ela
    chkconfig –add ela
    chkconfig ela on

转载于:https://www.cnblogs.com/Su-per-man/p/8625463.html

elasticsearch-6.0.1安装相关推荐

  1. 【Linux环境部署】最新版 elasticsearch + kibana(7.15.0)安装、配置、启动(多个问题处理 + kibana仪表盘使用)

    本文的安装文件是 2021.09.23 最新发布的[elasticsearch-7.15.0-linux-x86_64.tar.gz]和[kibana-7.15.0-linux-x86_64.tar. ...

  2. 在Windows上安装Elasticsearch 5.0

    在windows上安装Elasticsearch Elasticsearch可以使用.zip软件包安装在Windows上. elasticsearch-service.bat命令,它将设置Elasti ...

  3. hadoop集群安装ES(ElasticSearch 5.0.2)

    配置/etc/hosts,ntp服务,免密码登录,关闭防火墙这里不做详细说明. 安装java环境 [root@manager ~]# mkdir /usr/java [root@manager ~]# ...

  4. linux下载python的es库,Elasticsearch py客户端库安装及使用方法解析

    一.介绍 elasticsearch-py是一个官方提供的low-level的elasticsearch python客户端库.为什么说它是一个low-level的客户端库呢?因为它只是对elasti ...

  5. Elasticsearch 7.0中引入的新集群协调子系统如何使用?

    Elasticsearch之所以如此流行,其中一个原因是它可以从只有几个节点的小集群扩展到拥有数百个节点的大集群.它的核心是集群协调子系统.Elasticsearch 7提供了一个新的集群协调子系统, ...

  6. ElasticSearch 6.0.0 IK分词 Kibana 6.0.0

    ElasticSearch 6.0.0 & IK分词 & Kibana 6.0.0 1. 安装ES 6.0.0 docker run -itd -p 9200:9200 -p 9300 ...

  7. Elasticsearch 7.0 已经发布,盘他!

    Elastic{ON}北京分享了Elasticsearch7.0在Speed,Scale,Relevance等方面的很多新特性. 比快更快,有传说中的那么牛逼吗?盘他! 通过本文,你能了解到: Ela ...

  8. 启动elasticsearch命令_快速安装ElasticSearch

    现在对ES有一点了解了.索性就从头从安装到使用ES做一个详细的总结,也分享给其他人供他人学习 首先咱们要官网上去下载ES的安装包,推荐下载Linux版的,要是windos 用户可以自己安装一个虚拟机. ...

  9. kubesphere3.0的安装完整文档

    kubesphere3.0的安装文档 https://www.yuque.com/leifengyang/kubesphere/hxzk3t#SAP5W 基于kubernetes环境安装kubesph ...

  10. [翻译]ElasticSearch官方文档-安装

    本文翻译自:www.elastic.co/guide/en/el- 本文是Elasticsearch的入门文档,将会介绍ElasticSearch在不同环境下的安装. 安装 Elasticsearch ...

最新文章

  1. mysql5.6.30源码安装_Centos7.1 for MySQL5.6.30源码安装及多实例配置
  2. Exadata上的分页查询性能测试
  3. mysql 数学函数
  4. springboot entity date_「Java」 - SpringBoot amp; JPA多数据源
  5. 三包围结构的字是什么样的_四张图说清楷书结构技巧,学硬笔书法的有福了
  6. 文本转成图片(自动换行、自定义字体),图片抗锯齿优化,图片压缩优化
  7. Windows 10 输入法莫名其妙变为繁体的解决方法
  8. 2021-2027全球与中国微机械角速率传感器市场现状及未来发展趋势
  9. 新的IcedTea项目
  10. 网络跳线接续的四种方法
  11. 【刷题篇】鹅厂文化衫问题
  12. 酷比魔方iwork1x i30双系统版,重装单Ubuntu 20.04系统记录(重力传感器、触摸屏、启动菜单、声卡问题、优化充电慢)
  13. git fetch 理解
  14. error: resource style/Theme.AppCompat.Light.NoActionBar
  15. 累加器 java_Spark笔记之累加器(Accumulator)
  16. JOL:查看Java 对象布局、大小工具
  17. 基于Modbus RTU 485通信协议实现对PH、溶解氧传感器的数据采集
  18. OpenStack_Rocky版-8.安装Dashboard面板服务
  19. 治疗腰椎间盘突出特效方
  20. WiFiSpoof for Mac(wifi地址修改工具)

热门文章

  1. [na]华为acl(traffic-filter)和dhcp管理
  2. 获取打开文件的路径和文件名
  3. 计算机基础知识:什么是位、字节、字、KB、MB
  4. 多线程之间共享的资源有哪些
  5. python的print
  6. Matlab repmat函数
  7. oracle数据库升级失败,Oracle 11.2.0.1 rac 升级失败后,数据库降级方案(flashback database)...
  8. MFC程序在其他机器运行
  9. Java嵌入oracle,Java插入Oracle Spatial空间数据
  10. 多线程 调用 axis 报错_java笔记录(三、多线程)