-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-data
More file actions
179 lines (170 loc) · 6.76 KB
/
user-data
File metadata and controls
179 lines (170 loc) · 6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
# Switch to root user
sudo su
# Fetch IMDSv2 Token
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
# Retrieve instance metadata using IMDSv2
PRIVATE_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4)
HOSTNAME=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/hostname)
# Update and install Apache (httpd)
yum update -y
yum install -y httpd.x86_64
# Start and enable Apache
systemctl start httpd.service
systemctl enable httpd.service
# Enable Server-Side Includes (SSI) in Apache
sed -i 's/#AddOutputFilter INCLUDES .shtml/AddOutputFilter INCLUDES .html/' /etc/httpd/conf/httpd.conf
sed -i 's/Options Indexes FollowSymLinks/Options Indexes FollowSymLinks Includes/' /etc/httpd/conf/httpd.conf
# Remove default Apache test page
rm -f /var/www/html/index.html /var/www/html/index.shtml
# Create the HTML file with instance details
cat << EOF > /var/www/html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>High Availability in Cloud Computing - Cloudboosta Training</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
min-height: 100vh;
background: linear-gradient(to bottom, #2c3e50, #3498db);
color: white;
display: flex;
flex-direction: column;
}
header {
text-align: center;
padding: 2rem;
}
.cloudboosta-banner {
background-color: #f39c12;
color: #2c3e50;
text-align: center;
padding: 0.5rem;
font-weight: bold;
}
main {
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem;
}
.hostname, .private-ip {
background-color: white;
color: black;
padding: 1rem 2rem;
border-radius: 8px;
font-size: 1.5rem;
margin-bottom: 1rem;
}
.refresh-instruction {
background-color: #e74c3c;
color: white;
padding: 0.5rem 1rem;
border-radius: 4px;
margin-bottom: 2rem;
text-align: center;
}
.info {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
width: 100%;
max-width: 1200px;
}
.info-section {
flex-basis: 45%;
margin-bottom: 2rem;
}
footer {
text-align: center;
padding: 1rem;
background-color: rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<div class="cloudboosta-banner">
Training Provided by Cloudboosta
</div>
<header>
<h1>High Availability in Cloud Computing</h1>
</header>
<main>
<div class="hostname">
Hostname: <!--#exec cmd="hostname -f" -->
</div>
<div class="private-ip">
Private IP: $PRIVATE_IP
</div>
<div class="refresh-instruction">
<strong>Refresh the page several times to see the Private IP change, demonstrating High Availability in action!</strong>
</div>
<div class="info">
<div class="info-section">
<h2>What is High Availability?</h2>
<p>High Availability (HA) in cloud computing refers to the ability of a system to remain operational and accessible even in the face of component failures. It ensures that services remain available to users with minimal downtime, typically aiming for 99.9% uptime or higher.</p>
</div>
<div class="info-section">
<h2>Benefits of High Availability</h2>
<ul>
<li>Minimized downtime and service interruptions</li>
<li>Improved user experience and satisfaction</li>
<li>Increased business continuity</li>
<li>Enhanced disaster recovery capabilities</li>
<li>Better resource utilization</li>
</ul>
</div>
<div class="info-section">
<h2>Implementation Strategies</h2>
<ul>
<li>Redundancy: Duplicate critical components</li>
<li>Load Balancing: Distribute traffic across multiple servers</li>
<li>Failover Systems: Automatic switching to backup systems</li>
<li>Data Replication: Maintain multiple copies of data across locations</li>
<li>Geographic Distribution: Deploy across multiple regions or availability zones</li>
</ul>
</div>
<div class="info-section">
<h2>Use Cases</h2>
<ul>
<li>E-commerce platforms ensuring 24/7 availability</li>
<li>Financial services requiring constant uptime</li>
<li>Healthcare systems with critical patient data</li>
<li>Global content delivery networks</li>
<li>SaaS applications with service level agreements (SLAs)</li>
</ul>
</div>
<div class="info-section">
<h2>Scaling Strategies</h2>
<ul>
<li>Vertical Scaling: Increasing the power of existing servers</li>
<li>Horizontal Scaling: Adding more servers to distribute load</li>
<li>Auto-scaling: Dynamically adjusting resources based on demand</li>
<li>Database Sharding: Partitioning data across multiple databases</li>
<li>Microservices Architecture: Breaking down applications into smaller, scalable services</li>
</ul>
</div>
<div class="info-section">
<h2>Monitoring and Management</h2>
<p>Implementing high availability requires continuous monitoring and management. Cloud providers offer tools for real-time monitoring, automated alerts, and performance analytics to ensure systems remain highly available and quickly recover from any issues.</p>
</div>
</div>
</main>
<footer>
<p>© 2025 High Availability in Cloud Computing Demo | Cloudboosta Training</p>
</footer>
</body>
</html>
EOF
# Set correct file permissions
chmod 644 /var/www/html/index.html
chown apache:apache /var/www/html/index.html
# Restart Apache to apply changes
systemctl restart httpd.service