chore: optimize resource allocation and memory settings in Docker Compose
- Added memory and CPU limits and reservations for Prometheus, Grafana, and Uptime Kuma services to enhance performance and resource management. - Updated Prometheus and Grafana configurations with new storage block duration settings for improved memory optimization. - Revised README to include additional commands for running specific services and restarting containers.
This commit is contained in:
17
README.md
17
README.md
@@ -19,10 +19,6 @@ prod/
|
||||
|
||||
## 🚀 Быстрый запуск
|
||||
|
||||
### ⚠️ Важное замечание
|
||||
**Убедитесь, что вы удалили файл `docker-compose.yml` из папки `bots/telegram-helper-bot/`**
|
||||
для избежания конфликтов портов. Используйте только корневой `docker-compose.yml`.
|
||||
|
||||
### 1. Настройка переменных окружения
|
||||
|
||||
Скопируйте шаблон и настройте переменные:
|
||||
@@ -57,12 +53,25 @@ GRAFANA_ADMIN_PASSWORD=admin
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 2.1 Запуск только основного бота (с зависимостями). Можно заменить на AnonBot
|
||||
|
||||
```bash
|
||||
docker-compose up -d prometheus telegram-bot
|
||||
```
|
||||
|
||||
### 3. Проверка статуса
|
||||
|
||||
```bash
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
|
||||
### 4. Перезапуск контейнера
|
||||
|
||||
```bash
|
||||
docker-compose down telegram-bot && docker-compose build --no-cache telegram-bot && docker-compose up -d telegram-bot
|
||||
```
|
||||
|
||||
## 📊 Сервисы
|
||||
|
||||
- **Prometheus** (порт 9090) - сбор метрик
|
||||
|
||||
@@ -13,6 +13,9 @@ services:
|
||||
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_DAYS:-30}d'
|
||||
- '--web.enable-lifecycle'
|
||||
- '--web.external-url=https://${SERVER_IP}/prometheus/'
|
||||
# Оптимизация памяти
|
||||
- '--storage.tsdb.max-block-duration=2h'
|
||||
- '--storage.tsdb.min-block-duration=2h'
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
@@ -26,6 +29,14 @@ services:
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 128M
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
memory: 64M
|
||||
cpus: '0.25'
|
||||
|
||||
# Grafana Dashboard
|
||||
grafana:
|
||||
@@ -39,6 +50,10 @@ services:
|
||||
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
|
||||
- GF_SERVER_ROOT_URL=https://${SERVER_IP}/grafana/
|
||||
- GF_SERVER_SERVE_FROM_SUB_PATH=true
|
||||
# Оптимизация памяти
|
||||
- GF_DATABASE_MAX_IDLE_CONN=2
|
||||
- GF_DATABASE_MAX_OPEN_CONN=5
|
||||
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/node-exporter-full-dashboard.json
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
@@ -53,6 +68,14 @@ services:
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 200M
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
memory: 100M
|
||||
cpus: '0.25'
|
||||
|
||||
# Uptime Kuma Status Page
|
||||
uptime-kuma:
|
||||
@@ -73,6 +96,14 @@ services:
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 150M
|
||||
cpus: '0.5'
|
||||
reservations:
|
||||
memory: 80M
|
||||
cpus: '0.25'
|
||||
|
||||
# Alertmanager
|
||||
alertmanager:
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
known_hosts:
|
||||
path: ~/.ssh/known_hosts
|
||||
name: "{{ ansible_host }}"
|
||||
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa,ecdsa,ed25519 ' + ansible_host) }}"
|
||||
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa,ecdsa,ed25519 ' + ansible_host + ' 2>/dev/null') }}"
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
@@ -71,6 +71,8 @@
|
||||
- certbot
|
||||
- python3-certbot-nginx
|
||||
- logrotate
|
||||
- net-tools
|
||||
- cron
|
||||
state: present
|
||||
|
||||
- name: "[1/10] Установить Python библиотеки для Ansible"
|
||||
@@ -233,9 +235,10 @@
|
||||
var: node_exporter_status.stdout_lines
|
||||
|
||||
- name: "[3/10] Проверить, что node_exporter слушает на порту 9100"
|
||||
command: netstat -tulpn | grep 9100
|
||||
command: ss -tulpn | grep 9100
|
||||
register: node_exporter_port
|
||||
changed_when: false
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "[3/10] Показать информацию о порте 9100"
|
||||
debug:
|
||||
@@ -1126,6 +1129,7 @@
|
||||
command: fail2ban-client status
|
||||
register: fail2ban_status
|
||||
changed_when: false
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "[9/10] Показать статус Fail2ban"
|
||||
debug:
|
||||
@@ -1233,6 +1237,12 @@
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: "[9.5/10] Установить cron (если не установлен)"
|
||||
apt:
|
||||
name: cron
|
||||
state: present
|
||||
when: ansible_pkg_mgr == "apt"
|
||||
|
||||
- name: "[9.5/10] Настроить cron для ежедневного запуска logrotate"
|
||||
cron:
|
||||
name: "Logrotate daily"
|
||||
|
||||
Reference in New Issue
Block a user