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 
相关推荐
秃头菜狗15 分钟前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
2301_7931024921 分钟前
Linux——MySql数据库
linux·数据库
jiunian_cn2 小时前
【Linux】centos软件安装
linux·运维·centos
程序员JerrySUN2 小时前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
孤寂大仙v2 小时前
【计算机网络】非阻塞IO——select实现多路转接
linux·计算机网络
派阿喵搞电子2 小时前
Ubuntu下有关UDP网络通信的指令
linux·服务器·网络
Evan_ZGYF丶2 小时前
【PCIe总线】 -- PCI、PCIe相关实现
linux·嵌入式·pcie·pci
舰长1153 小时前
Ubuntu挂载本地镜像源(像CentOS 一样挂载本地镜像源)
linux·ubuntu·centos
程序员JerrySUN3 小时前
全面理解 Linux 内核性能问题:分类、实战与调优策略
java·linux·运维·服务器·单片机
huangyuchi.3 小时前
【Linux】LInux下第一个程序:进度条
linux·运维·服务器·笔记·进度条·c/c++