centos7下部署elasticsearch常见错误


一、Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected settings to start with 'object', instead was [VALUE_STRING]];

原因:elasticsearch.yml文件错误
解决:参数与参数值等号间需要空格
node.name ="node"  ##错误
node.name = "node" ##正确


二、org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

详细错误:

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads a
[2018-06-20T02:19:58,978][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] 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:140) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.3.0.jar:6.3.0]
	... 6 more
原因:处于对root用户的安全保护,需要使用其他用户组进行授权启动
解决:
step1:用户组进行授权启动
groupadd elsearch           
useradd elsearch -g elsearch -p elasticsearch
chown -R elsearch:elsearch  elasticsearch-6.3.0
备注: 添加用户组 elsearch  
      添加用户 elsearch 密码为 elasticsearch 到用户组 elsearch
      将elsearch安装目录授权给 用户组:用户  即 elsearch:elsearch
step2: 重新启动
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch
备注:切换 elsearch 用户
      重新启动


三、OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot a ...'(errno=12);

原因:jvm要分配最大内存超出系统内存

解决:
step1:适当调整指定jvm内存
vi /home/elasticsearch-6.3.0/config/jvm.options 
备注:编辑elasticsearch jvm配置文件 修改如下 esc+:wq保存退出
## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms512m
-Xmx512m
备注:由于虚拟机内存制定1g,所以适当降低jvm内存指定
step2:重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch

四、ERROR: [3] bootstrap checks failed

详细错误:

[2018-06-20T02:35:47,152][INFO ][o.e.b.BootstrapChecks    ] [SUcoFrg] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] 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]
[2018-06-20T02:35:47,170][INFO ][o.e.n.Node               ] [SUcoFrg] stopping ...
[2018-06-20T02:35:47,316][INFO ][o.e.n.Node               ] [SUcoFrg] stopped
[2018-06-20T02:35:47,316][INFO ][o.e.n.Node               ] [SUcoFrg] closing ...
[2018-06-20T02:35:47,336][INFO ][o.e.n.Node               ] [SUcoFrg] closed
原因:虚拟机限制用户的执行内存
解决:

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

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

step1:修改安全限制配置文件
su root 
vi /etc/security/limits.conf
备注:使用最高权限 修改安全配置 在文件末尾加入
# End of file
elsearch       hard        nofile        65536 
elsearch       soft        nofile        65536
*               soft       nproc         4096
*               hard       nproc         4096 
备注: elsearch为用户名 可以是使用*进行通配  
nofile 最大打开文件数目
nproc 最大打开线程数目

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

step2:修改系统配置文件
vi /etc/sysctl.conf 
备注:行末加上vm.max_map_count = 655360 ,esc +:wq保存退出
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count = 655360
备注:vm.max_map_count = 655360 值大于错误提示值
step3:重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch


五、org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

详细报错:
[2018-06-20T04:23:25,003][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] 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.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.0.jar:6.3.0]
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] 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.<init>(NodeEnvironment.java:243) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.node.Node.<init>(Node.java:270) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.3.0.jar:6.3.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.3.0.jar:6.3.0]
	... 6 more
原因:线程占用
解决:重新启动
step1:杀死elasticsearch线程
ps -ef | grep elastic

kill -9 2002

step2: 重启
su elsearch
/elasticsearch-6.3.0/bin/elasticsearch


六、验证

1、后台启动
 /home/elasticsearch-6.3.0/bin/elasticsearch -d

2、curl验证
curl http://zk01:9200

3、网站验证

  • 9
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
要在CentOS 7上部署Elasticsearch 7.10,可以按照以下步骤进行操作: 1. 下载Elasticsearch安装包。可以从Elasticsearch官方网站的下载页面\[1\]中获取安装包的下载链接。 2. 创建Elasticsearch的数据存储目录。可以使用以下命令创建一个目录来存储Elasticsearch的数据: ``` mkdir /path/to/data ``` 3. 创建一个新的用户来运行Elasticsearch。可以使用以下命令创建一个新用户: ``` useradd elasticsearch ``` 4. 配置新用户的打开文件数。为了确保Elasticsearch能够正常运行,需要增加新用户的打开文件数限制。可以编辑`/etc/security/limits.conf`文件,并添加以下行: ``` elasticsearch soft nofile 65536 elasticsearch hard nofile 65536 ``` 5. 解压安装包。使用以下命令解压下载的Elasticsearch安装包: ``` tar -zxvf elasticsearch-7.10.2.tar.gz ``` 6. 更改解压后的目录所属组。使用以下命令将解压后的目录的所属组更改为新创建的用户组: ``` chown -R elasticsearch:elasticsearch /path/to/elasticsearch ``` 7. 修改Elasticsearch的配置文件。编辑`/path/to/elasticsearch/config/elasticsearch.yml`文件,并根据需要进行配置更改。至少需要设置以下参数: ``` cluster.name: my-cluster node.name: my-node path.data: /path/to/data ``` 8. 修改内存配置。编辑`/path/to/elasticsearch/config/jvm.options`文件,并根据需要调整Elasticsearch的内存配置。 9. 切换到新创建的用户。使用以下命令切换到新创建的用户: ``` su - elasticsearch ``` 10. 导入Java 11环境变量。确保Java 11已经安装,并将其添加到新用户的环境变量中。 11. 启动Elasticsearch服务。使用以下命令启动Elasticsearch服务: ``` systemctl start elasticsearch.service ``` 12. 检查Elasticsearch服务状态。使用以下命令检查Elasticsearch服务的运行状态: ``` systemctl status elasticsearch.service ``` 以上是在CentOS 7上部署Elasticsearch 7.10的详细步骤。具体的安装和配置过程可能会因环境和需求而有所不同,建议参考Elasticsearch官方文档\[2\]进行操作。 \[1\]: https://artifacts.elastic.co/downloads/ \[2\]: Elasticsearch系列之:Centos7安装部署Elasticsearch详细步骤 #### 引用[.reference_title] - *1* *3* [Centos7搭建部署Elasticsearch7.10.2集群(rpm安装)](https://blog.csdn.net/xjjj064/article/details/113348492)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Elasticsearch系列之:Centos7安装部署Elasticsearch详细步骤](https://blog.csdn.net/zhengzaifeidelushang/article/details/128076955)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Mars'Ares

请我喝杯咖啡吧

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

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

打赏作者

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

抵扣说明:

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

余额充值