centos7 安装 Elasticsearch 8.14
时间: 2024-06-15 17:02:02 浏览: 403
centos7安装elasticsearch
安装 Elasticsearch 8.14 在 CentOS 7 上可以通过官方的 RPM 包或者从源代码编译的方式进行。这里提供两种常见的安装方法:
**方法一:使用官方 RPM 包**
1. **更新系统和添加存储库**:
```sh
sudo yum update -y
sudo yum install epel-release -y # 如果还没有安装 EPEL(额外的第三方软件仓库)
```
2. **安装依赖**:
```sh
sudo yum install -1.8.0-openjdk-devel git
```
3. **下载并安装 Elasticsearch RPM**:
```sh
sudo curl -o /etc/yum.repos.d/elasticsearch-8.repo https://artifacts.elastic.co/packages/7.x/yum/elasticsearch-8.x.repo
sudo yum install -y elasticsearch
```
4. **启动、配置和设置服务**:
```sh
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
```
5. **首次启动后,可能需要设置管理员密码**:
```sh
sudo bin/elasticsearch-plugin list # 查看插件
sudo bin/elasticsearch-setup-passwords interactive
```
**方法二:从源代码编译安装**
1. **下载 Elasticsearch 源码**:
```sh
mkdir -p /opt/elasticsearch
cd /opt/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.0.tar.gz
tar -zxvf elasticsearch-8.14.0.tar.gz
```
2. **创建配置文件**:
```sh
cp elasticsearch-8.14.0/bin/elasticsearch.in.sh elasticsearch-8.14.0/bin/elasticsearch.sh
```
3. **配置环境变量和启动**:
```sh
echo "export PATH=$PATH:/opt/elasticsearch/elasticsearch-8.14.0/bin" >> ~/.bashrc
source ~/.bashrc
bin/elasticsearch
```
4. **设置服务**:
```sh
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
```
阅读全文