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

elasticsearch-6.0.1安装的更多相关文章

  1. 在Windows上安装Elasticsearch 5.0

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

  2. Elasticsearch 5.0 安装 Search Guard 5 插件 (五)

    一.Search Guard 简介 Search Guard  是 Elasticsearch 的安全插件.它为后端系统(如LDAP或Kerberos)提供身份验证和授权,并向Elasticsearc ...

  3. ElasticSearch 5.0.0 集群安装部署文档

    1.  搭建环境 3台物理机 操作系统 centos7 es1   192.168.31.141   4g内存   2核 es2   192.168.31.142   4g内存   2核 es3    ...

  4. ElasticSearch 5.0及head插件安装

    一.elasticsearch安装配置 1.官网下载源码包 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0 ...

  5. Elasticsearch学习之ElasticSearch 5.0.0 安装部署常见错误或问题

    ElasticSearch 5.0.0 安装部署常见错误或问题 问题一: [--06T16::,][WARN ][o.e.b.JNANatives ] unable to install syscal ...

  6. elasticsearch 6.0在Ubuntu下的安装

    1:直接下载 elasticsearch 6.0  zip文件  https://www.elastic.co/downloads/past-releases 2:解压:进入到解压后的bin目录,执行 ...

  7. ElasticSearch 5学习(1)——安装Elasticsearch、Kibana和X-Pack

    安装准备: 安装Elasticsearch唯一的要求是安装官方新版的Java,包括对应的Jdk. 安装Elasticsearch 首先到官网下载最新版本的Elasticsearch压缩包. 可以使用命 ...

  8. ElasticSearch 2 (6) - 插件安装Head、Kopf与Bigdesk

    ElasticSearch 2 (6) - 插件安装Head.Kopf与Bigdesk 摘要 安装Elasticsearch插件Head.Kopf与Bigdesk 版本 elasticsearch版本 ...

  9. Elasticsearch 5.0

    Elasticsearch 5.0 使用ES的基本都会使用过head,但是版本升级到5.0后,head插件就不好使了.下面就看看如何在5.0中启动Head插件吧! 官方粗略教程 Running wit ...

  10. (新)elasticsearch6.0版本安装head插件

    ES6.0版本安装head插件 1.1 前言 不知道是我电脑问题还是最近的开源软件都比较**,mysql和elasticsearch新版本变动都比较大. elasticsearch6.0貌似已经不支持 ...

随机推荐

  1. 为什么总是弹出报错“百度未授权使用地图API”?

    今天打开网站的时候出现了这个问题“百度未授权使用地图API, 可能是因为您提供的密钥不是有效的百度开放平台密钥或此密钥未对本应用的百度地图JavasoriptAPI授权.…”经过研究终于知道什么原因了 ...

  2. spring注解开发:ComponentScan组件扫描

    在使用xml方式配置时,我们只需要在xml中配置如下代码: <context:component-scan base-package="包名"></context ...

  3. Java - 集合框架完全解析

    来自:http://www.jianshu.com/p/63e76826e852 数据结构是以某种形式将数据组织在一起的集合,它不仅存储数据,还支持访问和处理数据的操作.Java提供了几个能有效地组织 ...

  4. HDU 3571 N-dimensional Sphere( 高斯消元+ 同余 )

    N-dimensional Sphere Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  5. FZU 2060 The Sum of Sub-matrices(状态压缩DP)

    The Sum of Sub-matrices Description Seen draw a big 3*n matrix , whose entries Ai,j are all integer ...

  6. A re-introduction to JavaScript (JS Tutorial) 转载自:https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript

    A re-introduction to JavaScript (JS Tutorial) Redirected from https://developer.mozilla.org/en-US/do ...

  7. Java面试宝典(3)Java基础部分

    51.启动一个线程是用run()还是start()? . 启动一个线程是调用start()方法,使线程就绪状态,以后可以被调度为运行状态,一个线程必须关联一些具体的执行代码,run()方法是该线程所关 ...

  8. CocoaPods CDN: trunk Repo update failed

    问题 今天升级 CocoaPods 到 1.8.4 版本但是随即问题就来了, 执行 pod install 下载库时,出现错误 解决 在 Podfile 加上 source ‘https://gith ...

  9. 2019-9-2-win10-uwp-颜色转换

    title author date CreateTime categories win10 uwp 颜色转换 lindexi 2019-09-02 12:57:38 +0800 2018-2-13 1 ...

  10. ThreadLocal简单使用示例

    ThreadLocal为每个线程提供单独的数据副本,线程间的数据为自身线程所独有(不存在共享变量问题),直接看代码 public class ThreadLocalTest { private sta ...