Elasticsearch安装与测试

1,下载安装包,配置jdk环境

这一步,比较简单,就不多赘言啦。不清楚的地方,可以百度下。

jdk-8u101-linux-x64.tar.gz
tar -zxvf jdk-8u101-linux-x64.tar.gz
vi ~/.profile
PATH="/home/xxx/es/jdk1.8.0_101/bin:$PATH"
source ~/.profile

2,安装node

打开官网,下载node
https://nodejs.org/en/download/

如下图所示,下载linux binaries(X86/X64),64bit
node-v6.11.0-linux-x64.tar.xz
nodejs下载页面

下载完毕后,配置nodejs环境:

xz -d node*.tar.xz
tar -xvf node*.tar

vi ~/.profile
export NODE_HOME=/home/xxx/es/node-v6.11.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
source ~/.profile

测试nodejs是否OK:

$ echo $NODE_HOME
/home/xxx/es/node-v6.11.0-linux-x64
$ node -v
v6.11.0
$ npm -v
3.10.10

3,安装head

在es目录下执行git安装和head下载:

apt-get install git
git clone git://github.com/mobz/elasticsearch-head.git

到elasticsearch-head目录下,运行命令:

npm install
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org
npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org
npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org
npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org
npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org
npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org
npm install grunt-cli --registry=https://registry.npm.taobao.org

$ ./node_modules/grunt/bin/grunt -version
grunt-cli v1.2.0
grunt v1.0.1

4,修改head代码

由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此,需要修改两个地方:

修改服务器监听地址,增加hostname属性,设置为*

vi Gruntfile.js
connect: { server: { options: { port: 9100, hostname: '*', base: '.', keepalive: true } } }

修改连接地址

目录:vi _site/app.js
修改head的连接地址:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
把localhost修改成你es的服务器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.32:9200";

5,启动测试

如下图所示,下载elasticsearch,https://www.elastic.co/downloads/elasticsearch
elasticsearch-5.4.1.zip
这里写图片描述

解压es,并修改配置文件

vi ./config/elasticsearch.yml

cluster.name: xxxApplication1
node.name: node-orange
network.host: 192.168.1.32
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["192.168.1.89"]
node.master: true
node.data: true
action.auto_create_index: true

启动测试,先启动es,然后在启动head插件

$ ./elasticsearch-5.4.1/bin/elasticsearch -d
$ ./elasticsearch-head/node_modules/grunt/bin/grunt server

报错处理
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
查看当前系统最大文件描述符
ulimit -a
1024

切换到root下,增加配置,修改系统的最大文件描述符
sudo su root
vi /etc/security/limits.conf
* soft nofile 204800
* hard nofile 204800
ulimit -HSn 204800

重启elasticsearch,查看./elasticsearch-5.4.1/logs是否有报错,没有则正常

$ ps -ef | grep elasticsearch | grep -v grep |awk '{print$2}' | xargs kill -9
$ ./elasticsearch-5.4.1/bin/elasticsearch -d
$ ./elasticsearch-head/node_modules/grunt/bin/grunt server

通过浏览器访问head:
这里写图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值