linux 安装 Elasticsearch记录

1 jdk安装

安装JDK1.8版本以上,因为他是依赖JDK的,Elasticsearch也是Java开发的。

2 Elasticsearch安装

2.1 下载安装包
  • 去官网下载tar,我下的是6.3.0版本
  • tar -vxf elasticsearch-6.3.0.tar.gz
  • cd elasticsearch-6.3.0
2.2 配置修改
  • root权限下创建elsearch用户组及elsearch用户,用于启动Elasticsearch,因为root下会启动失败,依次执行下面的命令:
groupadd elsearch
useradd elsearch -g elsearch
//更改elasticsearch-6.3.0文件夹所属的用户组的权限
chown -R elsearch:elsearch elasticsearch-6.3.0
  • root权限下创建ES数据文件和日志文件,位置可以自己定,我是创建在根目录下,依次执行下列命令:
mkdir /esdata
chown -R elsearch:elsearch /esdata/
//切换用户
su elsearch
//创建data 和 logs文件夹
cd /esdata
mkdir data logs
  • 修改配置,进入elasticsearch-6.3.0下的config文件下,修改配置:
vi elasticsearch.yml

# ---------------------------------- Cluster -----------------------------------
cluster.name: name
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name:name01
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /esdata/data
#
# Path to log files:
#
path.logs: /esdata/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: false
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this


  • 执行ES文件,进入到bin 目录下执行 sh ./elasticsearch命令就可以了,执行 sh ./elasticsearch -d 是后台运行 ,关键信息如下图所示,如果没有出现started信息表示安装失败。


    image.png
  • 检测连接的正确

//输入下面的命令
curl 'http://127.0.0.1:9200'
//出现如下信息
{
  "name" : "JSJ-ES01",
  "cluster_name" : "JSJ-ES",
  "cluster_uuid" : "D0ck9KgzTBegP2Bfo222Lw",
  "version" : {
    "number" : "6.3.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "424e937",
    "build_date" : "2018-06-11T23:38:03.357887Z",
    "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"
}
2.3 常见问题
1、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

切换到root用户修改配置/etc/sysctl.conf,增加一行配置: vm.max_map_count=655360,执行命令 sysctl -p 这样就可以了,然后重新启动ES服务

你可能感兴趣的:(linux 安装 Elasticsearch记录)