centos7下安装ElasticSearch-解压缩版

前言:开发中难免会遇到各种中间件的安装,本文主要介绍的是ElasticSearch的安装方式,也是自己的一个总结,避免每一次都去网上寻找各种文章,既浪费时间,又拉低了效率,喜欢的可以收藏一波。同时也会将遇见的问题以及解决方式即使的更新上来。

1、下载ElasticSearch,本文以ElasticSearch7.5.1为例

1、去官网下载:https://www.elastic.co/cn/downloads/elasticsearch(记得选择Linux版本的)
2、使用百度云:https://pan.baidu.com/s/1D7zE2HxXKJ7wCdpN4HkbSA 提取码:o0pm 

2、解压安装

1、上传至服务器(不过多介绍,可以采用filezilla、xshell都是可以的)
2、上传至指定的目录我这里是:/usr/local/
3、解压压缩包:tar -zxvf elasticsearch-7.5.1-linux-x86_64.tar.gz

在这里插入图片描述centos7下安装ElasticSearch-解压缩版_第1张图片

3、修改配置

1、修改配置文件 elasticsearch.yml
	cd /usr/local/elasticsearch-7.5.1/config/

centos7下安装ElasticSearch-解压缩版_第2张图片

2、修改集群名称
	cluster.name: power-es
3、修改当前节点名称
	node.name: power-es-node1
4、修改当前data数据和日志保存的地址
	path.data: /usr/local/elasticsearch-7.5.1/data
	path.logs: /usr/local/elasticsearch-7.5.1/logs
5、绑定es的ip
	network.host: 0.0.0.0
6、修改集群节点(之前的节点名称)
	cluster.initial_master_nodes: ["power-es-node1"]

centos7下安装ElasticSearch-解压缩版_第3张图片

7、修改JVM的参数:jvm.options
	-Xms1g
	-Xmx1g

centos7下安装ElasticSearch-解压缩版_第4张图片

4、添加操作用户: es在5之后不能使用root用户操作,需要单独添加其他的用户

useradd es
chown -R es:es /usr/local/elasticsearch-7.5.1 (赋权)
su es

5、启动项目

1、 前台启动:./elasticsearch
2、 后台启动:./elasticsearch -d

6、设置ES用户名和密码(可选)

1、在ES的根目录生成CA证书
	bin/elasticsearch-certutil ca
		中间需要设置密码,直接回车可以不设置(慎重考虑)。
2、使用第一步生成的证书,产生p12密钥
	bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
3、在config目录创建certs目录
4、拷贝(或移动)p12文件至certs目录
5、修改配置文件
	cd /usr/local/elasticsearch-7.5.1/config/
	添加如下配置:
	xpack.security.enabled: true
	xpack.license.self_generated.type: basic
	xpack.security.transport.ssl.enabled: true
	xpack.security.transport.ssl.verification_mode: 	certificate
	xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
	xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

centos7下安装ElasticSearch-解压缩版_第5张图片
centos7下安装ElasticSearch-解压缩版_第6张图片
centos7下安装ElasticSearch-解压缩版_第7张图片

6、进入到elasticsearch-7.9.2/bin
	执行如下命令
	elasticsearch-setup-passwords interactive
执行之后,会对如下几个账号进行密码设置elastic, kibana, logstash_system,beats_system
7、修改密码时,将第一步配置删除,然后重启es,将.security-7的索引删除即可。然后重新1-4步骤。

7、常见问题及解决方式

7.1.1max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
7.1.2max number of threads [3795] for user [esuser] is too low, increase to at least [4096]
7.1.3max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方式:
7.1.17.1.2需要切换至root用户修改/etc/security/limits.conf,增加如下配置,再切换es用户重启服务。
	* soft nofile 65536
	* hard nofile 131072
	* soft nproc 2048
	* hard nproc 4096
7.1.3需要切换至root用户修改/etc/sysctl.conf,增加如下配置,然后执行 sysctl -p 刷新,再切换es用户重启服务。
	vm.max_map_count=262145
也可以:
	执行命令: 
	sysctl -w vm.max_map_count=262144 
	查看结果: sysctl -a|grep vm.max_map_count 
	显示: vm.max_map_count = 262144

你可能感兴趣的:(服务器的环境安装,elasticsearch,大数据,搜索引擎)