一、下载Elasticsearch
1.自行从官方下载
2.解压及配置文件修改
cd /usr/local/src
rz命令,将本地Elasticsearch压缩包上传
tar -zxvf elasticsearch-6.5.0.tar.gz
mv elasticsearch-6.5.0 /usr/local/tools/
#远程访问开启:yml文件修改:
network.host:内网ip地址
http.port:9200
#重启即可
#若报bind Exception 则检查机器ip是否正确
3.添加es用户并启动
#添加用户及用户组
groupadd esgroup;
useradd esuser -g esgroup -p 123456;
[root@iz2zebdl5tab26agsgfhvwz tools]# chown -R esuser:esgroup elasticsearch-6.5.0
su esuser;
#普通启动
./bin/elasticsearch
#后台启动
./bin/elasticsearch -d
4.遇到的问题及解决方法:
1.若出现以下错误:
max file descriptions[4096] for elasticsearch process is too low...
max number of thread |3790| for user esuser is too low...
max virtual memory areas vm.max_map_count 65536 is too low...
则解决方式如下:
su root
vim /etc/security/limits.conf
esuser soft nofile 65536
esuser hard nofile 65536
esuser soft nproc 4096
esuser hard nproc 4096
vim /etc/security/limits.d/20-nproc.conf
esuser soft nproc 4096
vim /etc/sysctl.conf
vm.max_map_count=655360
执行sysctl -p生效
2.若出现启动失败显示killed:
则解决方式如下:
vim config/jvm.options
-Xms512m
-Xmx512m
3.遇到以下问题:
main ERROR Could not register mbeans java.security.AccessControlException:
access denied ("javax.management.MBeanTrustPermission" "register")
基本就是权限问题了,解决
查看文件所属用户:ll
为esyonghu设权限:chown -R esyonghu:eszu elasticsearch-6.5.0
[esuser@iz2zebdl5tab26agsgfhvwz elasticsearch-6.5.0]$ ./bin/elasticsearch
Exception in thread "main" 2021-04-25 14:55:32,274 main ERROR No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1216)
at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1189)
at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)
at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86)
Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]
at org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken(XContentParserUtils.java:78)
at org.elasticsearch.common.settings.Settings.fromXContent(Settings.java:696)
at org.elasticsearch.common.settings.Settings.access$500(Settings.java:84)
at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1212)
... 8 more
#解决
这个问题是空格引起的,
注意冒号后加空格然后是参数值,注意检查配置文件

本文详细介绍了Elasticsearch的下载、解压、配置及常见问题解决方法,包括远程访问设置、用户组创建、内存限制调整及日志配置等。
1155

被折叠的 条评论
为什么被折叠?



