# 本地安装

URL: https://caijiao.org/elasticsearch/01.intro/04.installation-local
Source: docs/elasticsearch/01.intro/04.installation-local.md
Description: 本章介绍如何在本地环境中安装 Elasticsearch，适配 Windows、macOS 和 Linux 系统，便于开发测试与入门学习。

为了更好地学习和调试 Elasticsearch，建议先在本地搭建一个开发环境。Elasticsearch 提供跨平台的安装方式，适用于 Windows、macOS 和 Linux 操作系统。

## 1. 安装前准备

- 安装 Java（JDK 17 推荐）
- 确保机器至少有 4GB 可用内存
- 安装包下载地址：  
  [https://www.elastic.co/downloads/elasticsearch](https://www.elastic.co/downloads/elasticsearch)

## 2. Windows 安装步骤

1. 解压下载的 `.zip` 安装包到任意目录  
2. 在终端中进入解压目录，执行：

   ```bash
   bin\elasticsearch.bat
   ````

3. 浏览器访问 `http://localhost:9200`，看到集群信息即启动成功

## 3. macOS 安装方式

推荐使用 Homebrew 安装：

```bash
brew tap elastic/tap
brew install elastic/tap/elasticsearch-full
brew services start elastic/tap/elasticsearch-full
```

## 4. Linux 安装方式（以 Debian 为例）

```bash
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-<version>-linux-x86_64.tar.gz
tar -xzf elasticsearch-<version>-linux-x86_64.tar.gz
cd elasticsearch-<version>
./bin/elasticsearch
```

## 5. 测试是否运行成功

启动后，在浏览器或命令行运行：

```bash
curl http://localhost:9200
```

应返回包含版本号、集群名等基本信息的 JSON。

---

本地部署是理解 Elasticsearch 架构、测试索引与查询的第一步，建议先在本地充分练习后再部署到服务器或集群环境中。
