Linux中es启动成功,windows服务器访问不了的解决方案

1.在Linux服务器中安装elasticsearch。在bin目录下执行

./elasticsearch

报错信息:

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:174) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.6.2.jar:7.6.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.6.2.jar:7.6.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.6.2.jar:7.6.2]
	... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
	at org.elasticsearch.cli.Command.main(Command.java:90)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /home/tools/elasticsearch-7.6.2/logs/elasticsearch.log

解决方法:

1.groupadd es

2.useradd es -g es

3.passwd es

2.在window中打卡cmd执行

telnet 远程ip地址 9200 

正在连接IP...无法打开到主机的连接。 在端口 9200: 连接失败 

3.更改 Elasticsearch 配置: vim elasticsearch/config/elasticsearch.yml

network.host: 0.0.0.0

更改配置文件/config/jvm.options  根据自己内存情况设置

-Xms128m
-Xmx128m 

更改etc/sysctl.conf 文件

vm.max_map_count=655360

生效

sysctl -p

4.执行启动es的命令,发现报以下错误

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[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
ERROR: Elasticsearch did not exit normally - check the logs at /home/es/elasticsearch-7.6.2/logs/elasticsearch.log

解决方法 es是启动 elasticsearch 的linux用户

vim /etc/security/limits.conf

es ssoft nofile 65536s
es hard nofile 65536

5.修改后启动发现又报以下的错误

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
ERROR: Elasticsearch did not exit normally - check the logs at /home/es/elasticsearch-7.6.2/logs/elasticsearch.log

解决方法:

vi elasticsearch.yml 

添加cluster.initial_master_nodes: ["node-1"]

6.在window的浏览器中输入http://ip地址:9200/ 

{
  "name" : "centos7",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "knkSw2sdQCm-BbjIkCbyKw",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

成功。

注意:在此之前需要确保你Linux的防火墙已经关闭

关闭命令:service iptables stop

查看状态:service iptables status

● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2021-09-03 15:45:56 CST; 47min ago
  Process: 5246 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)
  Process: 2812 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
 Main PID: 2812 (code=exited, status=0/SUCCESS)

Sep 03 14:07:49 centos7 systemd[1]: Starting IPv4 firewall with iptables...
Sep 03 14:07:49 centos7 iptables.init[2812]: iptables: Applying firewall rules: [  OK  ]
Sep 03 14:07:49 centos7 systemd[1]: Started IPv4 firewall with iptables.
Sep 03 15:45:56 centos7 systemd[1]: Stopping IPv4 firewall with iptables...
Sep 03 15:45:56 centos7 iptables.init[5246]: iptables: Setting chains to policy ACCEPT: nat filter [  OK  ]
Sep 03 15:45:56 centos7 iptables.init[5246]: iptables: Flushing firewall rules: [  OK  ]
Sep 03 15:45:56 centos7 systemd[1]: Stopped IPv4 firewall with iptables.

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值