irpas技术客

Linux中es启动成功,windows服务器访问不了的解决方案_码代码的小仙女_es启动后在浏览器访问不了

大大的周 1536

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.


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #es启动后在浏览器访问不了 #can #not #run #ElasticSearch