es6.0安装文档

1 创建 elasticsearch 用户组

1

[root@localhost ~]# groupadd elasticsearch

2 创建用户 es 并设置密码为es

1

2

[root@localhost ~]# useradd es

[root@localhost ~]# passwd es

3 用户es 添加到 elasticsearch 用户组

1

[root@localhost ~]# usermod -G elasticsearch es

4 设置sudo权限

1

[root@localhost ~]# visudo

1

2

3

4

5

在root ALL=(ALL) ALL 一行下面

添加es用户 如下:

es ALL=(ALL) ALL

 

添加成功保存后切换到es用户操作

 

1

2

[root@localhost ~]# su es

[es@localhost root]$

  

下载安装包

/usr/local/src 目录下 下载elasticsearch ,并解压 tar.gz 

[es@localhost src]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.tar.gz

1

[es@localhost src]$ tar -xvf elasticsearch-6.3.2.tar.gz 

1

 

 

1

把解压的文件移动到 /usr/local

1

[es@localhost src]$ sudo mv elasticsearch-6.3.2 /usr/local

更改elasticsearch-6.3.2 文件夹以及内部文件的所属用户为es, 用户组组为elasticsearch-R表示逐级

1

[es@localhost local]$ sudo chown -R es:elasticsearch elasticsearch-6.3.2

 

ElasticSearch 配置

elasticsearch.yml 修改

1

[es@localhost elasticsearch-6.3.2]$ vim config/elasticsearch.yml

修改内容(没有就添加):

cluster.name: my-application

node.name: node-1

network.host: 0.0.0.0 

http.port: 9200

#因为Centos6不支持SecComp,ES默认bootstrap.system_call_filtertrue进行检测

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

修改/etc/sysctl.conf 

切换回root 用户 执行

1

vim /etc/sysctl.conf

在文件最后面添加内容:

vm.max_map_count=262144

保存退出后,使用sysctl -p 刷新生效

[root@localhost ~]# sysctl -p

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route = 0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

vm.max_map_count = 262144

[root@localhost ~]#

修改文件/etc/security/limits.conf

1

vim /etc/security/limits.conf

添加如下内容:

1

2

3

4

5

* hard nofile 65536

* soft nofile 65536

 

* soft nproc 2048

* hard nproc 4096 

启动elasticesearch 可能还会报如下错误

max number of threads [1024] for user [lish] likely too low, increase to at least [4096]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf

修改如下内容:

* soft nproc 1024

#修改为

* soft nproc 4096

 

启动 elasticsearch

完成上面配置修改后,切换到es 用户,目录切换到 elasticsearch 安装目录下执行

1

[es@localhost elasticsearch-6.3.2]$ bin/elasticsearch

在浏览器输入localhost:9200 验证是否启动成功,如果浏览器输出如下信息,代表安装启动成功

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

{

  "name" : "node-1",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "8okSnhNzRr6Xo233szO0Vg",

  "version" : {

    "number" : "6.3.2",

    "build_flavor" : "default",

    "build_type" : "tar",

    "build_hash" : "053779d",

    "build_date" : "2018-07-20T05:20:23.451332Z",

    "build_snapshot" : false,

    "lucene_version" : "7.3.1",

    "minimum_wire_compatibility_version" : "5.6.0",

    "minimum_index_compatibility_version" : "5.0.0"

  },

  "tagline" : "You Know, for Search"

}

  

elasticsearch head 插件安装和使用

wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz

tar xf node-v6.10.2-linux-x64.tar.xz

mv node-v6.10.2-linux-x64 /usr/local/node

vim /etc/profile

 配置并生效

vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
 
source /etc/profile

查看版本验证

[elsearch@imok bin]$ node -v
v6.10.2
[elsearch@imok bin]$ npm -v
3.10.10

<2>下载head插件

如果未安装git ,则先安装git工具

yum install –y git
 
git clone https://github.com/mobz/elasticsearch-head.git

<3>安装grunt

cd elasticsearch-head
npm install -g grunt --registry=https://registry.npm.taobao.org

<4>安装插件

npm install

elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:

npm install grunt --save 

<5>修改配置 elasticsearch-head下Gruntfile.js文件

修改connect配置节点

https://i-blog.csdnimg.cn/blog_migrate/517d401a7c732ca2655e65a6ede7a7b0.png

修改 _site/app.js 修改http://localhost:9200字段到本机ES端口与IP

 https://i-blog.csdnimg.cn/blog_migrate/62994722013214aa2f868e8012a4499a.png

 <6>修改 elasticsearch配置文件 

 修改elasticsearch.yml文件加入以下内容:

# 是否支持跨域
http.cors.enabled: true
 
# *表示支持所有域名
http.cors.allow-origin: "*"

https://i-blog.csdnimg.cn/blog_migrate/c72e5377f12d2ca2ed9ba2017674f7f0.png

<7>启动head插件服务(后台运行)

/elasticsearch-head/node_modules/grunt/bin/grunt server &

 https://i-blog.csdnimg.cn/blog_migrate/dd74efc932185159d95a9e553963ad98.png

<8>查看

如下图说明安装OK

https://i-blog.csdnimg.cn/blog_migrate/802b3ea2ca6a933e30db92fd2d704c3b.png

 

安装中文分词器

中文分词器的版本和elasticsearch的版本要一致。随笔中安装的是6.3.2版本

$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.2/elasticsearch-analysis-ik-6.3.2.zip

 安装OK后重启elasticsearch服务

 

安装过程遇到的问题:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决:vim /etc/security/limits.conf ,在文件末尾添加以下参数 (* 要带上)

* soft nofile 65536
 
* hard nofile 131072
 
* soft nproc 2048
 
* hard nproc 4096

ulimit -n查看进程数

 

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决:修改 /etc/sysclt.conf配置

vi /etc/sysctl.conf

添加一下配置参数

vm.max_map_count=655360

 执行命令

sysctl -p

 

 

重启elasticsearch服务即可。

 

 

如果遇见错误:PhantomJS not found on PATH

解决办法:npm install -g cnpm --registry=https://registry.npm.taobao.org

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值