linux安装elasticsearch

首先创建个文件夹用于存放elasticsearch

bash 复制代码
 cd /opt/
 mkdir module
 cd module

根据官网提示下载 官网文档链接

bash 复制代码
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.0-x86_64.rpm
bash 复制代码
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.0-x86_64.rpm.sha512
bash 复制代码
shasum -a 512 -c elasticsearch-8.15.0-x86_64.rpm.sha512 

如果在执行 shasum -a 512 -c elasticsearch-8.15.0-x86_64.rpm.sha512 时提示未找到命令 shasum,可能是系统中没有安装 shasum 工具。

在 CentOS 或 Red Hat 系统上,可以尝试以下命令安装:我这里安装完还是不行

bash 复制代码
sudo yum install coreutils


不知道什么问题,懒得理了,换其他的命令校验

bash 复制代码
sha512sum -c elasticsearch-8.15.0-x86_64.rpm.sha512

安装

bash 复制代码
sudo rpm --install elasticsearch-8.15.0-x86_64.rpm

输出的信息中会有初始的elastic账号的密码

Elasticsearch 安装在 /usr/share/elasticsearch/

bash 复制代码
# 新增 es 用户
useradd es
# 为 es 用户设置密码
passwd es
# 创建数据文件目录
mkdir /usr/share/elasticsearch/data
# 创建证书目录
mkdir /usr/share/elasticsearch/config/certs
#切换目录
cd /usr/share/elasticsearch
# 修改文件拥有者
chown -R es:es /usr/share/elasticsearch
bash 复制代码
# 切换用户
su es
# 签发 ca 证书,过程中需按两次回车键
bin/elasticsearch-certutil ca
#提示:bin/elasticsearch-env:行78:/etc/sysconfig/elasticsearch: 权限不够

切换root目录给权限

bash 复制代码
# 用 ca 证书签发节点证书,过程中需按三次回车键
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
# 将生成的证书文件移动到 config/certs 目录中
mv elastic-stack-ca.p12 elastic-certificates.p12 config/certs

elasticsearch.yml配置文件在/etc/elasticsearch/文件夹下,备份

bash 复制代码
 cd /etc/elasticsearch/
 cp elasticsearch.yml elasticsearch.yml.copy

要将 Elasticsearch 配置为在系统启动时自动启动,请运行以下命令:

root用户运行

bash 复制代码
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

Elasticsearch 可以按如下方式启动和停止:

bash 复制代码
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

在环境变量里面设置密码:

bash 复制代码
export ELASTIC_PASSWORD="your_password"

检查 Elasticsearch 是否正在运行

9200您可以通过向端口发送 HTTPS 请求来测试 Elasticsearch 节点是否正在运行 localhost:

bash 复制代码
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 
相关推荐
松涛和鸣11 分钟前
DAY55 Getting Started with ARM and IMX6ULL
linux·服务器·网络·arm开发·数据库·html
HIT_Weston22 分钟前
101、【Ubuntu】【Hugo】搭建私人博客:元信息&翻译(二)
linux·运维·ubuntu
暮云星影36 分钟前
一、linux系统 应用开发:基本认知概念
linux·arm开发
赵民勇1 小时前
yum命令用法与技巧总结
linux·centos
小小福仔1 小时前
Linux运维基础篇(二)之用户管理
linux·运维·服务器·增删改查
haluhalu.2 小时前
[特殊字符] 深入理解Linux信号机制:信号的产生,保存和捕捉
linux·运维·服务器
JY.yuyu2 小时前
Linux磁盘管理 / 硬盘分区、创建逻辑卷
linux·运维·服务器
~黄夫人~3 小时前
Kubernetes Pod 初始化容器(InitContainer)起不来的排错思路
linux·运维·服务器
运维有小邓@3 小时前
如何在 Linux 中查看系统日志消息
linux·运维·服务器
·云扬·3 小时前
使用Prometheus+Grafana实现Elasticsearch监控的完整实践
elasticsearch·grafana·prometheus