Guide to Installing and Configuring Grafana on AWS EC2 with MySQL Database Integration
Section 01: Setting Ip AWS EC2 Instances
Section 02: Configuring Security Groups in AWS
Grafana Server Details:
Public IP: 54.67.123.98
Private IP: 172.10.8.1
MySQL Server Details:
Public IP: 54.128.34.56
Private IP: 172.10.8.2
HTTP 80 172.0.0.0/8
HTTPS 443 172.0.0.0/8
Custom TCP 3000 172.0.0.0/8
MySQL 3306 172.0.0.0/8
Section 03: Installing Grafana Cloud on the EC2 Server
Here I’m using the Amazon Linux 2023 server and I’m going to install Grafana OSS.
To install Grafana from the RPM repository, complete the following steps
1.1 Import the GPD key:
# wget -q -O gpg.key https://rpm.grafana.com/gpg.key
# sudo rpm --import gpg.key
1.2 Create /etc/yum.repos.d/grafana.repo with the following content
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
1.3 To prevent beta versions from being installed, add the following exclude line to your .repo file
exclude=*beta*
1.4 To install Grafana OSS, run the following command
# sudo dnf install Grafana
2.1 Start the Grafana server with systemd
# sudo systemctl daemon-reload
# sudo systemctl start grafana-server
# sudo systemctl status grafana-server
2.2 To verify the service is running, run the following command
# sudo systemctl status grafana-server
To sign in to Grafana for the first time, follow the steps:
3.1 Open your web browser and go to http://your_public_ip:3000
3.2 On the sign-in page use ‘admin’ for the username and password
3.3 Click sign in and change the password.
Section 04: Create a Connection Between Grafana Server and MySQL Server
Here I have an AWS EC2 RedHat server that installed MySQL.
mysql> create user ‘grafana’@Grafana_server_private_IP’ identified by 'password';
mysql> grant all privileges on database_name.* to ‘grafana’@Grafana_server_private_IP’;
mysql> flush privileges;
Section 05: Create a Data source in Grafana