πŸš€πŸ—„οΈ DevOps 3.2: Crafting DB, Cache, and Queue Setup πŸ’ΎπŸ”—

πŸš€πŸ—„οΈ DevOps 3.2: Crafting DB, Cache, and Queue Setup πŸ’ΎπŸ”—

"Database, Cache, and Queue Configuration: Building the Foundations of a Robust DevOps Ecosystem"

Β·

3 min read

Services:

  1. Nginx ===> Web Service

  2. Tomcat ===> Application Server

  3. RabbitMQ ===> Broker/Queuing Agent

  4. Memcache ===> DB caching

  5. MySQL ===> SQL Databases

Setup Order:

  1. MySQL

  2. Memcache

  3. RabbitMQ

  4. Tomcat

  5. 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 using systemctl enable mariadb .

  • Run mysql_secure_installation and answer the questions accordingly (all of it yes) - By running mysql_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:

    1. Run mysql -u root -padmin123 to get MySQL CLI.

    2. Now create database accounts using create database accounts;

    3. 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'.

    4. FLUSH PRIVILEGES; to reload then exit.

    5. 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.

    6. 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.

    7. Then login to accounts using mysql -u root -padmin123 accountsand enter the commands the show tables; to check the if all the data has been imported.

    8. Then exit the database and restart the MariaDB service and check the status.

  • Setup the Memcache service:

  1. Login into web01 using vagrant ssh mc01.

  2. Switch to root user using sudo -i.

  3. Then write the command dnf install epel-release -y and install Memcached using dnf install memcached -y.

  4. Start the Memcached service systemctl start memcached and enable it using systemctl enable memcached.

  5. 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.

  6. Now restart the service.

  • Setup the RabbitMQ:

  1. Login into the rabbitMQ service using vagrant ssh rmq01.

  2. Do sudo -i and do yum update -y.

  3. Now do yum install epel-release -y.

  4. Disable SELINUX on fedora

    1.  # sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
       # setenforce 0
      
    2. Install Dependencies

      1.  # 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
        
    3. Install Rabbitmq Server

      1.  # curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash 
         # sudo yum install rabbitmq-server -y
        
    4. Start & Enable RabbitMQ

      1.  # sudo systemctl start rabbitmq-server
         # sudo systemctl enable rabbitmq-server
         # sudo systemctl status rabbitmq-server
        
      2. 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
        
      3. 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
        

Now let's move to application setup!!!

Did you find this article valuable?

Support Saswat Samal by becoming a sponsor. Any amount is appreciated!

Β