feat: add mongodb-replicaset/ & mysql/ & minio/

This commit is contained in:
Sun-ZhenXing
2025-09-24 00:06:13 +08:00
parent 619281e78a
commit 79ad907def
11 changed files with 156 additions and 2 deletions

1
src/mongodb-replicaset/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/secrets

View File

@@ -0,0 +1,22 @@
# MongoDB
```bash
docker exec -it mongodb-mongo1-1 mongosh
```
初始化副本集:
```js
use admin
db.auth('root', '$MONGO_ROOT_PASSWORD')
config = {
_id: "rs0",
members: [
{_id: 0, host: "192.168.31.38:27017"},
{_id: 1, host: "192.168.31.38:27018"},
{_id: 2, host: "192.168.31.38:27019"},
]
}
rs.initiate(config)
exit
```

View File

@@ -0,0 +1,56 @@
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
x-mongo: &mongo
<<: *default
image: mongo:${MONGO_VERSION:-8.0.13}
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:-root}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:-password}
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE:-admin}
command:
- mongod
- --replSet
- ${MONGO_REPLICA_SET_NAME:-rs0}
- --keyFile
- /secrets/rs0.key
volumes:
- *localtime
- *timezone
- ./secrets/rs0.key:/secrets/rs0.key
entrypoint:
- bash
- -c
- |
chmod 400 /secrets/rs0.key
chown 999:999 /secrets/rs0.key
exec docker-entrypoint.sh $$@
deploy:
resources:
limits:
cpus: '0.50'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
services:
mongo1:
<<: *mongo
ports:
- "${MONGO_PORT_OVERRIDE_1:-27017}:27017"
mongo2:
<<: *mongo
ports:
- "${MONGO_PORT_OVERRIDE_2:-27018}:27017"
mongo3:
<<: *mongo
ports:
- "${MONGO_PORT_OVERRIDE_3:-27019}:27017"