安装elasticsearch踩过的坑,教训写在这里,一起共同努力,希望大家先通读一下再按着步骤操作,看过就知道哪些坑可以掠过

安装elasticsearch踩过的坑,教训写在这里,一起共同努力,希望大家先通读一下再按着步骤操作,看过就知道哪些坑可以掠过

配置外网访问出现启动不了的问题:

Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

[2019-09-06T09:27:10,924][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [hadoop111] 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.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.3.1.jar:7.3.1]

        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.3.1.jar:7.3.1]

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.3.1.jar:7.3.1]

        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.3.1.jar:7.3.1]

这个说是elasticsearch不能用root用户启动

说以需要创建一个其他用户

adduser   test

passwd    test

输入明码

重新输入密码

这样就创建好其他用户了,但是如果你用其他的ssh软件去登录服务器可能会报如下错误

The server has disconnected with an error. Server message reads:

A protocol error occurred. Change of username or service not allowed: (root,ssh-connection) -> (user,ssh-connection) 

这个是因为你用了一个已经创建好的链接,这个链接写的用户是其他用户,我开始用的是root用户,而且只接受一次验证,所以

再次链接的时候可以重新的输入用户名和密码,所以就报出了这样错误,所以你需要重新创建一个链接,不需要把以前的链接删除掉

现在我就可以使用其他用户登录了

在这个之前我们在elasticsearch-evn中也配置了jdk的路径,因为我是最新下载的elasticsearch,所以需要jdk11的支持,而我的

Linux中是jdk1.8的所以不支持,怎么在elasticsearch-evn中配置jdk11自行百度一下

然后需要配置一个elasticsearch的环境变量,我们配置在用户的环境变量中,使用~/.bash_profile文件进行配置

配置好后我们再次启动发现还是不行,报错误

Exception in thread "main" java.nio.file.AccessDeniedException: /usr/developing/elasticsearch/elasticsearch-7.3.1/config/jvm.options

        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)

        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)

        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)

        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)

        at java.base/java.nio.file.Files.newByteChannel(Files.java:373)

        at java.base/java.nio.file.Files.newByteChannel(Files.java:424)

        at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)

        at java.base/java.nio.file.Files.newInputStream(Files.java:158)

        at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:61)

经网上查询说我没对这个文件没有操作权限,所以报了一个访问拒绝的异常,然后我用我的test用户

去修改它的权限发现我的test用户没有修改这个文件的权限

那没办法,只好使用我的root用户修改权限了,修改权限后继续启动,还是有部分文件权限不足,

那没办法继续改

还是同样的道理,那么这次我们直接config文件的权限都改了

但是还是一顿的报错,真实无语,最后查找网上相关教程,只要使用root用户把elasticsearch文件权限赋给test用户就可以了,本身是一小步

操作,整了这么多没有的权限修改,实际只需要执行下面的就可以了

在启动完成之后会在cd elasticsearch-7.3.1/文件夹下自动的生成一个data目录,

然后在Linux中使用curl访问一下这样就正常了,但是在浏览器中不能访问,看到需要配置一个

启动后,如果只有本地可以访问,尝试修改配置文件 elasticsearch.yml

中network.host(注意配置文件格式不是以#开头的要空一格, 后要空一格) 为network.host: 0.0.0.0

如果想在后台以守护进程模式运行,添加-d参数。

注意的是要开头空一格 :后要空一格

但是即使注意了这些,启动后怎么也启动不了报错

[2019-09-06T10:58:35,577][INFO ][o.e.p.PluginsService ] [hadoop111] no plugins loaded

[2019-09-06T10:58:49,613][INFO ][o.e.x.s.a.s.FileRolesStore] [hadoop111] parsed [0] roles from file [/usr/developing/elasticsearch/elasticsearch-7.3.1/config/roles.yml]

[2019-09-06T10:58:51,850][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [hadoop111] [controller/108780] [Main.cc@110] controller (64 bit): Version 7.3.1 (Build 1d93901e09ef43) Copyright (c) 2019 Elasticsearch BV

[2019-09-06T10:58:52,921][DEBUG][o.e.a.ActionModule ] [hadoop111] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security

[2019-09-06T10:58:53,650][INFO ][o.e.d.DiscoveryModule ] [hadoop111] using discovery type [zen] and seed hosts providers [settings]

[2019-09-06T10:58:56,251][INFO ][o.e.n.Node ] [hadoop111] initialized

[2019-09-06T10:58:56,251][INFO ][o.e.n.Node ] [hadoop111] starting ...

[2019-09-06T10:58:56,561][INFO ][o.e.t.TransportService ] [hadoop111] publish_address {192.168.1.129:9300}, bound_addresses {[::]:9300}

[2019-09-06T10:58:56,569][INFO ][o.e.b.BootstrapChecks ] [hadoop111] bound or publishing to a non-loopback address, enforcing bootstrap checks

ERROR: [4] bootstrap checks failed

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

[2]: max number of threads [3764] for user [test] 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]: 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-09-06T10:58:56,987][INFO ][o.e.n.Node ] [hadoop111] stopping ...

[2019-09-06T10:58:57,014][INFO ][o.e.n.Node ] [hadoop111] stopped

[2019-09-06T10:58:57,015][INFO ][o.e.n.Node ] [hadoop111] closing ...

[2019-09-06T10:58:57,049][INFO ][o.e.n.Node ] [hadoop111] closed

[2019-09-06T10:58:57,057][INFO ][o.e.x.m.p.NativeController] [hadoop111] Native controller process has stopped - no new native processes can be started

终于好了,在网上转了好几圈,翻看了好多贴子,终于有整完了。

其实在好多贴子都写了,也能解决问题,但是有的关键的地方没有写到,所以你其实配正确了,但是最后启动还是启动不了

下面我就给大家分析一下怎么解决,总共是4个报错,先看一下这几个报错:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

这个说应用打开一个文件的描述量(我觉的就是一个文件的大小),Linux中默认的访问量是4096,但是elasticsearch进程需要至少是65535

[2]: max number of threads [3764] for user [test] is too low, increase to at least [4096]

目前Linux对于test这个用户中最多线程(但是在配置文件中写的是process进程数量)数量是3764,需要增加打4096

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

虚拟的内存范围是65530太低,需要增加到至少262144

[4]: 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

默认的discovery设置不适合生产使用,在discovery.seec_hosts,discovery.seed_providers,cluter.inital_master_nodes中的至少一个需要设置一下

那么我就按着这几个问题解决一下,在许多贴子其实都有描述(配置文件的时候使用root用户):

vim /etc/security/limits.conf

修改这个配置文件:

这个就把第一和第二错误解决了,不要着急的再启动你的elasticsearch,接着解决第三个错误

[3]: 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

这个配置文件配置完了,需要是这个配置文件生效一下,但是上边第一个错误和第二错误配置不需要生效

但是需要重新链接一下ssh(但也不需要着急的启动elasticsearch),不然的话第一个错误和第二错误还是会出错的。

还有一个elasticsearch的配置文件需要配置一下解决第4个错误:

在elasticsearch的目录中的config/elasticsearch.yml

cluster.initial_master_nodes: ["node-1"] 

这个配置完毕之后,重新用ssh链接一下服务器再启动就大功告成了,也可以用其他服务器访问该服务搜索引擎了

可以访问:http://192.168.1.129:9200/    也可以访问:http://192.168.1.129:9200/?pretty,如果出现下面的提示就说明成功了

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

枣泥馅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值