Pemecahan Masalah
Panduan mengatasi masalah umum pada server ujian.
Service Tidak Jalan
Nginx gagal start
# Cek error
systemctl status nginx
nginx -t
# Error umum: "port already in use"
lsof -i :80
lsof -i :443
# Kill proses yang menggunakan port tersebut
# Error umum: "SSL certificate not found"
ls -la /etc/nginx/ssl/
# Pastikan file .crt dan .key ada dan readable
PHP-FPM gagal start
# Cek error
systemctl status php8.3-fpm
journalctl -u php8.3-fpm --no-pager -n 50
# Error umum: "pool ujian cannot get uid"
id www-data
# Jika user tidak ada: apt install nginx (creates www-data)
# Error umum: "unable to bind listening socket"
ls -la /run/php/
# Pastikan direktori /run/php/ ada
mkdir -p /run/php && chown www-data:www-data /run/php
MariaDB gagal start
# Cek error
systemctl status mariadb
journalctl -u mariadb --no-pager -n 50
# Error umum: disk penuh
df -h /var/lib/mysql/
# Bersihkan disk atau expand partition
# Error umum: InnoDB corruption
# JANGAN hapus ib_logfile* sembarangan
# Backup dulu, lalu:
examtool backup-db
Memcached gagal start
systemctl status memcached
# Biasanya masalah port conflict atau RAM tidak cukup
free -m
Masalah Koneksi
Tidak bisa akses dari browser
- Cek DNS:
nslookup ujian.fk.example.ac.id - Cek firewall:
ufw status - Cek nginx:
systemctl status nginx - Cek SSL:
openssl s_client -connect ujian.fk.example.ac.id:443 - Cek log:
tail -20 /var/log/nginx/ujian_error.log
ERR_CONNECTION_REFUSED
- Port 443 tidak dibuka di firewall
- Nginx tidak running
- Cek:
ufw allow 443/tcp && systemctl restart nginx
ERR_SSL_PROTOCOL_ERROR
- Certificate dan key tidak match
- Certificate expired
- Cek:
openssl x509 -in /etc/nginx/ssl/ujian.crt -noout -dates
502 Bad Gateway
- PHP-FPM tidak running
- Socket file missing
- Cek:
systemctl restart php8.3-fpm - Cek:
ls -la /run/php/php8.3-fpm-ujian.sock
504 Gateway Timeout
- PHP script timeout (query berat)
- Cek slow query:
tail -20 /var/log/mysql/slow-query.log - Tambah timeout sementara di nginx config
Masalah Database
Koneksi database gagal
# Test login manual
mysql -u usr_kedokteran -p cbt_kedokteran
# Cek MariaDB running
systemctl status mariadb
# Cek socket
ls -la /run/mysqld/mysqld.sock
# Reset password jika lupa
examtool reconfigure
Database lambat
# Cek slow queries
tail -50 /var/log/mysql/slow-query.log
# Cek table lock
mysql -e "SHOW PROCESSLIST;"
# Cek ukuran database
mysql -e "SELECT table_schema, ROUND(SUM(data_length+index_length)/1024/1024,2) AS 'Size (MB)' FROM information_schema.tables GROUP BY table_schema;"
Backup/Restore
# Backup
examtool backup-db
# File tersimpan di /var/backups/examtool/
# Restore
examtool restore-db --file=/var/backups/examtool/backup_2024xxxx.sql.gz
Masalah Performa
Server lambat saat ujian
- Cek resource:
examtool status - Cek RAM:
free -m— jika swap terpakai banyak, RAM kurang - Cek CPU:
top— cek proses yang paling banyak makan CPU - Cek disk I/O:
iostat -x 1 5 - Cek koneksi:
ss -s— berapa total koneksi aktif
OOM Killer
Jika server tiba-tiba mati/restart:
dmesg | grep -i "oom\|out of memory"
journalctl -k | grep -i oom
Solusi:
- Kurangi jumlah client di konfigurasi
- Tambah RAM server
- Atau switch ke tier yang lebih kecil
Memcached tidak efektif
# Cek hit ratio
echo "stats" | nc localhost 11211 | grep -E "get_hits|get_misses"
# Hit ratio < 80% → cek konfigurasi cache di aplikasi
Masalah SSL
Certificate expired
# Cek expiry
openssl x509 -in /etc/nginx/ssl/ujian.crt -noout -dates
# Ganti certificate
cp /path/to/new.crt /etc/nginx/ssl/ujian.crt
cp /path/to/new.key /etc/nginx/ssl/ujian.key
nginx -t && systemctl reload nginx
Certificate chain tidak lengkap
Browser menunjukkan "Not Secure" meski certificate valid:
# Gabungkan certificate dengan chain
cat ujian.crt intermediate.crt > ujian-fullchain.crt
cp ujian-fullchain.crt /etc/nginx/ssl/ujian.crt
systemctl reload nginx
Masalah Fail2ban
IP admin ter-ban
# Cek IP yang di-ban
fail2ban-client status nginx-req-limit
# Unban IP
fail2ban-client set nginx-req-limit unbanip 192.168.1.100
# Whitelist IP di jail config
# Tambahkan ke ignoreip di /etc/fail2ban/jail.d/examtool.conf
Terlalu banyak false positive
Edit /etc/fail2ban/jail.d/examtool.conf:
- Naikkan
maxretry - Turunkan
bantime - Tambahkan IP range ke
ignoreip
Kemudian: systemctl restart fail2ban
Command Diagnostik
Kumpulan command untuk troubleshooting cepat:
# Status lengkap
examtool status
# Semua log error nginx (1 jam terakhir)
find /var/log/nginx/ -name "*error*" -mmin -60 -exec tail -20 {} \;
# Koneksi aktif
ss -tuanp | grep -E ":80|:443" | wc -l
# Disk usage
du -sh /var/www/* /var/lib/mysql/ /var/log/
# Proses PHP aktif
ps aux | grep php-fpm | grep -v grep | wc -l
# Restart semua service
systemctl restart nginx php8.3-fpm mariadb memcached