# 安装 API7 企业版

本教程将引导你使用快速启动脚本在 Docker 中安装 API7 企业版。

安装将包含 API7 企业版组件（数据面、控制面、控制台、开发者门户）以及用于管理配置、监控和链路追踪的外部组件（PostgreSQL、Prometheus 和 Jaeger）。

提示

本指南提供了一个用于概念验证（PoC）测试的容器化一体解决方案，其中包含了 PostgreSQL 和 Prometheus。这无需手动设置数据库和监控，从而简化了你的 PoC 流程。

对于生产环境部署，PostgreSQL 是主要且推荐的存储后端。API7 企业版还支持以下数据库和版本：

* PostgreSQL：12.x–18.x
* MySQL：5.7、8.x
* Microsoft SQL Server：2019、2022

除本页介绍的容器化快速启动方式外，API7 企业版还支持 Kubernetes 和 RPM 部署。有关完整的兼容性信息和安装方式，请参阅[支持的版本和互操作性](https://docs.apiseven.com/api7-gateway/install/supported-versions-and-interoperability.md)及[在本地环境安装 API7 网关](https://docs.apiseven.com/api7-gateway/install/overview.md)。

如需获取高可用性和可扩展性解决方案，请联系 API7 专家[申请试用](https://api7.ai/try?product=enterprise)。

## 前置条件[​](#前置条件 "前置条件的直接链接")

* 安装 [Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://docs.docker.com/compose/install)。在 Linux 上，推荐使用 3.10.0-927 或更高版本的内核；已知 3.10.0-327 或更低版本的内核存在兼容性问题。
* 安装 [cURL](https://curl.se/)。
* 获取 30 天[免费试用许可证](https://api7.ai/try?product=enterprise)。
* 操作系统：推荐使用 Linux CentOS 7.6 或更高版本。已知 Linux CentOS 7.2 或更低版本存在不兼容问题。

## 安装 API7 企业版[​](#安装-api7-企业版 "安装 API7 企业版的直接链接")

```
curl -sL "https://run.api7.ai/api7/quickstart" | bash
```

你应该会看到类似于以下的响应：

```
✔ Container api7-ee-postgresql-1

✔ Container api7-ee-prometheus-1

✔ Container api7-ee-jaeger-1

✔ Container api7-ee-api7-ee-dashboard-1

✔ Container api7-ee-api7-ee-dp-manager-1

✔ Container api7-ee-api7-ee-developer-portal-1

...

Waiting for service api7-ee-gateway to be ready...

Service api7-ee-gateway is ready.

✔ API7-EE is ready!



API7-EE Listening: Dashboard(https://192.168.2.102:7443), DP Manager Address(http://192.168.2.102:7900, https://192.168.2.102:7943), Gateway(http://192.168.2.102:9080, https://192.168.2.102:9443)



If you want to access Dashboard with HTTP Endpoint(:7080), you can turn server.listen.disable to false in dashboard_conf/conf.yaml, then restart dashboard container
```

任何一步失败时，脚本都会以非零状态码退出，不会打印 `API7-EE is ready!`，而是打印失败原因、`docker compose ps -a` 的输出和各服务最后的日志。

### 安装 ADC（可选）[​](#安装-adc可选 "安装 ADC（可选）的直接链接")

你还可以安装 API 声明式命令行（ADC）来以声明式方式管理 API7 企业版。

```
curl -sL "https://run.api7.ai/adc/install" | bash
```

要验证安装，请运行：

```
adc help
```

你应该会看到以下响应：

```
Usage: adc [options] [command]



Options:

  -V, --version      output the version number

  -h, --help         display help for command



Commands:

  ping [options]     Verify connectivity with backend

  dump [options]     Dump configurations from the backend

  diff [options]     Show the difference between local and backend configurations

  sync [options]     Sync local configurations to backend

  convert [options]  Convert other API spec to ADC configurations

  lint [options]     Check provided configuration files, local execution only, ensuring inputs meet ADC requirements

  help [command]     display help for command
```

有关可用命令和配置的更多详细信息，请参阅[ADC 参考](https://docs.apiseven.com/api7-gateway/reference/adc.md)。

## 激活 API7 企业版[​](#激活-api7-企业版 "激活 API7 企业版的直接链接")

1. 访问 API7 企业版控制台 `https://{your_inet_ip_addr}:7443` 并使用默认的用户名 `admin` 和密码 `admin` 登录（我们建议在首次登录后更改默认密码）。

信息

你也可以在 `https://localhost:7443/login` 访问控制台。但是，随后在控制台中生成的部署脚本将默认使用 `localhost` 作为 IP 地址，这可能会导致连接问题，例如在[设置 Ingress Controller 和网关](https://docs.apiseven.com/ingress-controller/set-up-ingress-controller-and-gateway.md)时。

2. 选择你要上传的许可证，然后点击 **上传** 来激活 API7 企业版。

### 使用 ADC 连接到 API7 企业版（可选）[​](#使用-adc-连接到-api7-企业版可选 "使用 ADC 连接到 API7 企业版（可选）的直接链接")

在使用 ADC 将配置同步到 API7 企业版之前，首先请确保你的 ADC 客户端能够完成身份认证并与 API7 企业版进行通信。你需要在 `.env` 文件或命令行参数中配置一些变量。

按照[从控制台获取 Token](https://docs.apiseven.com/api7-gateway/reference/obtain-dashboard-token.md)中的步骤，在 API7 网关控制台生成 Token。

创建一个包含以下变量的 `.env` 文件：

.env

```
ADC_BACKEND=api7ee                   # 指定后端为 API7 企业版

ADC_TOKEN=a7ee-YVDPvh6CXxMuz5iM...   # 替换为你的 Token

ADC_SERVER=https://localhost:7443    # 如果 API7 企业版不在本地运行，请更新服务器地址
```

或者，你也可以在命令行参数中指定这些值。有关更多信息，请参阅 [ADC 参考](https://docs.apiseven.com/api7-gateway/reference/adc.md)。

要验证连通性，请运行：

```
adc ping
```

你应该会看到以下响应：

```
Connected to the "api7ee" backend successfully!
```

## 停止 API7 企业版[​](#停止-api7-企业版 "停止 API7 企业版的直接链接")

如果你已经完成了对 API7 企业版的测试，你可以在 `api7-ee` 目录下使用以下命令停止 API7 企业版：

```
bash run.sh stop
```

## 后续步骤[​](#后续步骤 "后续步骤的直接链接")

1. 如果你想在 Kubernetes 上部署 API7 网关并使用 Ingress Controller，请参阅[在 Kubernetes 上部署 API7 企业版](https://docs.apiseven.com/api7-gateway/install/deploy-on-kubernetes.md)和[设置 Ingress Controller 和网关](https://docs.apiseven.com/ingress-controller/set-up-ingress-controller-and-gateway.md)。
2. 按照[发布你的第一个 API](https://docs.apiseven.com/api7-gateway/getting-started/launch-your-first-api.md)中的步骤发布 API，进一步了解 API7 企业版的使用方法。
3. 按照[部署高可用环境](https://docs.apiseven.com/api7-gateway/install/deploy-high-availability.md)部署 API7 企业版。
4. 联系 API7 专家[申请试用](https://api7.ai/try?product=enterprise)，开始在生产环境中使用 API7 企业版。
