πποΈ DevOps 3.2: Crafting DB, Cache, and Queue Setup πΎπ
"Database, Cache, and Queue Configuration: Building the Foundations of a Robust DevOps Ecosystem"
Services:
Nginx ===> Web Service
Tomcat ===> Application Server
RabbitMQ ===> Broker/Queuing Agent
Memcache ===> DB caching
MySQL ===> SQL Databases
Setup Order:
MySQL
Memcache
RabbitMQ
Tomcat
Nginx
Steps:
Log in to the database service that is db01 from the previous blog i.e.
vagrant ssh db01
.Then switch to the root user using
sudo -i
.Update the OS with latest patches using
yum update -y
.Install MariaDB and git using
yum install git mariadb-server -y
. Git is for cloning the source code.Start the MariaDB service using
systemctl start mariadb
and enable it usingsystemctl enable mariadb
.Run
mysql_secure_installation
and answer the questions accordingly (all of it yes) - By runningmysql_secure_installation
, you can ensure that your database server is configured with improved security settings, which is crucial for protecting sensitive data and preventing unauthorized access.Now lets set dbname and users:
Run
mysql -u root -padmin123
to get MySQL CLI.Now create database accounts using
create database accounts;
Now run
grant all privileges on accounts.* TO 'admin'@'%' identified by 'admin123' ;
- it provides full access and control over the 'accounts' database to the 'admin' user with the password 'admin123'.FLUSH PRIVILEGES
; to reload thenexit
.Then clone this repository repository in the db01 VM using the git clone command i.e.
git clone -b main
https://github.com/saswatsam786/devops-project-local
and then cd into the project.Then write this command
mysql -u root -padmin123 accounts < src/main/resources/db_backup.sql
- this command logs in to MySQL as the 'root' user with the password 'admin123' and imports the data from the 'db_backup.sql' file into the 'accounts' data.Then login to accounts using
mysql -u root -padmin123 accounts
and enter the commands theshow tables;
to check the if all the data has been imported.Then exit the database and restart the MariaDB service and check the status.
Setup the Memcache service:
Login into web01 using
vagrant ssh mc01
.Switch to root user using
sudo -i
.Then write the command
dnf install epel-release -y
and install Memcached usingdnf install memcached -y
.Start the Memcached service
systemctl start memcached
and enable it usingsystemctl enable memcached
.Now enter this command
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/sysconfig/memcached
- This command helps a connection between services which are running on different machines. It will allow connections from all IPs.Now restart the service.
Setup the RabbitMQ:
Login into the rabbitMQ service using
vagrant ssh rmq01
.Do sudo -i
and doyum update -y
.Now do
yum install epel-release -y
.Disable SELINUX on fedora
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # setenforce 0
Install Dependencies
# curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash # sudo yum clean all # sudo yum makecache # sudo yum install erlang -y
Install Rabbitmq Server
# curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash # sudo yum install rabbitmq-server -y
Start & Enable RabbitMQ
# sudo systemctl start rabbitmq-server # sudo systemctl enable rabbitmq-server # sudo systemctl status rabbitmq-server
Config Changes
# sudo sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config' # sudo rabbitmqctl add_user test test # sudo rabbitmqctl set_user_tags test administrator
For Fedora
# firewall-cmd --add-port=5671/tcp --permanent # firewall-cmd --add-port=5672/tcp --permanent # firewall-cmd --reload # sudo systemctl restart rabbitmq-server # reboot