目录
ubuntu安装 es7.6.2
安装步骤
上传至Ubuntu 服务器 这里我存放在 /usr/
解压elasticsearch-7.6.2-linux-x86_64.tar.gz
出现问题及解决方法
1.如启动时出现如下内容
2.最大虚拟内存区域 vm.max_map_count [65530] 太低警告
3.启动异常:failed to obtain node locks
4.启动后外网无法访问问题
ubuntu安装 es7.6.2
Ubuntu 18.04.4jdk (Ubuntu 18.04.4搭建开发环境之 JDK1.8安装,原先安装jdk8,后直接升级为jdk11版本,关于linux配置jdk1.8或者jdk11这里不再细说)elasticsearch-7.6.2
安装步骤
下载 ES (官网)
在visit our downloads page中找到elasticsearch7.6.2版本,点击下载即可
上传至Ubuntu 服务器 这里我存放在 /usr/ 解压elasticsearch-7.6.2-linux-x86_64.tar.gz
解压后看下目录结构
bin 存放可执行的脚本文件目录config 存放配置文件目录data 存放node数据jdk 版本自带jdklogs 存放日志目录plugins 用来扩展ES的插件目录
这样就算基本完成了,先启动(一步一步踩坑开始)
root@daryl:/usr/elasticsearch-7.6.2# ./bin/elasticsearch &
出现问题及解决方法 1.如启动时出现如下内容
java.lang.RuntimeException: can not run elasticsearch as root
解决方法:此错误,是因为ES不能直接使用 Root 用户来启动,需要创建es用户,我这里直接创建的是esroot用户。
root@VM-0-2-ubuntu:/usr/local/elasticsearch-7.6.2# adduser esrootEnter new UNIX password: ***** '输入你的密码'Retype new UNIX password:***** '再次输入你的密码'
enter 走下去,确认选 y 就 ok 了,然后再root用户下授权文件夹elasticsearch-7.6.2 权限给esroot用户。
root@daryl:/usr# chown -R esroot elasticsearch-7.6.2
再切换到这个 esroot 用户 再次运行 ./bin/elasticsearch,后台启动则在启动命令后加 &
root@daryl:/usr# su esrootesroot@daryl:/usr$ ./elasticsearch-7.6.2/bin/elasticsearch &
看到started之后,再使用curl命令查看,出现如下则为启动成功
2.最大虚拟内存区域 vm.max_map_count [65530] 太低警告
[daryl] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法:修改/etc/sysctl.conf文件,添加如下代码
vm.max_map_count=262144
退出保存后执行如下命令: sysctl -p
root@daryl:~# sysctl -pvm.max_map_count = 655360root@daryl:~#
3.启动异常:failed to obtain node locks
[ERROR][o.e.b.Bootstrap ] [daryl] Exceptionjava.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/elasticsearch-7.6.2/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?at org.elasticsearch.env.NodeEnvironment.
解决方法:这类错误网上有很多解决方案,我们这边问题的原因则是第一次启动es是用root用户启动造成的。这时,只要删除/重命名data下的node目录,再次运行ES就可以解决
4.启动后外网无法访问问题
netstat查看进程在运行状态,使用curl命令出现如下提示
esroot@daryl:/usr/elasticsearch-7.6.2$ curl 192.168.29.131:9200curl: (7) Failed to connect to 192.168.29.131 port 9200: Connection refused
解决方法:修改配置文件elasticsearch.yml,在network模块添加 network.host: 0.0.0.0
# ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):##network.host: 192.168.0.1network.host: 0.0.0.0## Set a custom port for HTTP:##http.port: 9200## For more information, consult the network module documentation.
然后在Discovery模块添加 discovery.seed_hosts: ["127.0.0.1", "[::1]"]
# --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when this node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]##discovery.seed_hosts: ["host1", "host2"]discovery.seed_hosts: ["127.0.0.1", "[::1]"]## Bootstrap the cluster using an initial set of master-eligible nodes:##cluster.initial_master_nodes: ["node-1", "node-2"]## For more information, consult the discovery and cluster formation module documentation.
如果不添加的话启动会提示需要在discovery.seed_hosts,discovery.seed_providers, cluster.initial_master_nodes中至少设置一项的异常
[ERROR][o.e.b.Bootstrap ] [daryl] node validation exception[1] bootstrap checks failed[1]: 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
配置好之后,esroot用户下启动es用浏览器访问 http://192.168.29.131:9200/,ok