Elasticsearch单节点安装部署

1.单节点安装

(1)先前条件:

  • 安装java8
  • 下载es安装包

(2)上传到linux:/opt/software
(3)解压

cd /opt/software

tar -zxvf elasticsearch-5.6.2.tar.gz -C /opt/module

(4)新建data,logs文件夹

cd /opt/module/elasticsearch-5.6.2

mkdir data

mkdir logs
image.png

(4)修改配置文件(root用户)

a.修改elasticsearch.yml文件

vi /opt/module/elasticsearch-5.6.2/conf/elasticsearch.yml

修改内容如下:

# ---------------------------------- Cluster -------------------------------------
cluster.name: my-application
# ------------------------------------ Node --------------------------------------
node.name: JBS
# ----------------------------------- Paths ---------------------------------------
path.data: /opt/module/elasticsearch-5.6.1/data
path.logs: /opt/module/elasticsearch-5.6.1/logs
# ----------------------------------- Memory -----------------------------------
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# ---------------------------------- Network ------------------------------------
network.host: 192.168.127.121 
# --------------------------------- Discovery ------------------------------------
discovery.zen.ping.unicast.hosts: ["bigdata121"]
elasticsearch.yml

说明:

  • cluster.name :如果要配置集群需要两个节点上的 elasticsearch 配置的 cluster.name 相同,都启动可以自动组成集群,这里如果不改 cluster.name 则默认是 cluster.name=my-application。
  • nodename 随意取但是集群内的各节点不能相同

b.修改limits.conf文件

vi /etc/security/limits.conf

//在文件末尾添加如下内容

* soft nofile 655360
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
image.png

c.修改limits.d文件

vi /etc/security/limits.d/20-nproc.conf

//修改内容如下
*    soft    nproc    1024
//改为
*    soft    nproc    4096
image.png

d.修改配置sysctl.conf

vi /etc/sysctl.conf

//添加内容
vm.max_map_count=655360
sysctl.conf

(5)新建linux用户:es不能以root用户启动

useradd kai

passwd kai
输入密码

cd /opt/module/elasticsearch-5.6.2       //进入的elasticsearch目录

chown -R kai:users *      //修改权限

su kai        //切换到kai用户,启动es
新建用户

(6)重启linux,因为修改linux配置文件后需要重启后才生效

2.启动:
su kai      //切换到kai用户
cd /opt/module/elasticsearch-5.6.2

bin/elasticsearch       //启动
image.png

注意:can not run elasticsearch as root

3.验证:
curl 'http://192.168.127.121:9200'

curl -XGET '192.168.127.121:9200/_cat/health?v&pretty'

验证

当看到status是green时,证明启动成功

  • Green - 一切运行正常(集群功能齐全)
  • Yellow - 所有数据是可以获取的,但是一些复制品还没有被分配(集群功能齐全)
  • Red - 一些数据因为一些原因获取不到(集群部分功能不可用)
4.当启动es,报错:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

[2]: max number of threads [1024] for user [hduser] is too low, increase to at least [4096]

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[4]: system call filters failed to install; check the logs and fix your configuration or disable system 

(1)配置linux系统环境:
(2)切换到 root 用户,编辑 limits.conf 添加类似如下内容

vi /etc/security/limits.conf

新增内容如下:

* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096

(3)进入 limits.d 目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf

把 * soft nproc 1024 改成4096
(4)修改配置 sysctl.conf

vi /etc/sysctl.conf 

添加内容如下:

vm.max_map_count=655360

执行命令:

sysctl -p

(5)重新登录kai用户,重新启动es,如果还有报错,则需重启虚拟机

  • 查看集群状态命令:
curl -XGET 'http://192.168.127.121:9200/_cat/health?v&pretty'
  • 查看所有数据命令:
curl -XGET 'ip地址:9200/index名称/_search?pretty' -H 'Content-Type: application/json' -d'

{

  "query": { "match_all": {} }

}'

你可能感兴趣的:(Elasticsearch单节点安装部署)