Script automation lengkap untuk setup MongoDB cluster dengan web dashboard profesional untuk HR Management System.
- Instalasi Otomatis MongoDB di Rocky Linux 9
- Konfigurasi Replication Cluster dengan 3 node
- Generate Dummy Data HR lengkap dengan file media
- Web Dashboard Modern dengan fitur real-time monitoring
- Live Replication Status visual dengan grafik
- Log Monitoring real-time dari setiap node
- Query Interface untuk MongoDB langsung dari web
- SSH Console terintegrasi untuk setiap node
- Configuration Management dengan accounts.json
- Sistem Operasi: Rocky Linux 9
- Akses Root: Script harus dijalankan sebagai root
- SSH Access: Koneksi SSH tanpa password ke semua node
- Node Names: Pastikan hostname sudah dikonfigurasi:
hrmlabs-mongo-primaryhrmlabs-mongo-secondaryhrmlabs-mongo-analytics
# Download atau clone script
wget https://raw.githubusercontent.com/your-repo/hrmlabs-mongo-automation.sh
chmod +x hrmlabs-mongo-automation.sh# Generate SSH key jika belum ada
ssh-keygen -t rsa -b 4096 -C "hrmlabs-automation"
# Copy public key ke semua node
ssh-copy-id root@hrmlabs-mongo-primary
ssh-copy-id root@hrmlabs-mongo-secondary
ssh-copy-id root@hrmlabs-mongo-analytics# Jalankan sebagai root
sudo ./hrmlabs-mongo-automation.shScript akan otomatis melakukan:
- ✅ Install dependencies lokal
- ✅ Cek konektivitas SSH ke semua node
- ✅ Install MongoDB di setiap node (jika belum ada)
- ✅ Konfigurasi replication cluster
- ✅ Generate dan insert dummy data HR
- ✅ Setup web dashboard
- ✅ Validasi semua komponen
Script akan menghasilkan data lengkap untuk HR Management:
- 5 Perusahaan dengan informasi lengkap
- 100 Karyawan dengan data personal
- 5 Departemen (HR, IT, Finance, Marketing, Operations)
- 5 Posisi Jabatan dengan range gaji
- 1,500+ Record Absensi (30 hari terakhir)
- 50 Pengajuan Cuti dengan berbagai status
- 1,200 Record Payroll (12 bulan)
- 40+ File Dokumen (foto karyawan, kontrak) dalam format PNG/JPG
Setelah instalasi selesai, akses dashboard di:
http://localhost:3000
- Grafik visual status replica set
- Status health setiap node
- Informasi member replica set real-time
- View log MongoDB dari setiap node
- Auto-refresh setiap 10 detik
- Filter berdasarkan node
- Execute query MongoDB langsung dari web
- Support untuk semua node (primary/secondary/analytics)
- Syntax highlighting dan hasil formatted
- Akses SSH ke setiap node dari browser
- Execute command real-time
- History command dan output
- Load/save konfigurasi node
- Manage accounts.json
- Export data functionality
┌─────────────────────────────────────────────────────────────┐
│ HRM Labs MongoDB Cluster │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐ │
│ │ PRIMARY NODE │ │ SECONDARY NODE │ │ANALYTICS NODE│ │
│ │ │ │ │ │ │ │
│ │ hrmlabs-mongo- │◄─┤ hrmlabs-mongo- │◄─┤hrmlabs-mongo-│ │
│ │ primary:27017 │ │ secondary:27017 │ │analytics:27017│ │
│ │ │ │ │ │ │ │
│ │ Priority: 2 │ │ Priority: 1 │ │Priority: 0 │ │
│ │ Votes: 1 │ │ Votes: 1 │ │Hidden: true │ │
│ └─────────────────┘ └─────────────────┘ └──────────────┘ │
│ │
├─────────────────────────────────────────────────────────────┤
│ Replica Set: hrmlabsrs │
└─────────────────────────────────────────────────────────────┘
/workspace/
├── hrmlabs-mongo-automation.sh # Script utama
├── package.json # Dependencies Node.js
├── server.js # Web dashboard server
├── accounts.json # Konfigurasi node
├── dashboard.log # Log dashboard
├── generate_hr_data.py # Script generate data (temporary)
└── public/
└── index.html # Dashboard frontend
mongosh --host hrmlabs-mongo-primary:27017 --eval "rs.status()"tail -f /workspace/dashboard.logcd /workspace
npm start# Test SSH connectivity
ssh root@hrmlabs-mongo-primary "echo 'OK'"
ssh root@hrmlabs-mongo-secondary "echo 'OK'"
ssh root@hrmlabs-mongo-analytics "echo 'OK'"
# Test MongoDB connectivity
mongosh --host hrmlabs-mongo-primary:27017 --eval "db.runCommand('ping')"- Aktifkan Authentication MongoDB
- Setup SSL/TLS
- Konfigurasi Firewall
- Use Strong Passwords
- Setup Backup Strategy
db.employees.find().limit(5).pretty()db.attendance.aggregate([
{$group: {_id: "$status", count: {$sum: 1}}}
])db.payroll.find({month: 12, year: 2024}).limit(10)db.documents.find({document_type: "photo"}).limit(3)# Restart MongoDB service pada node bermasalah
ssh root@hrmlabs-mongo-primary "systemctl restart mongod"# Check port 3000
netstat -tulpn | grep :3000
# Restart dashboard
cd /workspace && npm start# Test SSH connectivity
ssh -v root@hrmlabs-mongo-primary
# Check SSH service
ssh root@hrmlabs-mongo-primary "systemctl status sshd"Untuk pertanyaan atau issue, silakan buat GitHub issue atau hubungi tim development.
© 2024 HRM Labs - MongoDB Automation Script