安装单机版Elasticsearch和head

2018-08-23  本文已影响0人  龟龟51

1安装Elasticsearch6.2.4

参考https://blog.csdn.net/daerzei/article/details/79761086

1.1从官网下载Elasticsearch6.2.4

https://www.elastic.co/products/elasticsearch

1.2创建应用程序目录

mkdir -p /opt/modules/

1.3解压Elasticsearch到/opt/modules/tar -zxf elasticsearch-6.2.4.tar.gz -C /opt/modules/

1.4创建Elasticsearch用户和所在组

groupadd -g 1024 bigdatauseradd -g bigdata es

查看是否创建成功id es

1.5:更改解压的Elasticsearch应用所属用户及组# 先切换到Elasticsearch根目录

cd /opt/shortcut/elasticsearch# 

更改目录及文件权限

chown -R es:bigdata .

1.6:执行脚本添加可执行权限

chmod u+x bin/*

1.7:修改相关配置

1. 修改limits.conf配置文件(修改用户最大可创建文件数)

vim /etc/security/limits.conf# 

添加如下内容

* soft nofile 65536

* hard nofile 1048576

* soft nproc 65536

* hard nproc unlimited

* soft memlock unlimited

* hard memlock unlimited

1.8修改sysctl.conf

vim /etc/sysctl.conf 

# 尾部添加下面的配置 

vm.max_map_count=655360 # 

然后执行命令 

sysctl -p

1.9修改elasticsearch.ymlvim config/elasticsearch.yml

# 默认的只能本机访问,修改后就可以远程访问了 

network.host: 0.0.0.01.10

启动一定要再非root用户去运行/root/elasticsearch6_2_2/bin/elasticsearch

在浏览器打开

http://172.31.100.114:9200/

1.11一个关于命令的报错:

curl -XPOST 192.168.14.173:32000/test_index_1221/test_type/5 -d '{'user_name':"xiaoming"}' {"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

解决:curl -H "Content-Type: application/json" -XPOST 192.168.14.173:32000/test_index_1221/test_type/5 -d '{'user_name':"xiaoming"}

要在curl的前面加字段 -H "Content-Type: application/json",需要加一个头文件

原因:官方进行了命令的更改,详情: https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests

2.安装elasticsearch-head

nodejs是grunt的依赖,而head要借助grunt去运行,所以要先装nodejs、grunt。

2.1下载elasticsearch-head

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

2.2安装nodejs

2.2.1下载

打开官网下载链接:https://nodejs.org/en/download/ 我这里下载的是node-v8.11.2-linux-x64.tar.xz,

2.2.2解压

tar -zxvf node-v8.11.2-linux-x64.tar.xz -C /opt/moudles/

2.2.3修改配置文件

修改 /etc/profile

[root@biluos node-v8.9.4-linux-x64]# vim /etc/profile

export NODEJS_HOME=/opt/moudles/node-v8.9.4-linux-x64

export PATH=$PATH:$NODEJS_HOME/bin

测试

[root@biluos node-v8.9.4-linux-x64]# node -v             

v8.9.4

安装成功

2.3安装grunt-cli

进入elasticsearch-head目录

cd  /opt/modules/elasticsearch-head/

npm install -g grunt-cli

2.4改变用户组目录,不然会报错

chown -R es:bigdata /opt/modules/elasticsearch-head/

2.5修改_site/app.js

将高亮部分改为自己设置的es主机。

2.6安装grunt

使用es用户

npm install

这里出现一个错误:

报以下错误tar:bzip2….,是没有bzip2包,安装bzip2包

yum install -y bzip2

2.7启动grunt server

grunt server

2.8访问界面

http://172.31.100.114:9100/

上一篇下一篇

猜你喜欢

热点阅读