Actualiser Guide-migration-moodle-rber-v2
This commit is contained in:
@@ -67,41 +67,42 @@ rsync --version
|
|||||||
|
|
||||||
## 2. Phase 1 : Audit de l'environnement source
|
## 2. Phase 1 : Audit de l'environnement source
|
||||||
|
|
||||||
### 2.1 Informations système
|
> **Note :** Les Moodle sources sont des pods Kubernetes. Toutes les commandes utilisent `kubectl exec`.
|
||||||
|
|
||||||
|
### 2.1 Identifier le pod source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Connexion au serveur source
|
# Variables - ADAPTER selon l'université et le namespace source
|
||||||
ssh admin@elearning.UNIVERSITE.bj
|
SOURCE_NS="moodle-source" # Namespace où se trouve le Moodle actuel
|
||||||
|
SOURCE_DEPLOY="moodle" # Nom du deployment
|
||||||
|
|
||||||
# Version système
|
# Vérifier le pod
|
||||||
cat /etc/os-release
|
kubectl get pods -n ${SOURCE_NS}
|
||||||
uname -a
|
|
||||||
|
|
||||||
# Version Moodle
|
# Version Moodle
|
||||||
sudo -u www-data php /var/www/moodle/admin/cli/version.php
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php /bitnami/moodle/admin/cli/version.php
|
||||||
|
|
||||||
# Version PHP et extensions
|
# Version PHP et extensions
|
||||||
php -v
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php -v
|
||||||
php -m | grep -E "curl|gd|intl|mbstring|pgsql|mysqli|xml|zip|soap|ldap"
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php -m | grep -E "curl|gd|intl|mbstring|pgsql|mysqli|xml|zip|soap|ldap"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.2 Audit base de données
|
### 2.2 Audit base de données
|
||||||
|
|
||||||
**Pour MySQL/MariaDB :**
|
|
||||||
```bash
|
```bash
|
||||||
mysql -u root -p -e "
|
# Identifier le cluster PostgreSQL source
|
||||||
SELECT
|
kubectl get cluster -n ${SOURCE_NS}
|
||||||
table_schema AS 'Database',
|
|
||||||
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size_MB'
|
|
||||||
FROM information_schema.tables
|
|
||||||
WHERE table_schema = 'moodle'
|
|
||||||
GROUP BY table_schema;
|
|
||||||
"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Pour PostgreSQL :**
|
# Ou se connecter via le pod Moodle
|
||||||
```bash
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php -r "
|
||||||
sudo -u postgres psql -d moodle -c "
|
require('/bitnami/moodle/config.php');
|
||||||
|
global \$DB;
|
||||||
|
echo 'Host: ' . \$CFG->dbhost . PHP_EOL;
|
||||||
|
echo 'Database: ' . \$CFG->dbname . PHP_EOL;
|
||||||
|
"
|
||||||
|
|
||||||
|
# Taille de la base (si accès direct au pod PostgreSQL)
|
||||||
|
kubectl exec -n ${SOURCE_NS} <pg-pod-name> -- psql -U postgres -d moodle -c "
|
||||||
SELECT pg_size_pretty(pg_database_size('moodle')) AS size;
|
SELECT pg_size_pretty(pg_database_size('moodle')) AS size;
|
||||||
"
|
"
|
||||||
```
|
```
|
||||||
@@ -109,12 +110,13 @@ SELECT pg_size_pretty(pg_database_size('moodle')) AS size;
|
|||||||
### 2.3 Statistiques Moodle
|
### 2.3 Statistiques Moodle
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Remplacer par la commande appropriée selon le type de BDD
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php -r "
|
||||||
mysql -u root -p moodle -e "
|
require('/bitnami/moodle/config.php');
|
||||||
SELECT 'Utilisateurs' AS metric, COUNT(*) AS value FROM mdl_user WHERE deleted=0
|
global \$DB;
|
||||||
UNION ALL SELECT 'Cours', COUNT(*) FROM mdl_course WHERE id > 1
|
echo 'Utilisateurs actifs: ' . \$DB->count_records('user', ['deleted' => 0]) . PHP_EOL;
|
||||||
UNION ALL SELECT 'Fichiers', COUNT(*) FROM mdl_files WHERE filename != '.'
|
echo 'Cours: ' . (\$DB->count_records('course') - 1) . PHP_EOL;
|
||||||
UNION ALL SELECT 'Devoirs', COUNT(*) FROM mdl_assign;
|
echo 'Fichiers: ' . \$DB->count_records_select('files', \"filename != '.'\") . PHP_EOL;
|
||||||
|
echo 'Devoirs: ' . \$DB->count_records('assign') . PHP_EOL;
|
||||||
"
|
"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -122,37 +124,36 @@ UNION ALL SELECT 'Devoirs', COUNT(*) FROM mdl_assign;
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Taille totale
|
# Taille totale
|
||||||
du -sh /var/moodledata/
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- du -sh /bitnami/moodledata/
|
||||||
|
|
||||||
# Répartition
|
# Répartition
|
||||||
du -h --max-depth=1 /var/moodledata/ | sort -hr
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- du -h --max-depth=1 /bitnami/moodledata/ | sort -hr
|
||||||
|
|
||||||
# Nombre de fichiers
|
# Nombre de fichiers
|
||||||
find /var/moodledata -type f | wc -l
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- find /bitnami/moodledata -type f | wc -l
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.5 Plugins installés
|
### 2.5 Plugins installés
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Liste des plugins
|
# Liste des plugins
|
||||||
php /var/www/moodle/admin/cli/plugin_list.php > /tmp/plugins_list.txt
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php /bitnami/moodle/admin/cli/plugin_list.php
|
||||||
cat /tmp/plugins_list.txt
|
|
||||||
|
|
||||||
# Plugins custom (local)
|
# Plugins custom (local)
|
||||||
ls -la /var/www/moodle/local/
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- ls -la /bitnami/moodle/local/
|
||||||
|
|
||||||
# Thèmes custom
|
# Thèmes custom
|
||||||
ls -la /var/www/moodle/theme/ | grep -v boost | grep -v classic
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- ls -la /bitnami/moodle/theme/ | grep -v boost | grep -v classic
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.6 Configuration actuelle
|
### 2.6 Configuration actuelle
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sauvegarder config.php
|
# Afficher config.php
|
||||||
cat /var/www/moodle/config.php > /tmp/config.php.backup
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- cat /bitnami/moodle/config.php
|
||||||
|
|
||||||
# Paramètres critiques à noter
|
# Paramètres critiques
|
||||||
grep -E "wwwroot|dataroot|dbtype|dbhost|dbname|prefix" /var/www/moodle/config.php
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- grep -E "wwwroot|dataroot|dbtype|dbhost|dbname|prefix" /bitnami/moodle/config.php
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -293,148 +294,174 @@ helm install moodle-${UNIVERSITY} bitnami/moodle \
|
|||||||
### 4.1 Activer le mode maintenance
|
### 4.1 Activer le mode maintenance
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sur le serveur source
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php /bitnami/moodle/admin/cli/maintenance.php --enable
|
||||||
sudo -u www-data php /var/www/moodle/admin/cli/maintenance.php --enable
|
|
||||||
|
|
||||||
# Vérifier
|
# Vérifier
|
||||||
curl -I http://elearning.UNIVERSITE.bj
|
curl -I https://elearning-source.rber.bj
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.2 Dump de la base de données
|
### 4.2 Dump de la base de données
|
||||||
|
|
||||||
**Source MySQL → Cible PostgreSQL :**
|
**Option A : Dump depuis le pod PostgreSQL**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Dump MySQL
|
# Identifier le pod PostgreSQL
|
||||||
mysqldump -u root -p \
|
PG_POD=$(kubectl get pods -n ${SOURCE_NS} -l cnpg.io/cluster=<cluster-name> -o jsonpath='{.items[0].metadata.name}')
|
||||||
--single-transaction \
|
|
||||||
--quick \
|
|
||||||
--lock-tables=false \
|
|
||||||
--routines \
|
|
||||||
--triggers \
|
|
||||||
--hex-blob \
|
|
||||||
--default-character-set=utf8mb4 \
|
|
||||||
moodle > moodle_dump_$(date +%Y%m%d_%H%M%S).sql
|
|
||||||
|
|
||||||
# Compresser
|
# Dump
|
||||||
gzip moodle_dump_*.sql
|
kubectl exec -n ${SOURCE_NS} ${PG_POD} -- pg_dump -U postgres -Fc moodle > moodle_dump_$(date +%Y%m%d_%H%M%S).dump
|
||||||
|
|
||||||
|
# Vérifier
|
||||||
|
ls -lh moodle_dump_*.dump
|
||||||
```
|
```
|
||||||
|
|
||||||
**Source PostgreSQL → Cible PostgreSQL :**
|
**Option B : Dump via port-forward**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo -u postgres pg_dump -Fc moodle > moodle_dump_$(date +%Y%m%d_%H%M%S).dump
|
# Port-forward
|
||||||
|
kubectl port-forward -n ${SOURCE_NS} svc/<pg-service> 5432:5432 &
|
||||||
|
|
||||||
|
# Dump
|
||||||
|
PGPASSWORD=<password> pg_dump -h localhost -U moodle -Fc moodle > moodle_dump_$(date +%Y%m%d_%H%M%S).dump
|
||||||
|
|
||||||
|
# Arrêter le port-forward
|
||||||
|
kill %1
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.3 Archiver moodledata
|
### 4.3 Archiver moodledata
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Exclure cache, sessions, temp
|
# Créer l'archive depuis le pod source
|
||||||
tar -czf moodledata_backup_$(date +%Y%m%d_%H%M%S).tar.gz \
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- tar -czf /tmp/moodledata_backup.tar.gz \
|
||||||
--exclude='cache/*' \
|
--exclude='cache/*' \
|
||||||
--exclude='sessions/*' \
|
--exclude='sessions/*' \
|
||||||
--exclude='temp/*' \
|
--exclude='temp/*' \
|
||||||
--exclude='trashdir/*' \
|
--exclude='trashdir/*' \
|
||||||
--exclude='localcache/*' \
|
--exclude='localcache/*' \
|
||||||
-C /var moodledata
|
-C /bitnami moodledata
|
||||||
|
|
||||||
# Vérifier la taille
|
# Copier l'archive vers le poste local
|
||||||
|
kubectl cp ${SOURCE_NS}/${SOURCE_DEPLOY}:/tmp/moodledata_backup.tar.gz ./moodledata_backup_$(date +%Y%m%d_%H%M%S).tar.gz
|
||||||
|
|
||||||
|
# Vérifier
|
||||||
ls -lh moodledata_backup_*.tar.gz
|
ls -lh moodledata_backup_*.tar.gz
|
||||||
|
|
||||||
# Checksum
|
# Checksum
|
||||||
sha256sum moodledata_backup_*.tar.gz > moodledata.sha256
|
sha256sum moodledata_backup_*.tar.gz > moodledata.sha256
|
||||||
|
|
||||||
|
# Nettoyer le fichier temporaire dans le pod
|
||||||
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- rm /tmp/moodledata_backup.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4.4 Sauvegarder plugins custom
|
**Alternative : Extraction directe (gros volumes)**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -czf moodle_plugins_$(date +%Y%m%d).tar.gz \
|
# Streamer directement sans fichier intermédiaire
|
||||||
-C /var/www/moodle \
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- tar -czf - \
|
||||||
|
--exclude='cache/*' \
|
||||||
|
--exclude='sessions/*' \
|
||||||
|
--exclude='temp/*' \
|
||||||
|
--exclude='trashdir/*' \
|
||||||
|
--exclude='localcache/*' \
|
||||||
|
-C /bitnami moodledata > moodledata_backup_$(date +%Y%m%d_%H%M%S).tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4.4 Sauvegarder plugins custom (si nécessaire)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- tar -czf /tmp/plugins.tar.gz \
|
||||||
|
-C /bitnami/moodle \
|
||||||
local/ \
|
local/ \
|
||||||
theme/ \
|
theme/
|
||||||
mod/ \
|
|
||||||
blocks/ \
|
kubectl cp ${SOURCE_NS}/${SOURCE_DEPLOY}:/tmp/plugins.tar.gz ./moodle_plugins_$(date +%Y%m%d).tar.gz
|
||||||
auth/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. Phase 4 : Transfert et restauration
|
## 5. Phase 4 : Transfert et restauration
|
||||||
|
|
||||||
### 5.1 Transfert des fichiers
|
### 5.1 Variables cibles
|
||||||
|
|
||||||
**Option A : Via MinIO (recommandé pour gros volumes)**
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sur le serveur source
|
# ADAPTER selon l'université
|
||||||
|
UNIVERSITY="unstim"
|
||||||
|
TARGET_NS="moodle-${UNIVERSITY}"
|
||||||
|
TARGET_DEPLOY="moodle-${UNIVERSITY}"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5.2 Transfert via MinIO (recommandé)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Configurer MinIO
|
||||||
mc alias set rber http://minio.rber.bj:9000 ACCESS_KEY SECRET_KEY
|
mc alias set rber http://minio.rber.bj:9000 ACCESS_KEY SECRET_KEY
|
||||||
|
|
||||||
|
# Créer le bucket
|
||||||
mc mb rber/migrations/${UNIVERSITY}
|
mc mb rber/migrations/${UNIVERSITY}
|
||||||
mc cp moodle_dump_*.gz rber/migrations/${UNIVERSITY}/
|
|
||||||
|
# Upload
|
||||||
|
mc cp moodle_dump_*.dump rber/migrations/${UNIVERSITY}/
|
||||||
mc cp moodledata_backup_*.tar.gz rber/migrations/${UNIVERSITY}/
|
mc cp moodledata_backup_*.tar.gz rber/migrations/${UNIVERSITY}/
|
||||||
|
mc cp moodledata.sha256 rber/migrations/${UNIVERSITY}/
|
||||||
|
|
||||||
|
# Vérifier
|
||||||
|
mc ls rber/migrations/${UNIVERSITY}/
|
||||||
```
|
```
|
||||||
|
|
||||||
**Option B : SCP direct**
|
### 5.3 Restaurer la base de données
|
||||||
|
|
||||||
|
**PostgreSQL → PostgreSQL :**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scp moodle_dump_*.gz admin@10.29.112.130:/tmp/migration/
|
# Port-forward vers le cluster PG cible
|
||||||
scp moodledata_backup_*.tar.gz admin@10.29.112.130:/tmp/migration/
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5.2 Conversion MySQL → PostgreSQL (si nécessaire)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Installer pgloader
|
|
||||||
sudo apt-get install -y pgloader
|
|
||||||
|
|
||||||
# Créer le fichier de configuration
|
|
||||||
cat > migration.load << 'EOF'
|
|
||||||
LOAD DATABASE
|
|
||||||
FROM mysql://user:password@source-server:3306/moodle
|
|
||||||
INTO postgresql://moodle:password@edu-pg-main-rw.shared.svc.cluster.local:5432/moodle
|
|
||||||
|
|
||||||
WITH include drop, create tables, create indexes, reset sequences
|
|
||||||
|
|
||||||
CAST type datetime to timestamp using zero-dates-to-null,
|
|
||||||
type date using zero-dates-to-null
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Exécuter (peut prendre plusieurs heures)
|
|
||||||
pgloader migration.load
|
|
||||||
```
|
|
||||||
|
|
||||||
**Ou import direct PostgreSQL → PostgreSQL :**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Port-forward vers le cluster PG
|
|
||||||
kubectl port-forward -n shared svc/edu-pg-main-rw 5432:5432 &
|
kubectl port-forward -n shared svc/edu-pg-main-rw 5432:5432 &
|
||||||
|
|
||||||
# Restaurer
|
# Restaurer
|
||||||
pg_restore -h localhost -U moodle -d moodle moodle_dump_*.dump
|
pg_restore -h localhost -U moodle -d moodle --no-owner --no-acl moodle_dump_*.dump
|
||||||
|
|
||||||
|
# Arrêter le port-forward
|
||||||
|
kill %1
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.3 Restaurer moodledata
|
**Ou directement dans le pod PostgreSQL :**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copier le dump dans le pod PG
|
||||||
|
kubectl cp moodle_dump_*.dump shared/edu-pg-main-1:/tmp/
|
||||||
|
|
||||||
|
# Restaurer
|
||||||
|
kubectl exec -n shared edu-pg-main-1 -- pg_restore -U postgres -d moodle --no-owner /tmp/moodle_dump.dump
|
||||||
|
|
||||||
|
# Nettoyer
|
||||||
|
kubectl exec -n shared edu-pg-main-1 -- rm /tmp/moodle_dump.dump
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5.4 Restaurer moodledata
|
||||||
|
|
||||||
**Méthode recommandée avec suivi de progression :**
|
**Méthode recommandée avec suivi de progression :**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Avec pv pour voir la progression
|
# Avec pv pour voir la progression
|
||||||
pv moodledata_backup_*.tar.gz | kubectl exec -i -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- tar -xzf - -C /bitnami/moodledata --strip-components=1 --no-same-owner
|
pv moodledata_backup_*.tar.gz | kubectl exec -i -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- tar -xzf - -C /bitnami/moodledata --strip-components=1 --no-same-owner
|
||||||
|
```
|
||||||
|
|
||||||
# Sans pv
|
**Sans pv :**
|
||||||
cat moodledata_backup_*.tar.gz | kubectl exec -i -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- tar -xzf - -C /bitnami/moodledata --strip-components=1 --no-same-owner
|
|
||||||
|
```bash
|
||||||
|
cat moodledata_backup_*.tar.gz | kubectl exec -i -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- tar -xzf - -C /bitnami/moodledata --strip-components=1 --no-same-owner
|
||||||
```
|
```
|
||||||
|
|
||||||
**Suivre la progression (autre terminal) :**
|
**Suivre la progression (autre terminal) :**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
watch -n 5 'kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- du -sh /bitnami/moodledata'
|
watch -n 5 "kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- du -sh /bitnami/moodledata"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.4 Corriger les permissions
|
### 5.5 Corriger les permissions
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- chown -R 1001:1001 /bitnami/moodledata
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- chown -R 1001:1001 /bitnami/moodledata
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- chmod -R 755 /bitnami/moodledata
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- chmod -R 755 /bitnami/moodledata
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -446,50 +473,60 @@ kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- chmod -R 755 /bitnam
|
|||||||
**⚠️ Point critique** - Un config.php mal configuré casse l'affichage (CSS non chargé).
|
**⚠️ Point critique** - Un config.php mal configuré casse l'affichage (CSS non chargé).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -i -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- bash -c 'cat > /bitnami/moodle/config.php' << 'EOF'
|
# ADAPTER les valeurs selon l'université
|
||||||
|
UNIVERSITY="unstim"
|
||||||
|
TARGET_NS="moodle-${UNIVERSITY}"
|
||||||
|
TARGET_DEPLOY="moodle-${UNIVERSITY}"
|
||||||
|
TARGET_URL="elearningum.rber.bj" # Adapter selon université
|
||||||
|
DB_HOST="edu-pg-main-rw.shared.svc.cluster.local"
|
||||||
|
DB_NAME="moodle"
|
||||||
|
DB_USER="moodle"
|
||||||
|
DB_PASS="MOT_DE_PASSE"
|
||||||
|
|
||||||
|
kubectl exec -i -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- bash -c 'cat > /bitnami/moodle/config.php' << EOF
|
||||||
<?php // Moodle configuration file
|
<?php // Moodle configuration file
|
||||||
unset($CFG);
|
unset(\$CFG);
|
||||||
global $CFG;
|
global \$CFG;
|
||||||
$CFG = new stdClass();
|
\$CFG = new stdClass();
|
||||||
|
|
||||||
// === DATABASE ===
|
// === DATABASE ===
|
||||||
$CFG->dbtype = 'pgsql';
|
\$CFG->dbtype = 'pgsql';
|
||||||
$CFG->dblibrary = 'native';
|
\$CFG->dblibrary = 'native';
|
||||||
$CFG->dbhost = 'edu-pg-main-rw.shared.svc.cluster.local'; // Adapter si base dédiée
|
\$CFG->dbhost = '${DB_HOST}';
|
||||||
$CFG->dbname = 'moodle'; // Adapter : moodle_uac, moodle_una, etc.
|
\$CFG->dbname = '${DB_NAME}';
|
||||||
$CFG->dbuser = 'moodle'; // Adapter
|
\$CFG->dbuser = '${DB_USER}';
|
||||||
$CFG->dbpass = 'MOT_DE_PASSE'; // Adapter
|
\$CFG->dbpass = '${DB_PASS}';
|
||||||
$CFG->prefix = 'mdl_';
|
\$CFG->prefix = 'mdl_';
|
||||||
$CFG->dboptions = array(
|
\$CFG->dboptions = array(
|
||||||
'dbpersist' => 0,
|
'dbpersist' => 0,
|
||||||
'dbport' => 5432,
|
'dbport' => 5432,
|
||||||
'dbsocket' => '',
|
'dbsocket' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
// === URL ===
|
// === URL ===
|
||||||
if (empty($_SERVER['HTTP_HOST'])) {
|
if (empty(\$_SERVER['HTTP_HOST'])) {
|
||||||
$_SERVER['HTTP_HOST'] = '127.0.0.1:8080';
|
\$_SERVER['HTTP_HOST'] = '127.0.0.1:8080';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Détection automatique HTTP/HTTPS
|
// Détection automatique HTTP/HTTPS
|
||||||
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
|
if (isset(\$_SERVER['HTTPS']) && \$_SERVER['HTTPS'] == 'on') {
|
||||||
$CFG->wwwroot = 'https://elearningXX.rber.bj'; // Adapter XX
|
\$CFG->wwwroot = 'https://${TARGET_URL}';
|
||||||
} else {
|
} else {
|
||||||
$CFG->wwwroot = 'http://elearningXX.rber.bj'; // Adapter XX
|
\$CFG->wwwroot = 'http://${TARGET_URL}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// === PATHS ===
|
// === PATHS ===
|
||||||
$CFG->dataroot = '/bitnami/moodledata';
|
\$CFG->dataroot = '/bitnami/moodledata';
|
||||||
$CFG->admin = 'admin';
|
\$CFG->admin = 'admin';
|
||||||
$CFG->directorypermissions = 02775;
|
\$CFG->directorypermissions = 02775;
|
||||||
|
|
||||||
// === PERFORMANCE (optionnel) ===
|
// === PERFORMANCE ===
|
||||||
$CFG->cachejs = true;
|
\$CFG->cachejs = true;
|
||||||
$CFG->langstringcache = true;
|
\$CFG->langstringcache = true;
|
||||||
|
|
||||||
// === PROXY SETTINGS (si derrière HAProxy) ===
|
// === PROXY SETTINGS (derrière HAProxy) ===
|
||||||
$CFG->reverseproxy = true;
|
\$CFG->reverseproxy = true;
|
||||||
$CFG->sslproxy = true; // Si HTTPS terminé au niveau ingress
|
\$CFG->sslproxy = true;
|
||||||
|
|
||||||
require_once(__DIR__ . '/lib/setup.php');
|
require_once(__DIR__ . '/lib/setup.php');
|
||||||
EOF
|
EOF
|
||||||
@@ -498,22 +535,23 @@ EOF
|
|||||||
### 6.2 Purger les caches
|
### 6.2 Purger les caches
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/admin/cli/purge_caches.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php /bitnami/moodle/admin/cli/purge_caches.php
|
||||||
```
|
```
|
||||||
|
|
||||||
### 6.3 Mettre à jour les URLs dans la base
|
### 6.3 Mettre à jour les URLs dans la base
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/admin/cli/replace.php \
|
# Remplacer l'ancienne URL par la nouvelle
|
||||||
--search="http://elearning.ANCIEN-DOMAINE.bj" \
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php /bitnami/moodle/admin/cli/replace.php \
|
||||||
--replace="https://elearningXX.rber.bj" \
|
--search="http://ANCIEN-DOMAINE" \
|
||||||
|
--replace="https://${TARGET_URL}" \
|
||||||
--non-interactive
|
--non-interactive
|
||||||
```
|
```
|
||||||
|
|
||||||
### 6.4 Exécuter les mises à jour de base
|
### 6.4 Exécuter les mises à jour de base
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/admin/cli/upgrade.php --non-interactive
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php /bitnami/moodle/admin/cli/upgrade.php --non-interactive
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -682,7 +720,7 @@ Si le client n'existe pas encore dans Keycloak :
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Compter les utilisateurs
|
# Compter les utilisateurs
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php -r "
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php -r "
|
||||||
require('/bitnami/moodle/config.php');
|
require('/bitnami/moodle/config.php');
|
||||||
global \$DB;
|
global \$DB;
|
||||||
echo 'Utilisateurs actifs: ' . \$DB->count_records('user', ['deleted' => 0]) . PHP_EOL;
|
echo 'Utilisateurs actifs: ' . \$DB->count_records('user', ['deleted' => 0]) . PHP_EOL;
|
||||||
@@ -712,13 +750,14 @@ elearningXX.rber.bj. IN A 10.29.112.100 ; IP HAProxy VIP
|
|||||||
elearning.UNIVERSITY.bj. IN CNAME elearningXX.rber.bj.
|
elearning.UNIVERSITY.bj. IN CNAME elearningXX.rber.bj.
|
||||||
```
|
```
|
||||||
|
|
||||||
### 8.5 Désactiver la maintenance sur l'ancien serveur
|
### 8.5 Désactiver la maintenance sur le pod source
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Sur l'ancien serveur (si toujours accessible)
|
# Désactiver la maintenance
|
||||||
sudo -u www-data php /var/www/moodle/admin/cli/maintenance.php --disable
|
kubectl exec -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} -- php /bitnami/moodle/admin/cli/maintenance.php --disable
|
||||||
|
|
||||||
# Ou éteindre l'ancien serveur après validation complète
|
# Ou si l'ancien pod n'est plus nécessaire, le scaler à 0
|
||||||
|
kubectl scale -n ${SOURCE_NS} deploy/${SOURCE_DEPLOY} --replicas=0
|
||||||
```
|
```
|
||||||
|
|
||||||
### 8.6 Communication aux utilisateurs
|
### 8.6 Communication aux utilisateurs
|
||||||
@@ -745,20 +784,27 @@ Support : support@rber.bj
|
|||||||
|
|
||||||
## 9. Troubleshooting
|
## 9. Troubleshooting
|
||||||
|
|
||||||
|
> **Note :** Dans toutes les commandes ci-dessous, utiliser les variables définies :
|
||||||
|
> ```bash
|
||||||
|
> UNIVERSITY="unstim" # Adapter
|
||||||
|
> TARGET_NS="moodle-${UNIVERSITY}"
|
||||||
|
> TARGET_DEPLOY="moodle-${UNIVERSITY}"
|
||||||
|
> ```
|
||||||
|
|
||||||
### 9.1 CSS ne charge pas (page sans style)
|
### 9.1 CSS ne charge pas (page sans style)
|
||||||
|
|
||||||
**Cause :** `wwwroot` incorrect dans config.php
|
**Cause :** `wwwroot` incorrect dans config.php
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier
|
# Vérifier
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- grep wwwroot /bitnami/moodle/config.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- grep wwwroot /bitnami/moodle/config.php
|
||||||
|
|
||||||
# Le protocole (http/https) doit correspondre à l'URL utilisée
|
# Le protocole (http/https) doit correspondre à l'URL utilisée
|
||||||
# Corriger si nécessaire
|
# Corriger si nécessaire
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- sed -i "s|http://|https://|g" /bitnami/moodle/config.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- sed -i "s|http://|https://|g" /bitnami/moodle/config.php
|
||||||
|
|
||||||
# Purger le cache
|
# Purger le cache
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/admin/cli/purge_caches.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php /bitnami/moodle/admin/cli/purge_caches.php
|
||||||
|
|
||||||
# Vider le cache du navigateur : Ctrl+Shift+R
|
# Vider le cache du navigateur : Ctrl+Shift+R
|
||||||
```
|
```
|
||||||
@@ -767,81 +813,81 @@ kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier la connectivité
|
# Vérifier la connectivité
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php -r "
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php -r "
|
||||||
\$conn = pg_connect('host=edu-pg-main-rw.shared.svc.cluster.local port=5432 dbname=moodle user=moodle password=XXX');
|
\$conn = pg_connect('host=edu-pg-main-rw.shared.svc.cluster.local port=5432 dbname=moodle user=moodle password=XXX');
|
||||||
if (\$conn) { echo 'DB OK'.PHP_EOL; } else { echo 'DB FAIL'.PHP_EOL; }
|
if (\$conn) { echo 'DB OK'.PHP_EOL; } else { echo 'DB FAIL'.PHP_EOL; }
|
||||||
"
|
"
|
||||||
|
|
||||||
# Vérifier les credentials dans config.php
|
# Vérifier les credentials dans config.php
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- grep -E "dbhost|dbname|dbuser|dbpass" /bitnami/moodle/config.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- grep -E "dbhost|dbname|dbuser|dbpass" /bitnami/moodle/config.php
|
||||||
```
|
```
|
||||||
|
|
||||||
### 9.3 Erreur 502 Bad Gateway
|
### 9.3 Erreur 502 Bad Gateway
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier le pod
|
# Vérifier le pod
|
||||||
kubectl get pods -n ${NAMESPACE}
|
kubectl get pods -n ${TARGET_NS}
|
||||||
kubectl logs -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} --tail=50
|
kubectl logs -n ${TARGET_NS} deploy/${TARGET_DEPLOY} --tail=50
|
||||||
|
|
||||||
# Vérifier l'ingress
|
# Vérifier l'ingress
|
||||||
kubectl get ingress -n ${NAMESPACE}
|
kubectl get ingress -n ${TARGET_NS}
|
||||||
kubectl describe ingress -n ${NAMESPACE}
|
kubectl describe ingress -n ${TARGET_NS}
|
||||||
|
|
||||||
# Vérifier le service
|
# Vérifier le service
|
||||||
kubectl get svc -n ${NAMESPACE}
|
kubectl get svc -n ${TARGET_NS}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 9.4 Fichiers non accessibles
|
### 9.4 Fichiers non accessibles
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier les permissions
|
# Vérifier les permissions
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- ls -la /bitnami/moodledata/
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- ls -la /bitnami/moodledata/
|
||||||
|
|
||||||
# Corriger
|
# Corriger
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- chown -R 1001:1001 /bitnami/moodledata
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- chown -R 1001:1001 /bitnami/moodledata
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- chmod -R 755 /bitnami/moodledata
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- chmod -R 755 /bitnami/moodledata
|
||||||
```
|
```
|
||||||
|
|
||||||
### 9.5 rberConnect ne fonctionne pas
|
### 9.5 rberConnect ne fonctionne pas
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Vérifier que OAuth2 est activé
|
# Vérifier que OAuth2 est activé
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- php /bitnami/moodle/admin/cli/cfg.php --name=auth
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- php /bitnami/moodle/admin/cli/cfg.php --name=auth
|
||||||
|
|
||||||
# Tester la connectivité vers Keycloak
|
# Tester la connectivité vers Keycloak
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- curl -I https://auth.rber.bj/realms/rber/.well-known/openid-configuration
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- curl -I https://auth.rber.bj/realms/rber/.well-known/openid-configuration
|
||||||
|
|
||||||
# Vérifier les logs
|
# Vérifier les logs
|
||||||
kubectl logs -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} | grep -i oauth
|
kubectl logs -n ${TARGET_NS} deploy/${TARGET_DEPLOY} | grep -i oauth
|
||||||
```
|
```
|
||||||
|
|
||||||
### 9.6 Pod en CrashLoopBackOff
|
### 9.6 Pod en CrashLoopBackOff
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Voir les logs du pod précédent
|
# Voir les logs du pod précédent
|
||||||
kubectl logs -n ${NAMESPACE} -l app.kubernetes.io/name=moodle --previous
|
kubectl logs -n ${TARGET_NS} -l app.kubernetes.io/name=moodle --previous
|
||||||
|
|
||||||
# Vérifier les events
|
# Vérifier les events
|
||||||
kubectl get events -n ${NAMESPACE} --sort-by='.lastTimestamp' | tail -20
|
kubectl get events -n ${TARGET_NS} --sort-by='.lastTimestamp' | tail -20
|
||||||
|
|
||||||
# Vérifier les ressources
|
# Vérifier les ressources
|
||||||
kubectl describe pod -n ${NAMESPACE} -l app.kubernetes.io/name=moodle
|
kubectl describe pod -n ${TARGET_NS} -l app.kubernetes.io/name=moodle
|
||||||
```
|
```
|
||||||
|
|
||||||
### 9.7 Commandes de diagnostic générales
|
### 9.7 Commandes de diagnostic générales
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# État général
|
# État général
|
||||||
kubectl get all -n ${NAMESPACE}
|
kubectl get all -n ${TARGET_NS}
|
||||||
|
|
||||||
# Logs en temps réel
|
# Logs en temps réel
|
||||||
kubectl logs -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -f
|
kubectl logs -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -f
|
||||||
|
|
||||||
# Entrer dans le pod
|
# Entrer dans le pod
|
||||||
kubectl exec -it -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- bash
|
kubectl exec -it -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- bash
|
||||||
|
|
||||||
# Vérifier le config.php complet
|
# Vérifier le config.php complet
|
||||||
kubectl exec -n ${NAMESPACE} deploy/moodle-${UNIVERSITY} -- cat /bitnami/moodle/config.php
|
kubectl exec -n ${TARGET_NS} deploy/${TARGET_DEPLOY} -- cat /bitnami/moodle/config.php
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user