centos7 elasticsearch-7.12.0-linux-x86_64单机安装及问题

centos7 单机版安装

安装环境
操作系统:centos7
elasticsearch版本:elasticsearch-7.12.0-linux-x86_64
JDK版本:1.8
安装
tip:安装ES前提是已经安装好Java JDK并配置好 环境变量

1、选择自己的解压目录(,将下载下来的包解压

tar -zxvf  elasticsearch-7.12.0-linux-x86_64.tar

2、配置文件修改
进入配置目录config

cd /../../elasticsearch-7.12.0/config

对文件进行修改

vim elasticsearch.yml
#
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application
# ------------------------------------ Node ------------------------------------
node.name: node-1
# ----------------------------------- Paths ------------------------------------
#注意:新建的用户一定需要具有这两个path的权限
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
# ----------------------------------- Memory -----------------------------------
# Lock the memory on startup:
bootstrap.memory_lock: false
# ---------------------------------- Network -----------------------------------
network.host: 自己服务器ip
http.port: 9200
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["自己服务器ip"]

问题

1、elasticsearch不能使用root启动问题解决,使用root启动会报错:can not run elasticsearch as root

[root@iZbp1bb2egi7w0ueys548pZ bin]# ./elasticsearch
[2021-04-08T09:50:59,387][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:134) ~[elasticsearch-7.12.0.jar:7.12.0]

原因: 为了安全不允许使用root用户启动
解决:elasticsearch之后的都不能使用添加启动参数或者修改配置文件等方法启动了,必须要创建用户

1、创建用户:elasticsearch

adduser elasticsearch

2、创建用户密码,需要输入两次

passwd elasticsearch

3、将对应的文件夹权限赋给该用户

[root@localhost config]# chown -R elasticsearch elasticsearch
[root@localhost config]# chown -R elasticsearch /data/elasticsearch

4、可能遇到其他错误

第一种错误:
		ERROR: [1] bootstrap checks failed
		max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
	解决办法:
		su 进入root
		vim /etc/sysctl.conf 
		添加参数	vm.max_map_count=262144
		参数大小 大于 262144
		修改完后执行以下命令
		sysctl -p
	
第二种错误:
		ERROR: [1] bootstrap checks failed
		[1]: max number of threads [3758] for user [es] is too low, increase to at least [4096]
	解决办法:
		切换到root用户
		  vim /etc/security/limits.conf
		 在末尾添加下面设置(参数值大于4096)
		* soft nproc 4096
		* hard nproc 4096
	
	
第三种错误:	
		ERROR: [1] bootstrap checks failed
		[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
	解决办法 
		  切换到root用户
		  vim /etc/security/limits.conf
		 在末尾添加下面设置(参数值大于65535)
	 	* soft nofile 65535 
		* hard nofile 65535

5、后台启动

sh /opt/soft/Elasticsearch/elasticsearch-7.12.0/bin/elasticsearch -d
##
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_231/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_231/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.

6、访问
浏览器打开ip:9200
安装成功
看到这个界面说明Elasticsearch搭建成功

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值