linux下elasticSearch安装及head安装

半兽人 发表于: 2016-12-09   最后更新时间: 2023-05-06 17:46:19  
{{totalSubscript}} 订阅, 9,220 游览

一、安装elasticsearch

前提

首先,确保jdk为jdk1.8.0_73以上,并已确保安装ok。

1、下载elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz
tar -zxvf elasticsearch-5.1.1.tar.gz

cd elasticsearch-5.1.1

2、修改limit限制(5.0以后都要修改)

> vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536

> echo 'vm.max_map_count=262144'>> /etc/sysctl.conf
> sysctl -p

> vi /etc/security/limits.d/90-nproc.conf
*          soft    nproc     2048

3、设置配置文件

> vim config/elasticsearch.yml

node.name: node-1
path.data: /tmp/elasticsearch/data
path.logs: /tmp/elasticsearch/logs
network.host: 192.168.x.x
http.port: 9200
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"

4、创建用户

# 创建elasticsearch用户
groupadd elasticsearch
useradd elasticsearch -g elasticsearch -p elasticsearch
# 赋权限
chown elasticsearch:elasticsearch -R /usr/local/elasticsearch-5.1.1

5、启动

su - elasticsearch -c "nohup /usr/local/elasticsearch-5.1.1/bin/elasticsearch >/dev/null 2>&1 &"

二、head插件的安装

浏览器访问:https://192.168.x.x:9200/

1、下载

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

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

cd elasticsearch-head
npm install grunt --save

2、修改服务器监听地址

修改elasticsearch-headGruntfile.js文件,默认监听在127.0.0.19200端口。

修改head的连接地址: 目录:head/_site/app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "https://localhost:9200";

把localhost修改成你es的服务器地址,如:

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "https://x.x.x.10:9200";

然后在head目录中,执行npm install下载依赖的包:

npm install

3、启动服务

/usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server

最后访问:https://192.168.1.1:9200

三、如果没有npm,则需安装npm

curl https://npmjs.org/install.sh | sh
sh install.sh

如果出现

npm cannot be installed without Node.js.
Install Node.js first, and then try again.

则需要 安装Node.js

yum install -y nodejs

如果node.js版本过低,则需要升级

升级node.js
# 第一步:首先安装 n 模块:
npm install -g n

# 第二步:升级node.js到最新稳定版
n stable
更新于 2023-05-06

Magic Huang 3年前

标题错了 liunx-> linux

半兽人 -> Magic Huang 3年前

thanks,已改正..

查看ElasticSearch更多相关的文章或提一个关于ElasticSearch的问题,也可以与我们一起分享文章