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 ...
随机推荐
- OpenHarmony标准系统开机时长优化
简介 万物互联时代,产品性能至关重要,而系统启动时间是系统性能的重要组成部分,因为用户必须等待系统启动完成后才能使用设备.对于经常需要进行冷启动的汽车等设备而言,较短的启动时间至关重要(没有人喜欢在等 ...
- MySQL 数据库操作指南:LIMIT,OFFSET 和 JOIN 的使用
限制结果 您可以通过使用"LIMIT"语句来限制查询返回的记录数量.以下是一个示例,获取您自己的Python服务器中"customers"表中的前5条记录: i ...
- Maven——阿里云镜像
<mirror> <id>nexus-aliyun</id> <mirrorOf>*,!jeecg,!jeecg-snapshots</mirro ...
- 重新点亮shell————什么是shell[一]
前言 这里简介一下什么是shell. 写linux和shell 系列是为了后面的docker 系列的整理,本来想直接整理k8s的,但是呢,想想docker 系列整理完了的话,那么整理k8s系列就没有那 ...
- React纯组件的使用
1. 有无必要使用纯组件 如果应用不是很大型,页面渲染效率使用纯组件与非纯组件差别不大,尽量使用组件 应用一定注意,setState时子组件依赖渲染的属性一定要传递给子组件,不然父组件setState ...
- DC-1渗透靶场实战速通版
"感谢您阅读本篇博客!如果您觉得本文对您有所帮助或启发,请不吝点赞和分享给更多的朋友.您的支持是我持续创作的动力,也欢迎留言交流,让我们一起探讨技术,共同成长!谢谢!" 文章为速通 ...
- 【力扣精选】Oracle SQL 176. 第二高的薪水
[力扣精选]Oracle SQL 176. 第二高的薪水 这道题很适合用来作为窗口函数的入门使用练习 链接如下: https://leetcode.cn/problems/second-highest ...
- 【笔记】go语言--函数式编程
[笔记]go语言--函数式编程 简单来说,go语言的函数式编程体现的是一个闭包的情况 函数式编程 VS 函数指针 函数是一等公民:参数,变量,返回值都可以是函数 高阶函数 函数->闭包 &quo ...
- EMT4J——让 Java 应用升级更轻松
简介: EMT4J 是什么?如何使用 EMT4J 工具进行 Java 应用升级? 前言 JDK 升级对于 Java 应用来说是不得不面对的事情,一方面 Java 生态系统希望 Java 应用能跟上最新 ...
- 史上最强《Java 开发手册》泰山版王者归来!
阿里妹导读:潜力修炼一年之久的<Java 开发手册(泰山版)>今天发布!此次共计新增 34 条规约,修改描述 90 处,其中错误码规则更是第一次提出完整的解决方案,大家参考错误码示例表,欢 ...