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 
相关推荐
Elastic 中国社区官方博客18 小时前
Elastic 9.4:Workflows 正式发布、Agent Builder 更新,以及 Prometheus / PromQL 支持
运维·数据库·人工智能·elasticsearch·搜索引擎·信息可视化·prometheus
逸Y 仙X18 小时前
Elasticsearch时间类型实战
java·大数据·elasticsearch·搜索引擎·全文检索
wljy119 小时前
二、静态库的制作和使用
linux·c语言·开发语言·c++
mzhan01719 小时前
Linux: coredump产生对程序退出的影响
linux·运维·服务器
光电笑映20 小时前
从环境变量到进程虚拟地址空间——Linux 内存管理的底层脉络
linux·服务器·c++·c
源远流长jerry20 小时前
Linux 网络收包机制:从网卡到 Socket 的完整路径
linux·运维·服务器·网络·网络协议·tcp/ip
杰 .21 小时前
Linux工具使用
linux·服务器
Gc9umsbL11 天前
零基础学Linux:21天从“命令小白”到独立部署服务器
linux·运维·服务器
骑着骆驼写程序1 天前
Ubuntu上部署前端项目报500错误
linux·运维·ubuntu
小娄~~1 天前
进程间通信
linux·运维·服务器