Elasticsearch7.x指定JDK及安装时报错
环境说明
Centos7、Elasticsearch7.2、JAVA_HOME="/usr/local/src/jdk-11.0.1"(指定自己想指定的jdk位置)
前篇提要
ES安装步骤
下载Elasticsearch7.2
1、登录Elasticsearch官网下载7.2版本
*点击可以下载各个版本的es
https://www.elastic.co/cn/
之后利用工具上传到(虚拟机/服务器上)
或者直接复制我的代码
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz
[root@localhost src]# ll
total 328760
-rw-r--r--. 1 root root 336647987 Aug 2 11:39 elasticsearch-7.2.0-linux-x86_64.tar.gz
解压
[work@localhost ~]$ tar -zxvf elasticsearch-7.2.0-linux-x86_64.tar.gz
[work@localhost ~]$ cd ../
[work@localhost ~]$ ll
总用量 537304
drwxrwxrwx. 3 root root 19 10月 25 11:11 data
drwxrwxrwx. 10 work work 166 10月 25 10:59 elasticsearch-7.2.0
新建用户
es不能用root用户启动,需要自己新建用户,并赋权
(我输的密码比较简单,所以有BAD PASSWORD:这个提示,不用管它)
·························································································
1.在本地虚拟机安装时可以选择新增用户赋予权限
2.也可以以Root 用户去新建用户
## 新建用户,设置密码
[root@localhost src]# adduser work
[root@localhost src]# passwd work
Changing password for user work.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
## 授权
[root@localhost src]# chown -R work elasticsearch/
新建文件夹
等会要配置下elasticsearch.yml,这里先建立两个文件夹,数据文件夹和日志文件夹,并授权给es用户,会在es的配置文件中使用到。
[root@localhost src]# mkdir /home/work/data
[root@localhost src]# mkdir /home/work/log
[root@localhost config]# chown -R esuser /home/work/data
[root@localhost config]# chown -R esuser /home/work/log
编辑elasticsearch.yml
注释的内容就不贴出来了,只保留改动的部分.
(设置0.0.0.0可以让任何人访问到你的es)
[work@localhost config]$ pwd
/usr/local/src/elasticsearch/config
[work@localhost config]$ vi elasticsearch.yml
cluster.name: es-application
node.name: node-1
path.data: /home/work/data
path.logs: /home/work/log
network.host: 0.0.0.0
http.port: 9200
# 下面这两个是默认配置,我先保留等下会说
#discovery.seed_hosts: ["host1", "host2"]
#cluster.initial_master_nodes: ["node-1", "node-2"]
在ES用户下启动Elasticsearch
[work@localhost bin]$ pwd
/home/work/elasticsearch-7.2.0/bin
[work@localhost bin]$ sh elasticsearch
报错
ERROR: [5] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [1024] for user [es] 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]: failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[5]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2019-04-09T09:51:29,228][INFO ][o.e.n.Node ] [localhost.localdomain] stopping …
[2019-04-09T09:51:29,264][INFO ][o.e.n.Node ] [localhost.localdomain] stopped
[2019-04-09T09:51:29,265][INFO ][o.e.n.Node ] [localhost.localdomain] closing …
[2019-04-09T09:51:29,320][INFO ][o.e.n.Node ] [localhost.localdomain] closed
[2019-04-09T09:51:29,323][INFO ][o.e.x.m.p.NativeController] [localhost.localdomain] Native controller process has stopped - no new native processes can be started
切换root用户
vi /etc/security/limits.conf
在倒数第二行
* soft nofile 65536
* hard nofile 65536
# End of file
vi /etc/sysctl.conf
添加
vm.max_map_count=655360
保存后执行
sysctl -p
重启es 异常
ERROR: [3] bootstrap checks failed
[1]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[2]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
vi /etc/security/limits