启动报错

错误信息-1

[2019-05-31T16:07:34,461][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [qvbilam_small_video_3] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.1.0.jar:7.1.0]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.1.0.jar:7.1.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:102) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:169) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.1.0.jar:7.1.0]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.0.jar:7.1.0]
    ... 6 more

解决方案

# 创建用户组
groupadd esearch
# 创建用户
useradd esearch -g esearch -p esearch
# 授权访问目录
chown -R esearch:esearch /data/softpackage/elasticsearch-7.1.0/ 
# 授予root权限
chmod 777 /etc/sudoers
vi /etc/sudoers
#添加es 用户 root 权限(切换不用输密码)
esearch     ALL=(ALL)       NOPASSWD:ALL 

错误信息-2

2019-05-22T18:21:54,754][INFO ][o.e.b.BootstrapChecks    ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: 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

解决方案

# 切换到root用户
su root
# 执行命令
sysctl -w vm.max_map_count=262144
# 查看结命令
sysctl -a|grep vm.max_map_count
# 显示结果
vm.max_map_count = 262144
#上述方法修改之后,如果重启虚拟机将失效.永久方法
vim /etc/sysctl.conf
添加
vm.max_map_count=262144

错误信息-3

[2019-05-22T03:29:49,479][INFO ][o.e.b.BootstrapChecks    ] [erhuadamowangdeMacBook-Pro.local] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [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

解决方案

# 因为配置分布式没有设置主服务的地址
# 修改配置
vim config/elasticsearch.yml
# 添加
discovery.zen.ping.unicast.hosts: ['172.20.10.6']

分布式错误

错误信息-1

[2019-05-31T15:32:05,455][WARN ][o.e.c.c.ClusterFormationFailureHelper] [qvbilam_small_video_2] master not discovered yet: have discovered []; discovery will continue using [192.168.0.105:9300] from hosts providers and [{qvbilam_small_video_2}{xyZyhu5oQ_uGz4232FlBwg}{50Hk52eaTx6QO_WVHtbvWQ}{192.168.128.125}{192.168.128.125:9300}{xpack.installed=true}, {qvbilam_small_video_1}{bQqIR5LwTCuXoqwr2qz2bg}{z_MGg5UQTguio2JFcqb9ig}{192.168.0.105}{192.168.0.105:9300}{xpack.installed=true}] from last-known cluster state; node term 7, last-accepted version 48 in term 7
Caused by: java.net.ConnectException: 连接超时
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:?]
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[?:?]
    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327) ~[?:?]
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) ~[?:?]
    ... 6 more

场景描述

  在之前搭建ES分布式是成功的.但是服务器,和服务都没有重启.为什么会突然连接不上呢?

错误猜想

  之前一直都是蹭的别人家的wife,今天小区断网.连的自己的热点.和这个有关系吗...目前就这一个想法,先排查试试。不行的话就溜了溜了

错误解决

在随意一台Servant查看信息

curl 127.0.0.1:8101/_cat/nodes?pretty

显示结果

{
  "error" : {
    "root_cause" : [
      {
        "type" : "master_not_discovered_exception",
        "reason" : null
      }
    ],
    "type" : "master_not_discovered_exception",
    "reason" : null
  },
  "status" : 503
}

就是tcp链接不到鸭.查看Master端口

lsof -i:9300

显示结果

COMMAND   PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    79719 qvbilam  249u  IPv6 0x655a2f33609dc31b      0t0  TCP *:vrace (LISTEN)
java    79719 qvbilam  322u  IPv6 0x655a2f33576fbd5b      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55720 (ESTABLISHED)
java    79719 qvbilam  324u  IPv6 0x655a2f33576fc8db      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55721 (ESTABLISHED)
java    79719 qvbilam  325u  IPv6 0x655a2f33576feb5b      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55722 (ESTABLISHED)
java    79719 qvbilam  326u  IPv6 0x655a2f33576fce9b      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55723 (ESTABLISHED)
java    79719 qvbilam  327u  IPv6 0x655a2f33576fe59b      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55724 (ESTABLISHED)
java    79719 qvbilam  328u  IPv6 0x655a2f33576fdfdb      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55725 (ESTABLISHED)
java    79719 qvbilam  329u  IPv6 0x655a2f3344cba11b      0t0  TCP 192.168.0.105:vrace->192.168.0.105:55726 (ESTABLISHED)

奇怪了呀端口是监听状态啊.和Servant链接的IP地址也相同.查看本机IP
2019-05-31T08:34:58.png
o!果然是IP地址变的问题啊

# 关闭ES服务
# 查看端口
lsof -i:8101
# 显示为空.重启ES服务
./bin/elasticsearch
# 查看端口
lsof -i:9300
#显示
COMMAND  PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    4577 qvbilam  249u  IPv6 0x655a2f3370e3dd5b      0t0  TCP *:vrace (LISTEN)
java    4577 qvbilam  250u  IPv6 0x655a2f33576fc31b      0t0  TCP 172.20.10.6:vrace->172.20.10.6:51548 (ESTABLISHED)
java    4577 qvbilam  251u  IPv6 0x655a2f33576fda1b      0t0  TCP 172.20.10.6:vrace->172.20.10.6:51549 (ESTABLISHED)

然后修改Servant配置的Master地址重启就好啦

Last modification:February 18th, 2020 at 10:28 pm