首先到官网下载最新的5.1.2的安装包,下载地址:https://www.elastic.co/products/elasticsearch
tar -zxvf elasticsearch-5.1.2.tar.gz
注意,elasticsearch需要使用jdk8,但是由于我对Linux还跑着其他的程序,所以要在.sh启动shell脚本中指定JDK的版本
修改elasticsearch-5.1.2/bin/elasticsearch
文件,在设置java变量前添加jdk1.8:
export JAVA_HOME=/letv/soft/elk/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="/letv/soft/elk/jdk1.8.0_121/bin/java"
else
JAVA=`which java`
fi
修改配置文件
network.host: 10.104.29.13
指定IP
启动服务
./elasticsearch &
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
于是我临时提高了vm.max_map_count的大小
*此操作需要root权限
[root@localhost ~]# sysctl -w vm.max_map_count=262144
或者永久性修改
[root@localhost ~]# cat /etc/sysctl.conf | grep -v "vm.max_map_count" > /tmp/system_sysctl.conf
[root@localhost ~]# echo "vm.max_map_count=262144" >> /tmp/system_sysctl.conf
[root@localhost ~]# mv /tmp/system_sysctl.conf /etc/sysctl.conf
mv:是否覆盖"/etc/sysctl.conf"? y
[root@localhost ~]# cat /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count=262144
[root@localhost ~]# sysctl -p
vm.max_map_count = 262144
以上修改参考 centos7虚拟机安装elasticsearch5.0.x-安装篇
服务启动以后,在浏览器中访问http://10.104.29.13:9200/
结果如下:
{
name: "Dsx3Ih1",
cluster_name: "elasticsearch",
cluster_uuid: "ro0IVlJITm-Kq-8ZfPwEtQ",
version: {
number: "5.1.2",
build_hash: "c8c4c16",
build_date: "2017-01-11T20:18:39.146Z",
build_snapshot: false,
lucene_version: "6.3.0"
},
tagline: "You Know, for Search"
}
真搞不懂,elasticsearch升级以后不能一行命令安装head插件,老版本的是可以的。
安装倒也简单,只需要一下三个命令:
clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行
cd elasticsearch-head
npm install grunt --save
然后修改配置:
修改elasticsearch-head
下Gruntfile.js
文件,添加hostname
字段
connect: {
server: {
options: {
hostname: '10.104.29.13',
port: 9100,
base: '.',
keepalive: true
}
}
}
修改Elasticsearch配置文件
编辑elasticsearch-5.1.2/config/elasticsearch.yml,加入以下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
进入elasticsearch-head/node_modules/grunt/bin
目录,执行./grunt server
命令启动head插件服务。
浏览器中访问http://10.104.29.13:9100/
即可
后台启动head(head插件是个nodejs应用)服务:
nohup bin/grunt server &
参考 elasticsearch5.0及head插件安装