Linuxcentos安装Elasticsearch7.8单机安装 [操作系统入门]
linux上elasticSearch7.8安装配置
一、资源准
名称
地址
elasticSearch7.8
https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
es安装包
jdk11
https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
jdk安装包
jdk1.8以上都可以,本人就是jdk1.8,只是安装的时候会提示以后的版本需要jdk11
上传资源包到到自己的安装目录下。
二、安装配置
1. 解压
cd /opt/resourcestar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz
2. 修改elasticsearch.yml配置文件
vim 安装路径下的/elasticsearch-7.8.0/config/elasticsearch.yml
cluster.name: es-hld #为集群提供一个名称node.name: hld-1 #此节点名称
path.data: /opt/es/data #数据存放的地址
path.logs: /opt/es/logs #日志存放地址
network.host: 0.0.0.0 #网络绑定这样设置就好了
cluster.initial_master_nodes: ["hld-1"] #将es-node1设置为master节点
3. 修改系统进程内存限制
vim /etc/security/limits.conf
* soft nofile 65536* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/sysctl.conf
vm.max_map_count=262145 #(es需要262144,我们在基础上+1,保证它启动)
保存退出过后在执行
sysctl -p #刷新命令
4. 创建用户
由于elasticsearch不允许root用户操作,所以需要建立子用户useradd esuser #增加一个子用户
chown -R esuser:esuser /usr/local/elasticsearch-7.4.2 #赋权
su esuser #切换成子用户
#进入 es/bin命令启动
cd /usr/local/elasticsearch-7.7.0/bin
./elasticsearch -d #-d表示后台启动,不是后台启动,不加 "-d" 即可
5. 校验
http:ip:9200 如果返回json字符串则安装成功,如图:
以上的常见问题以及解决办法
1、./elasticsearch-7.6.1/bin/elasticsearch 启动报以杀死 这个问题 没有生成其他日志 只有gc的,根据gc 日志分析 分配内存问题
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.
已杀死
解决:
编辑 vi config/jvm.options 文件
找到
-Xms1g
-Xmx1g
修改成你本身机器所能承受的范围即可 如 512m
2、type [START_OBJECT] but found [VALUE_STRING]];
[[email protected] elasticsearch-7.6.1]$ ./bin/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.
Exception in thread "main" 2020-04-02 10:33:21,459 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:1097)
at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1070)
at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:83)
at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:100)
at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:91)
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)
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:617)
at org.elasticsearch.common.settings.Settings.access$400(Settings.java:82)
at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:1093)
解决:
这个是因为编辑 vi config/elasticsearch.yml 的key 和value 写错了导致, 仔细检查你所修改的地方就可以发现问题
提示,key 和value 之间除了:还有个 空格 如: key: (空格)value
3、
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts,
这里是三个问题
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: 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/elsearch/elasticsearch-7.6.1/logs/elasticsearch.log
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决
编辑文件 用root 用户
vi /etc/security/limits.conf
请将es修改为你对应的 启动 elasticsearch 用户名
es hard nofile 65536
es soft nofile 65536
重启服务器 在重新启动es即可
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts,
解决
修改
vi /conf/elasticsearch.yml
找到 默认是有注释的,把注释去掉 后保存
cluster.initial_master_nodes: ["node-1"]
重启es 即可
原文转载两篇CSDN博客,地址: https://blog.csdn.net/han949417140/article/details/107614240
https://blog.csdn.net/qq_38380025/article/details/105263797
Linux centos安装Elasticsearch7.8单机安装
以上是 Linuxcentos安装Elasticsearch7.8单机安装 [操作系统入门] 的全部内容, 来源链接: utcz.com/z/518905.html