--- title: "URL 仓库地址配置" date: 2026-01-05 lastmod: 2026-01-05 description: "repositories.url.url 配置项用于定义 URL 仓库的根地址。" tags: ["仓库", "URL", "快照", "备份"] summary: "配置项作用 # repositories.url.url 配置项用于定义 URL 仓库的根地址。 配置项属性 # 配置路径: repositories.url.url 数据类型: URL(URL 对象) 默认值: "http:"(默认使用 http 协议) 是否可选: 否(URL 仓库必须配置) 作用域: NodeScope(节点级别) 动态更新: 是(可以动态更新,无需重启) 配置建议 # HTTP 仓库 # repositories: url: url: "http://repo.example.com/easysearch/snapshots" HTTPS 仓库(推荐) # repositories: url: url: "https://repo.example.com/easysearch/snapshots" FTP 仓库 # repositories: url: url: "ftp://ftp.example.com/easysearch/backups" 本地文件仓库 # repositories: url: url: "file:///mnt/easysearch-backups/snapshots" JAR 仓库 # repositories: url: url: "jar:file:///path/to/archive.jar!/" 功能说明 # 仓库类型 # URL 仓库是一种只读仓库类型,支持从远程或本地 URL 访问快照数据。" --- ## 配置项作用 `repositories.url.url` 配置项用于**定义 URL 仓库的根地址**。 ## 配置项属性 - **配置路径**: `repositories.url.url` - **数据类型**: `URL`(URL 对象) - **默认值**: `"http:"`(默认使用 http 协议) - **是否可选**: 否(URL 仓库必须配置) - **作用域**: NodeScope(节点级别) - **动态更新**: 是(可以动态更新,无需重启) ## 配置建议 ## HTTP 仓库 ```yaml repositories: url: url: "http://repo.example.com/easysearch/snapshots" ``` ## HTTPS 仓库(推荐) ```yaml repositories: url: url: "https://repo.example.com/easysearch/snapshots" ``` ## FTP 仓库 ```yaml repositories: url: url: "ftp://ftp.example.com/easysearch/backups" ``` ## 本地文件仓库 ```yaml repositories: url: url: "file:///mnt/easysearch-backups/snapshots" ``` ## JAR 仓库 ```yaml repositories: url: url: "jar:file:///path/to/archive.jar!/" ``` ## 功能说明 ## 仓库类型 URL 仓库是一种**只读**仓库类型,支持从远程或本地 URL 访问快照数据。 ## 配置解析顺序 当创建 URL 仓库时,系统按以下顺序查找 URL 配置: 1. 首先检查仓库配置中直接指定的 `url` 参数 2. 如果未找到,则查找环境设置中的 `repositories.url.url` 3. 如果都未指定,默认使用 `"http:"` 但初始化时会抛出 RepositoryException ## 支持的协议 - **HTTP** (`http://`) - 不加密的 HTTP 协议 - **HTTPS** (`https://`) - 加密的 HTTPS 协议(推荐) - **FTP** (`ftp://`) - 文件传输协议 - **FILE** (`file:///`) - 本地文件系统 - **JAR** (`jar://`) - JAR 归档文件 ## 使用场景 ## 远程备份仓库 ```yaml # 从远程 HTTP 服务器恢复快照 repositories: url: url: "https://backup.company.com/easysearch/prod" ``` ## 网络存储 ```yaml # 使用网络共享存储 repositories: url: url: "file:///mnt/network-storage/easysearch/snapshots" ``` ## 归档数据访问 ```yaml # 访问 JAR 归档中的历史快照 repositories: url: url: "jar:file:///archives/2023-backups.jar!/" ``` ## 多环境配置 ```yaml # 开发环境 repositories: url: url: "http://dev-repo.company.com/snapshots" # 生产环境 repositories: url: url: "https://prod-repo.company.com/snapshots" ``` ## 注意事项 1. **动态更新**: 此配置可以动态更新,无需重启节点。 2. **必需配置**: URL 仓库必须配置此参数,否则无法正常工作。 3. **只读限制**: URL 仓库本质上是只读的,不能用于创建新快照,只能用于恢复现有快照。 4. **协议选择**: 生产环境建议使用 HTTPS 以确保数据传输安全。 5. **访问权限**: 确保运行 Easysearch 的进程有权限访问指定的 URL。 6. **网络稳定性**: 使用远程 URL 时,考虑网络延迟和稳定性对恢复操作的影响。 7. **配合 allowed_urls**: 建议与 `repositories.url.allowed_urls` 配合使用以增强安全性。 8. **URL 格式**: 确保使用正确的 URL 格式,包括协议前缀和完整路径。 9. **认证凭据**: 某些协议(如 HTTPS)可能需要额外的认证配置,请参考相应协议的认证设置。 10. **性能考虑**: 从远程 URL 恢复大快照可能较慢,建议在低峰期进行或使用本地缓存。