feat: add more
This commit is contained in:
22
src/opensearch/.env.example
Normal file
22
src/opensearch/.env.example
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenSearch version
|
||||
OPENSEARCH_VERSION="2.19.0"
|
||||
|
||||
# OpenSearch Dashboards version
|
||||
OPENSEARCH_DASHBOARDS_VERSION="2.19.0"
|
||||
|
||||
# Cluster configuration
|
||||
CLUSTER_NAME="opensearch-cluster"
|
||||
|
||||
# JVM heap size (should be 50% of container memory)
|
||||
OPENSEARCH_HEAP_SIZE="512m"
|
||||
|
||||
# Admin password (minimum 8 chars with upper, lower, digit, special char)
|
||||
OPENSEARCH_ADMIN_PASSWORD="Admin@123"
|
||||
|
||||
# Security plugin (set to true to disable for testing)
|
||||
DISABLE_SECURITY_PLUGIN="false"
|
||||
|
||||
# Port overrides
|
||||
OPENSEARCH_PORT_OVERRIDE=9200
|
||||
OPENSEARCH_PERF_ANALYZER_PORT_OVERRIDE=9600
|
||||
OPENSEARCH_DASHBOARDS_PORT_OVERRIDE=5601
|
||||
99
src/opensearch/README.md
Normal file
99
src/opensearch/README.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# OpenSearch
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
This service deploys OpenSearch (Elasticsearch fork) with OpenSearch Dashboards (Kibana fork).
|
||||
|
||||
## Services
|
||||
|
||||
- `opensearch`: OpenSearch server for search and analytics.
|
||||
- `opensearch-dashboards`: OpenSearch Dashboards for visualization.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable Name | Description | Default Value |
|
||||
| -------------------------------------- | ----------------------------- | -------------------- |
|
||||
| OPENSEARCH_VERSION | OpenSearch image version | `2.19.0` |
|
||||
| OPENSEARCH_DASHBOARDS_VERSION | OpenSearch Dashboards version | `2.19.0` |
|
||||
| CLUSTER_NAME | Cluster name | `opensearch-cluster` |
|
||||
| OPENSEARCH_HEAP_SIZE | JVM heap size | `512m` |
|
||||
| OPENSEARCH_ADMIN_PASSWORD | Admin password | `Admin@123` |
|
||||
| DISABLE_SECURITY_PLUGIN | Disable security plugin | `false` |
|
||||
| OPENSEARCH_PORT_OVERRIDE | OpenSearch API port | `9200` |
|
||||
| OPENSEARCH_PERF_ANALYZER_PORT_OVERRIDE | Performance Analyzer port | `9600` |
|
||||
| OPENSEARCH_DASHBOARDS_PORT_OVERRIDE | Dashboards UI port | `5601` |
|
||||
|
||||
Please modify the `.env` file as needed for your use case.
|
||||
|
||||
## Volumes
|
||||
|
||||
- `opensearch_data`: OpenSearch data storage.
|
||||
|
||||
## Usage
|
||||
|
||||
### Start the Services
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Access OpenSearch
|
||||
|
||||
OpenSearch API:
|
||||
|
||||
```bash
|
||||
curl -XGET https://localhost:9200 -u 'admin:Admin@123' --insecure
|
||||
```
|
||||
|
||||
### Access OpenSearch Dashboards
|
||||
|
||||
Open your browser and navigate to:
|
||||
|
||||
```text
|
||||
http://localhost:5601
|
||||
```
|
||||
|
||||
Login with username `admin` and the password set in `OPENSEARCH_ADMIN_PASSWORD`.
|
||||
|
||||
### Create an Index
|
||||
|
||||
```bash
|
||||
curl -XPUT https://localhost:9200/my-index -u 'admin:Admin@123' --insecure
|
||||
```
|
||||
|
||||
### Index a Document
|
||||
|
||||
```bash
|
||||
curl -XPOST https://localhost:9200/my-index/_doc -u 'admin:Admin@123' --insecure \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"title": "Hello OpenSearch", "content": "This is a test document"}'
|
||||
```
|
||||
|
||||
### Search Documents
|
||||
|
||||
```bash
|
||||
curl -XGET https://localhost:9200/my-index/_search -u 'admin:Admin@123' --insecure \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"query": {"match": {"title": "Hello"}}}'
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **Full-Text Search**: Advanced search capabilities with relevance scoring
|
||||
- **Analytics**: Real-time data analysis and aggregations
|
||||
- **Visualization**: Rich dashboards with OpenSearch Dashboards
|
||||
- **Security**: Built-in security plugin with authentication and encryption
|
||||
- **RESTful API**: Easy integration with any programming language
|
||||
- **Scalable**: Single-node for development, cluster mode for production
|
||||
|
||||
## Notes
|
||||
|
||||
- Default admin password must contain at least 8 characters with uppercase, lowercase, digit, and special character
|
||||
- For production, change the admin password and consider using external certificates
|
||||
- JVM heap size should be set to 50% of available memory (max 31GB)
|
||||
- Security plugin can be disabled for testing by setting `DISABLE_SECURITY_PLUGIN=true`
|
||||
- For cluster mode, add more nodes and configure `discovery.seed_hosts`
|
||||
|
||||
## License
|
||||
|
||||
OpenSearch is licensed under the Apache License 2.0.
|
||||
99
src/opensearch/README.zh.md
Normal file
99
src/opensearch/README.zh.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# OpenSearch
|
||||
|
||||
[English](./README.md) | [中文](./README.zh.md)
|
||||
|
||||
此服务用于部署 OpenSearch(Elasticsearch 分支)和 OpenSearch Dashboards(Kibana 分支)。
|
||||
|
||||
## 服务
|
||||
|
||||
- `opensearch`: 用于搜索和分析的 OpenSearch 服务器。
|
||||
- `opensearch-dashboards`: 用于可视化的 OpenSearch Dashboards。
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量名 | 说明 | 默认值 |
|
||||
| -------------------------------------- | -------------------------- | -------------------- |
|
||||
| OPENSEARCH_VERSION | OpenSearch 镜像版本 | `2.19.0` |
|
||||
| OPENSEARCH_DASHBOARDS_VERSION | OpenSearch Dashboards 版本 | `2.19.0` |
|
||||
| CLUSTER_NAME | 集群名称 | `opensearch-cluster` |
|
||||
| OPENSEARCH_HEAP_SIZE | JVM 堆大小 | `512m` |
|
||||
| OPENSEARCH_ADMIN_PASSWORD | 管理员密码 | `Admin@123` |
|
||||
| DISABLE_SECURITY_PLUGIN | 禁用安全插件 | `false` |
|
||||
| OPENSEARCH_PORT_OVERRIDE | OpenSearch API 端口 | `9200` |
|
||||
| OPENSEARCH_PERF_ANALYZER_PORT_OVERRIDE | 性能分析器端口 | `9600` |
|
||||
| OPENSEARCH_DASHBOARDS_PORT_OVERRIDE | Dashboards UI 端口 | `5601` |
|
||||
|
||||
请根据实际需求修改 `.env` 文件。
|
||||
|
||||
## 卷
|
||||
|
||||
- `opensearch_data`: OpenSearch 数据存储。
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 启动服务
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 访问 OpenSearch
|
||||
|
||||
OpenSearch API:
|
||||
|
||||
```bash
|
||||
curl -XGET https://localhost:9200 -u 'admin:Admin@123' --insecure
|
||||
```
|
||||
|
||||
### 访问 OpenSearch Dashboards
|
||||
|
||||
在浏览器中打开:
|
||||
|
||||
```text
|
||||
http://localhost:5601
|
||||
```
|
||||
|
||||
使用用户名 `admin` 和 `OPENSEARCH_ADMIN_PASSWORD` 中设置的密码登录。
|
||||
|
||||
### 创建索引
|
||||
|
||||
```bash
|
||||
curl -XPUT https://localhost:9200/my-index -u 'admin:Admin@123' --insecure
|
||||
```
|
||||
|
||||
### 索引文档
|
||||
|
||||
```bash
|
||||
curl -XPOST https://localhost:9200/my-index/_doc -u 'admin:Admin@123' --insecure \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"title": "Hello OpenSearch", "content": "This is a test document"}'
|
||||
```
|
||||
|
||||
### 搜索文档
|
||||
|
||||
```bash
|
||||
curl -XGET https://localhost:9200/my-index/_search -u 'admin:Admin@123' --insecure \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"query": {"match": {"title": "Hello"}}}'
|
||||
```
|
||||
|
||||
## 功能
|
||||
|
||||
- **全文搜索**: 具有相关性评分的高级搜索功能
|
||||
- **分析**: 实时数据分析和聚合
|
||||
- **可视化**: 使用 OpenSearch Dashboards 创建丰富的仪表板
|
||||
- **安全性**: 内置安全插件,具有身份验证和加密功能
|
||||
- **RESTful API**: 易于与任何编程语言集成
|
||||
- **可扩展**: 开发环境使用单节点,生产环境使用集群模式
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 默认管理员密码必须至少包含 8 个字符,包括大写字母、小写字母、数字和特殊字符
|
||||
- 对于生产环境,请更改管理员密码并考虑使用外部证书
|
||||
- JVM 堆大小应设置为可用内存的 50%(最大 31GB)
|
||||
- 可以通过设置 `DISABLE_SECURITY_PLUGIN=true` 禁用安全插件进行测试
|
||||
- 对于集群模式,添加更多节点并配置 `discovery.seed_hosts`
|
||||
|
||||
## 许可证
|
||||
|
||||
OpenSearch 使用 Apache License 2.0 授权。
|
||||
68
src/opensearch/docker-compose.yaml
Normal file
68
src/opensearch/docker-compose.yaml
Normal file
@@ -0,0 +1,68 @@
|
||||
x-default: &default
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- &localtime /etc/localtime:/etc/localtime:ro
|
||||
- &timezone /etc/timezone:/etc/timezone:ro
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 100m
|
||||
|
||||
services:
|
||||
opensearch:
|
||||
<<: *default
|
||||
image: opensearchproject/opensearch:${OPENSEARCH_VERSION:-2.19.0}
|
||||
container_name: opensearch
|
||||
environment:
|
||||
cluster.name: ${CLUSTER_NAME:-opensearch-cluster}
|
||||
node.name: opensearch
|
||||
discovery.type: single-node
|
||||
bootstrap.memory_lock: true
|
||||
OPENSEARCH_JAVA_OPTS: "-Xms${OPENSEARCH_HEAP_SIZE:-512m} -Xmx${OPENSEARCH_HEAP_SIZE:-512m}"
|
||||
OPENSEARCH_INITIAL_ADMIN_PASSWORD: ${OPENSEARCH_ADMIN_PASSWORD:-Admin@123}
|
||||
DISABLE_SECURITY_PLUGIN: ${DISABLE_SECURITY_PLUGIN:-false}
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
nofile:
|
||||
soft: 65536
|
||||
hard: 65536
|
||||
ports:
|
||||
- "${OPENSEARCH_PORT_OVERRIDE:-9200}:9200"
|
||||
- "${OPENSEARCH_PERF_ANALYZER_PORT_OVERRIDE:-9600}:9600"
|
||||
volumes:
|
||||
- *localtime
|
||||
- *timezone
|
||||
- opensearch_data:/usr/share/opensearch/data
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '1.0'
|
||||
memory: 1G
|
||||
|
||||
opensearch-dashboards:
|
||||
<<: *default
|
||||
image: opensearchproject/opensearch-dashboards:${OPENSEARCH_DASHBOARDS_VERSION:-2.19.0}
|
||||
container_name: opensearch-dashboards
|
||||
ports:
|
||||
- "${OPENSEARCH_DASHBOARDS_PORT_OVERRIDE:-5601}:5601"
|
||||
environment:
|
||||
OPENSEARCH_HOSTS: '["https://opensearch:9200"]'
|
||||
DISABLE_SECURITY_DASHBOARDS_PLUGIN: ${DISABLE_SECURITY_PLUGIN:-false}
|
||||
depends_on:
|
||||
- opensearch
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
|
||||
volumes:
|
||||
opensearch_data:
|
||||
Reference in New Issue
Block a user