Linux安装ElastSearch
Linux安装ES
准备好Linux系统,软件安装前需要对当前系统做一些优化配置
系统配置修改
一、内存优化
在
/etc/sysctl.conf添加如下内容:
- fs.file-max=655360 系统最大打开文件描述符数
- vm.max_map_count=655360 限制一个进程拥有虚拟内存区域的大小
sysctl -p生效
[root@localhost /] vi /etc/sysctl.conf
[root@localhost /] cat /etc/sysctl.conf
fs.file-max=655360
vm.max_map_count=655360
[root@localhost /] sysctl -p
fs.file-max = 655360
vm.max_map_count = 655360
二、修改最大文件打开数量
修改
/etc/security/limits.conf文件
(nofile)最大开打开文件描述符
(nproc)最大用户进程数
(memlock)最大锁定内存地址空间
[root@localhost /] vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* soft memlock unlimited
* hard memlock unlimited
三、进程数限制
修改
/etc/security/limits.d/90-nproc.conf将1024修改为65536
重新登陆
ulimit -a查看是否生效系统差异有的可能是
20-nproc.conf
[root@localhost /] vi /etc/security/limits.d/90-nproc.conf
* soft nproc 65536
root soft nproc unlimited
[root@localhost ~] ulimit -u
65536
完成以上配置需要重启服务器
reboot
ElasticSearch安装
️ 自行下载相应版本安装包安 https://www.elastic.co/cn/downloads/past-releases#elasticsearch ,装
ES之前确保已经安装了jdk环境。启动ES服务时,不能使用root账号启动,切换创建的用户
一、上传解压重命名
将ES压缩包上传到
/home/下
[root@localhost home] cd /home/
[root@localhost home] pwd
/home
[root@localhost home] ll
总用量 338228
-rw-r--r--. 1 root root 346342976 3月 15 14:47 elasticsearch-7.15.0-linux-aarch64.tar.gz
解压压缩包
[root@localhost home] tar -zxf elasticsearch-7.15.0-linux-aarch64.tar.gz
[root@localhost home]# ll
总用量 338228
drwxr-xr-x. 9 root root 155 9月 16 11:07 elasticsearch-7.15.0
-rw-r--r--. 1 root root 346342976 3月 15 14:47 elasticsearch-7.15.0-linux-aarch64.tar.gz
重命名文件夹
[root@localhost home] mv elasticsearch-7.15.0 elasticsearch
创建快照路径
[root@localhost home] mkdir -p /home/elasticsearch/snapshot/
二、创建用户并授权
> 创建`es_user` 组 创建 `es_user`用户 设置用户密码
```shell
[root@localhost home] groupadd es_user
[root@localhost home] useradd es_user -g es_user
[root@localhost home] passwd es_user
更改用户 es_user 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
```
> 将文件`elasticsearch `的拥有者设为 `es_user`
```shell
[es_user@localhost home] chown -R es_user:es_user elasticsearch
[es_user@localhost home] ll
总用量 338228
drwxr-xr-x. 9 es_user es_user 155 9月 16 11:07 elasticsearch
-rw-r--r--. 1 root root 346342976 3月 15 14:47 elasticsearch-7.15.0-linux-aarch64.tar.gz
drwx------. 2 es_user es_user 62 3月 15 15:18 es_user
```
三、修改配置文件
切换当前用户
[es_user@localhost home] su es_user
修改配置文件
vi /home/elasticsearch/config/elasticsearch.yml
# 集群名称,同一个集群其他节点名称要和主节点相同
cluster.name: my-application
# 节点名称唯一,每一个节点都需不同
node.name: node-1
# 快照备份路径
path.repo: /home/elasticsearch/snapshot/
# 数据存放路径,默认 es 根目录下 可选
#path.data: /path/to/data
# 日志存放路径,默认 es 根目录下 可选
#path.logs: /path/to/logs
# true主节点 子节点 false
node.master: true
# 绑定 IP 当前主机IP 或 0.0.0.0
network.host: 0.0.0.0
# 端口
http.port: 9200
# 集群发现,集群需要配置
#discovery.seed_hosts: ["127.0.0.1"]
# 各个节点列表,集群需要配置
cluster.initial_master_nodes: ["node-1"]
# 开启系统监控日志收集
xpack.monitoring.collection.enabled: true
# 数据保留时间默认 7天
xpack.monitoring.history.duration: 7d
xpack.ml.enabled: false
四、启动ES服务
ES根目录下的
bin目录启动es
[es_user@localhost home] cd elasticsearch/bin/
启动ES,进入ES
./bin目录下执行; -d 后台运行
[es_user@localhost bin] ./elasticsearch -d
验证是否启动成功,输出以下信息证明启动成功
[root@localhost ~] curl http://127.0.0.1:9200
{
"name" : "node-1",
"cluster_name" : "my6666",
"cluster_uuid" : "_na_",
"version" : {
"number" : "7.15.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "79d65f6e357953a5b3cbcc5e2c7c21073d89aa29",
"build_date" : "2021-09-16T03:05:29.143308416Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
ES开启SSL加密传输
在开启SSL认证之前,请确认您的ES服务器可以成功启动,以及相关环境配置都没有问题,使用
es_user用户进行操作
生成证书
进入ES安装路径下,
pwd查看当前路径,请勿使用root账号操作,切换至普通用户或es用户
[root@localhost elasticsearch] pwd
/home/elasticsearch
生成ca授权证书
[es_user@localhost elasticsearch]$ ./bin/elasticsearch-certutil ca
Please enter the desired output file [elastic-stack-ca.p12]: 回车即可
Enter password for elastic-stack-ca.p12 : 回车即可
查看当前目录会生成一个
elastic-stack-ca.p12证书文件
[es_user@localhost elasticsearch]$ ls
bin config elastic-stack-ca.p12 lib LICENSE.txt logs modules NOTICE.txt plugins README.asciidoc
基于证书生成秘钥证书
[es_user@localhost elasticsearch]$ ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
Enter password for CA (elastic-stack-ca.p12) : 回车即可
Please enter the desired output file [elastic-certificates.p12]: 回车即可
Enter password for elastic-certificates.p12 :回车即可
查看当前目录会生成一个
elastic-certificates.p12证书
[es_user@localhost elasticsearch]$ ls
bin config elastic-certificates.p12 elastic-stack-ca.p12 lib LICENSE.txt logs modules NOTICE.txt plugins README.asciidoc
根据证书文件导出一份CA公钥文件,用于后续各应用配置文件(filebeat,logstash)中引用CA公钥时使用:
[es_user@localhost elasticsearch]$ openssl pkcs12 -clcerts -nokeys -in elastic-stack-ca.p12 -out ca.pem
在当前目录的
config目录下创建一个certs目录用于存放证书文件
[es_user@localhost elasticsearch]$ mkdir -p config/certs
拷贝当前证书文件
elastic-certificates.p12到config/certs并查看是否拷贝成功
[es_user@localhost elasticsearch]$ cp elastic-certificates.p12 config/certs/
[es_user@localhost elasticsearch]$ ls config/certs/
elastic-certificates.p12
添加SSL证书
添加证书时需要先停止ES服务
通过以下命令查看ES是否启动,如果启动使
kill -9 进程pid结束进程,如下所示当前ES并未启动
[es_user@localhost elasticsearch]$ ps -ef|grep elasticsearch
es_user 9616 116449 0 14:44 pts/2 00:00:00 grep --color=auto elasticsearch
编辑
config/elasticsearch.yml配置文件
[es_user@localhost elasticsearch]$ vi config/elasticsearch.yml
在配置文件底部增加以下内容
# 开启安全验证
xpack.security.enabled: true
# 设置密码时改配置为false,设置成功将此配置设置为true,并且重启服务
xpack.security.http.ssl.enabled: false
xpack.security.http.ssl.keystore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
启动ES服务
./bin/elasticsearch前台启动,窗口关闭服务停止,./bin/elasticsearch -d后台启动
[es_user@localhost elasticsearch]$ ./bin/elasticsearch
生成账号密码
执行以下命令系统自动生成不同角色账号,在执行命令时需要等待ES完全启动成功,
elastic账号类似root账号有系统最高权限。将该账号信息配置到Javaapplication-xxx.yaml配置中,生成成功后妥善保管所有账号密码
[es_user@localhost elasticsearch]$ ./bin/elasticsearch-setup-passwords auto
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/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.
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y
Changed password for user apm_system
PASSWORD apm_system = Gy2A1L9QPNArAEFdgLSq
Changed password for user kibana_system
PASSWORD kibana_system = bvkPOKij4H0peAtGICjY
Changed password for user kibana
PASSWORD kibana = bvkPOKij4H0peAtGICjY
Changed password for user logstash_system
PASSWORD logstash_system = Cw8pWQpqQWF0pvHfmZqo
Changed password for user beats_system
PASSWORD beats_system = qIqZTl8jNDuys39zUxOF
Changed password for user remote_monitoring_user
PASSWORD remote_monitoring_user = BMg3JiXs4PauCnTNGdYW
Changed password for user elastic
PASSWORD elastic = j80MPels5jfrf9E7PM89
重启ES服务
重启之前,先停掉ES服务,修改配置文件,开启SSL认证
到此ES SSL加密结束
[es_user@localhost elasticsearch]$ vi config/elasticsearch.yml
xpack.security.http.ssl.enabled: true
[es_user@localhost elasticsearch]$ ./bin/elasticsearch

完整配置文件示例
# 集群名称
cluster.name: big_data
# 节点名称
node.name: node-1
# 主节点
node.master: true
# 绑定IP地址
network.host: 192.168.0.114
# 端口
http.port: 9200
# 集群发现
discovery.seed_hosts: ["192.168.0.114"]
# 集群主节点
cluster.initial_master_nodes: ["node-1"]
# 快照备份路径
path.repo: /home/elasticsearch/snapshot/
# 开启系统监控日志收集
xpack.monitoring.collection.enabled: true
# 数据保留时间默认 7天
xpack.monitoring.history.duration: 7d
# 关闭ES机器学习
xpack.ml.enabled: false
# 开启系统安全
xpack.security.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.http.ssl.client_authentication: "optional"
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /home/elasticsearch/config/certs/elastic-certificates.p12
Linux安装ElastSearch的更多相关文章
- 搜狗输入法linux安装 以及 12个依赖包下载链接分享
搜狗输入法linux安装版,先安装各种依赖包,大概12个依赖,可能中途还需要其他依赖,可以效仿解决依赖问题.如图这12个文件要是手动点击下载,那也太笨点了,我们要用shell命令批量下载.命令如下:w ...
- linux安装php
接上篇:linux安装apache 一.安装php 先安装libxml2库 [root@ctxsdhy package]# yum -y install libxml2-devel 最新地址在:htt ...
- linux安装oracle11g
准备oracle安装文件 Oracle11gR2包含两个文件linux_11gR2_database_1of2.zip和linux_11gR2_database_2of2.zip,将这两个文件通过SS ...
- TODO:Linux安装PHP MongoDB驱动
TODO:Linux安装PHP MongoDB驱动 PHP利于学习,使用广泛,主要适用于Web开发领域. MongoDB的主要目标是在键/值存储方式(提供了高性能和高度伸缩性)以及传统的RDBMS系统 ...
- Symantec Backup Exec 2010 Agent For Linux安装
以前写过一篇文章介绍过Symantec Backup Exec 2012 Agent For Linux安装安装,今天介绍一下Symantec Backup Exec 2010 Agent For L ...
- Symantec Backup Exec 2012 Agent For Linux安装
Backup Exec 2012 介绍 Backup Exec 2012 是一种为虚拟和物理环境提供保护的集成产品,能够简化备份和灾难恢复,并提供了无可匹敌的恢复功能.借助于强大的 Symantec ...
- linux 安装jdk
1.Linux安装JDK步骤1. 先从网上下载jdk(jdk-1_5_0_02-linux-i586.rpm) ,推荐SUN的官方网站www.sun.com,下载后放在/home目录中,当然其它地方也 ...
- Hadoop Linux安装
Hadoop Linux安装 步骤流程 1.硬件准备 2.软件准备(推荐CDH) 3.将Hadoop安装包分发到各个节点下 4.安装JDK 5.修改/etc/hosts配置文件 6.设置SSH免密码登 ...
- 自己瞎捣腾的Win7下Linux安装之路-----理论篇
接着上回说道,我把双系统做好啦,开心.... 之后我就在想几个问题: 1.在Ubuntu装好后,重启电脑却还是win7,等我用EasyBCD之后,才可选择使用装好的Ubuntu呢? 2.在用EasyB ...
- Debian 7(Linux) 安装SSH使用SecureCRT连接配置
1 Debian 安装 ssh2 首先确保你的Debian或者linux安装ssh并开启ssh服务 Debian和ubuntu的安装方法一样,只要源OK的话,可以直接安装 apt-get instal ...
随机推荐
- Python 函数:定义、调用、参数、递归和 Lambda 函数详解
函数是一段代码块,只有在调用时才会运行.您可以将数据(称为参数)传递给函数. 函数可以返回数据作为结果. 创建函数 在Python中,使用def关键字定义函数: 示例 def my_function( ...
- 开发指导—利用CSS动画实现HarmonyOS动效(一)
注:本文内容分享转载自HarmonyOS Developer官网文档 一. CSS语法参考 CSS是描述HML页面结构的样式语言.所有组件均存在系统默认样式,也可在页面CSS样式文件中对组件.页面自 ...
- Mysql之innodb架构
Innodb存储引擎的架构 内存结构 Bufer Pool 缓冲池是主内存中的一个区域,里面可以缓存磁盘上经常操作的真实数据,在执行增删改查操作时,先操作缓冲池中的数据(若缓冲池没有数据,则从磁盘加载 ...
- 深入解析decltype和decltype(auto)
decltype关键字是C++11新标准引入的关键字,它和关键字auto的功能类似,也可以自动推导出给定表达式的类型,但它和auto的语法有些不同,auto推导的表达式放在"="的 ...
- 重新点亮linux 基本软件————防火墙[一]
前言 简单介绍一下linux的防火墙. 正文 防火墙分类: 软件防火墙和硬件防火墙 包过:过滤防火墙和应用层防火墙 iptables 的表和链 规则表: filter nat mangle raw f ...
- This version of Android Studio cannot open this project, please retry with Android Studio 4.0 or newer.
前言 遇到的问题,This version of Android Studio cannot open this project, please retry with Android Studio 4 ...
- python将日志生成到文件和控制台
# 日志收集设置import logging, osfrom logging.handlers import TimedRotatingFileHandlerimport datetimecurren ...
- Python阿里云消息推送调用API
很多公司测试APP推送时候,应该也是很头疼:推送环境:测试.正式,稍不注意就把测试的push到正式上,导致所有用户都收到 例子很多: 其实阿里.极光都有推送Api,直接调用API就ok,特别是有的公司 ...
- vue截取video视频中的某一帧
在vue中如何做到给视频拍照,留住那一帧的美好呢? 且看代码 <template> <div> <video src="../assets/video.mp4& ...
- 学习 XQuery:XML数据查询的关键
XQuery 是 XML 数据的查询语言,类似于 SQL 是数据库的查询语言.它被设计用于查询 XML 数据. XQuery 示例 for $x in doc("books.xml" ...