Nutanix_Home_Lab_HLD_8_Database - itnett/FTD02H-N GitHub Wiki
For å integrere temaet "Database" i din eksisterende Nutanix CE-lab, kan vi opprette et miljø som fokuserer på databasesystemer, SQL, normalisering, sikkerhet, og backup/restore-prosedyrer. Dette vil inkludere oppsett av dedikerte servere for MySQL, datavisualisering, og sikkerhetspraksiser som kryptering og brukeradministrasjon.
Vi vil introdusere et VLAN spesielt dedikert til databaser og datavisualisering. Dette vil gi et fokusert miljø for å praktisere databaseadministrasjon og sikkerhet.
VLAN ID | Nettverk | IP-adresseplan | Bruk |
---|---|---|---|
VLAN 600 | Database Network | 10.2.0.0/24 | Nettverk dedikert til databaseadministrasjon og sikkerhet |
VLAN 610 | Data Visualization | 10.2.1.0/24 | Nettverk dedikert til datavisualisering |
For databasetemaet, vil vi opprette flere servere dedikert til databaseadministrasjon, datavisualisering, og sikkerhetspraksis som kryptering og backup/restore.
Domene | Servernavn | Rolle | VLAN | IP Address | Ressurser |
---|---|---|---|---|---|
db.local | DB-SERVER-01 | MySQL databaseadministrasjon og sikkerhet | VLAN 600 | 10.2.0.10 | vCPU: 4, RAM: 8GB, 100GB SSD |
backup.local | BACKUP-SERVER-01 | Backup og Restore-tjenester | VLAN 600 | 10.2.0.20 | vCPU: 4, RAM: 4GB, 100GB SSD |
visualization.local | VISUAL-SERVER-01 | Datavisualisering (f.eks. Grafana) | VLAN 610 | 10.2.1.10 | vCPU: 4, RAM: 8GB, 100GB SSD |
Vi lager Blueprints i Nutanix Calm for hver server i de ulike domenene. Disse Blueprintene vil installere nødvendige verktøy og konfigurere miljøet ved oppstart.
Blueprint Details:
-
Name:
DB_SERVER_01
- Base Image: Minimal Ubuntu (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_db_server.sh
# Set Hostname
hostnamectl set-hostname "DB-SERVER-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.2.0.10/24" ipv4.gateway "10.2.0.1" ipv4.dns "10.2.0.1" ipv4.method manual
nmcli con up "System eth0"
# Install MySQL server
apt-get update -y
apt-get install -y mysql-server
# Secure MySQL installation
mysql_secure_installation
# Create a sample database
mysql -e "CREATE DATABASE sampledb;"
# Add a user with secure password
mysql -e "CREATE USER 'user'@'%' IDENTIFIED BY 'securepassword';"
mysql -e "GRANT ALL PRIVILEGES ON sampledb.* TO 'user'@'%';"
mysql -e "FLUSH PRIVILEGES;"
Blueprint Details:
-
Name:
BACKUP_SERVER_01
- Base Image: Minimal Ubuntu (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_backup_server.sh
# Set Hostname
hostnamectl set-hostname "BACKUP-SERVER-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.2.0.20/24" ipv4.gateway "10.2.0.1" ipv4.dns "10.2.0.1" ipv4.method manual
nmcli con up "System eth0"
# Install backup tools (e.g., Percona XtraBackup)
apt-get update -y
apt-get install -y percona-xtrabackup
# Configure daily backups
echo "0 2 * * * root xtrabackup --backup --target-dir=/var/backups/mysql/$(date +\%F) --datadir=/var/lib/mysql/ --user=root --password=securepassword" > /etc/cron.d/mysql-backup
Blueprint Details:
-
Name:
VISUAL_SERVER_01
- Base Image: Minimal Ubuntu (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_visual_server.sh
# Set Hostname
hostnamectl set-hostname "VISUAL-SERVER-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.2.1.10/24" ipv4.gateway "10.2.1.1" ipv4.dns "10.2.1.1" ipv4.method manual
nmcli con up "System eth0"
# Install Grafana for data visualization
apt-get update -y
apt-get install -y grafana
# Start Grafana service
systemctl start grafana-server
systemctl enable grafana-server
For å automatisere opprettelsen og styringen av databaserelaterte miljøer ved hjelp av Nutanix REST API, kan du bruke lignende trinn som tidligere nevnt.
curl -u "username:password" -X POST 'https://<prism_central_ip>:9440/api/nutanix/v3/login'
-
Opprett en MySQL database server:
curl -X POST https://<prism_central_ip>:9440/api/nutanix/v3/blueprints/<blueprint_uuid>/launch \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "spec": { "name": "DB_SERVER_DEPLOYMENT", "description": "Deployment of DB-SERVER-01", "app_profile_reference": { "kind": "app_profile", "uuid": "<app_profile_uuid>" }, "application_name": "DB-SERVER-01" } }'
curl -X DELETE https://<prism_central_ip>:9440/api/nutanix/v3/apps/<application_uuid> \
-H "Authorization: Bearer <token>"
For å overvåke og optimalisere ressursbruken når du kjører databasemiljøer:
-
Overvåk ressursbruk:
- Bruk Prism Central til å se CPU-, RAM-, og lagringsbruk for hver VM i sanntid.
- Identifiser potensielle flaskehalser eller underutnyttede ressurser.
-
Varsler og kapasitetsplanlegging:
- Sett opp varsler for å overvåke ressursbruk og sikre at ingen VM overskrider sine tildelte ressurser.
- Bruk Prism’s Capacity Runway-verktøy for å planlegge fremtidige utvidelser eller tilpasninger.
-
Optimaliser ressursbruk:
- Juster ressursallokering basert på bruken og læringsbehovene.
- Bruk automatisering i Calm for å justere ressurser dynamisk når miljøer startes og stoppes.
Overall Design:
- Network Segmentation: VLANs isolate different environments to prevent interference between labs and allow for specialized testing (e.g., database security).
- Resource Allocation: Each server is allocated sufficient CPU, memory, and storage resources based on the expected workload, ensuring smooth operation without overloading the rig.
- Security Measures: Each VLAN has built-in security measures like firewalls, ACLs, and encryption to replicate real-world database security scenarios.
- Automation and Management: Nutanix Calm and REST APIs are used to automate the deployment, configuration, and scaling of these environments.
Server Configuration and Deployment:
- Operating Systems: Most servers will run minimal Ubuntu, except for specialized environments like Grafana for visualization.
-
Network Configuration:
- Each server is connected to its specific VLAN through dedicated NICs (onboard NICs and USB
-to-NIC dongles).
- Static IP addresses are assigned to each server for consistent network configuration.
-
Software Installation:
- Servers are pre-configured with relevant software based on their role, such as MySQL on DB-SERVER-01, Percona XtraBackup on BACKUP-SERVER-01, or Grafana on VISUAL-SERVER-01.
-
Security Settings:
- Basic security configurations are applied to all servers, such as firewall rules, user access controls, and encryption for sensitive data.
- Backup and Restore: Backup routines are automated using cron jobs, and restore procedures are documented and tested regularly.
Managing Resources within the Rig's Limitations:
- CPU and Memory Allocation: The rig has 6 cores (12 threads) and 32GB of RAM. Not all servers will run simultaneously. Servers are grouped based on their use case, and only necessary servers are powered on depending on the lab scenario.
-
Storage Management:
- The Samsung 850 EVO 500GB SSD is used for high-speed storage of critical VMs.
- The additional HDDs (3x1.5TB and 1x4TB) are used for large data storage, logs, and backup purposes.
- Dynamic Resource Allocation: Nutanix Calm allows for the dynamic provisioning and de-provisioning of resources, ensuring optimal use of CPU and memory.
This setup provides a robust framework for studying and experimenting with various database management and security scenarios. It maximizes the use of your rig's capabilities while staying within its limitations, using VLANs, domains, and Nutanix's automation tools to create a flexible, dynamic lab environment.