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 
相关推荐
崔小汤呀2 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端
何中应2 天前
vi编辑器使用
linux·后端·操作系统
何中应2 天前
Linux进程无法被kill
linux·后端·操作系统
何中应2 天前
rm-rf /命令操作介绍
linux·后端·操作系统
何中应2 天前
Linux常用命令
linux·操作系统
葛立国2 天前
从 / 和 /dev 说起:Linux 文件系统与挂载点一文理清
linux
哇哈哈20212 天前
信号量和信号
linux·c++
不是二师兄的八戒2 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
一个人旅程~2 天前
如何用命令行把win10/win11设置为长期暂停更新?
linux·windows·经验分享·电脑
2302_799525742 天前
PCI、PCIe 和 NVLink
linux