How to Setup SonarQube with PostGRE SQL Database #aws #ec2 #sonarqube #postgresql #postgres

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to my channel AWS devops Niche 11 so in this video the topic what we are going to see is how to set up sonar Cube to connect with post gray SQL database okay so I had already posted a video on Sonar Cube few days before wherein I explained about what is sonar Cube what is its architecture and how to set up sonar Cube generally by default sonar Cube will use its default embedded database which is H2 and that is what I covered in my previous video on the sonar Cube so how to set up sonar Cube and how by default it connects to the default embedded database but however solar Cube also has the capability to support MySQL Oracle post gr SQL and Microsoft SQL Ser some of my subscribers had asked me to post a video on how do connect sonar Cube to the post gr SQL TV and that is a trigger for me to put this video so now let us go ahead and see how to set up sonar Cube and how do we connect it to the postr SQL database server so let us let's move ahead now this will be the sequence of our lab instructions first and foremost let us launch a t2. small EC to instance the next step will be to install Java next we will set up the post gray SQL database on the same instance and I'm typically going to use the Ubuntu Ubuntu operating system for this so I'll be selecting the btu Ami in AWS then once the database setup is complete we will go ahead and set up the sonar Cube application then we will verify if the sonar cube is working fine and if it is able to connect to the database without any issues so this will be the sequence of our lab instructions so now let us move ahead with our first step of launching the t2. small small easy to instance so why t2. small because sonar Cube would require minimum 2 GB of memory for its functioning so that is the reason we are directly going ahead and launching the t2. small type of E2 instance and I'm going to use the open 2 Ami to launch my instance so let me go into the AWS console so let us launch a open to instance here so I click launch instance and I'm going to name it as sonar QBE here let me select the ubo Ami and I will go ahead with the latest ub2 22.4 version of the operating system so instance type will be t2. small so you can see here this t2. small comes with one vual CPU on 2 gab of memory which is a prerequisite for sonar CU keare let me go ahead and select of my existing keypads and in the security group I will allow the SSH traffic from my IP address for now and then we will go ahead and launch the inst so now the instance is in the process of getting launched so meanwhile what I will do since solar cube is going to run on the port 9,000 let me go ahead and open that Port as well the security group so let me click the security group I go to the inbound rules edit inbound rules I will add a rule with custom TCP and the port number will be 9,000 right so I will select anywhere IP V4 let us have this rule ready because sonar cube is going to listen on the port 9,000 okay now the instance is in the running State let me connect to this instance I'll grab the IP address I will upload my private key just verify what was the key I used 11 12 20 22 okay looks like have the key here so let me try to create a new key I think I have only this 10 12 okay fine no issue so what I will do is let me go ahead and terminate this instance we quickly launch another instance selecting the other keypad so let me say launch instance Q select open to and here it will be T2 do for keeper let me go ahead and select the one which is 10 12 2023 and allow SSH from my IP address go ahead and launch the instance okay so while it is launching let me go to the security tab you think it is still loading the security grps let us give it some time okay I don't know why it is taking so much time but anyway though the instance is in the running state so now let us go ahead and directly connect to the instance so let me grab this IP address and we'll verify the connectivity to this instance delet the instance IP and Port 22 you can see that I'm able to connect to the c22 so let me directly log this instance let me select the key as 102 2023 PPK and this being a ub2 Ami the default usern name will be ubu right so I'll just login as UB to so that's it I'm inside the server now now let us go ahead and install Java so let me pick the instructions to install Java level so this is done right so where in we have launched a ec2 instance with the t2. small now we will install the Java 11 for sonar Q so let me pick the steps to install Java 11 first just let me up the packages using this command app typh get update so and then you know we will try to grip for the open jdk 11 package okay this is okay you can see here it is listing the open jdk 11 package now we will install the package it is open jdk 11 Hy jdk okay so now it has installed the open jdk 11 let us verify the Java version Java minus version you can see here 11.0.2 okay so now the next step is we will go ahead and install the post gr SQL database on this same virtual machine right so here are the steps to install the post gr database so I'm just going to copy this I copy this command now I will say after get update okay so now let me use this command add get minus y install post gr SQL right because we have basically downloaded the repository from this particular link ap. post.org now the repository is available on our local system I use this command to install the package okay so now the post gr SQL database has been installed now we will try to set a password for the POG SQL database by default it would have created a O Level user called post postgress I search for cat Etc password right you can see here we have a for gray user here right at the OS level so now what we need to do we need to set up a password for this user okay so let me try to set a password as admin it can be any password I'm just using the password as admin this case so what I will do password postgress then I will set the password as admin admin okay now the post gr user password has been updated successfully now if at all I want to log to the post grade SQL database I need to First switch to this user sudo Su minus post grade right okay so now you can see my user is a HST gr user now I want to log into the database and do some um you know activities there in terms of creating a database user Etc so what I will do now I'll just give the command psql okay once I do that I will be into the post gr database now I inside the post gr database okay now what we need to do we need to create a user for the sonar Cube application and we also need to create a database called sonar Cube so let us go ahead and do that the first will be create a database user and the database for sonar so create user sonar that will be the first step I'm creating a user with the name sonar so create user sonar semicolon enter okay so this is a first step secondly alter user sonar with encrypted password admin what we are doing is we are giving the password as admin setting the password as admin for this particular Phar user so let me copy this command so alter user son with encrypted password the password will be admin so that is done the next step is create database sonar Cube which will be owned by the sonar user so we are creating a database with the name sonar Cube and that database will be owned by the sonar user that will be our next step okay now Grant all all the privileges on the database sonar Cube to the sonar user basically you are giving full permissions for the sonar user in order to perform any activity on this sonar CU database okay I hope these steps are clear so this is what we need to do from the database perspective now what we need to do we have to come out of this post grade database but before that if I give a slash L we can see what are all the default databases that is available right now this is the database that I created okay so I created a database called as sonar cube right so this is the database because whatever we are seeing is the list of databases so we created the sonar Cube database and we also created a sonar user which is going to be the owner for this particular database okay okay now let me come out of this database I will say control Q okay now I will also go back to the root prompt because I need to restart the database services so I'll use this command which has to be done as a root user right so system CTL restart po SQL now I will check the status of the post gr SQL process you can see here it is in the active State and it is running fine okay okay so now let us see what is the next steps so generally this post grade database will be running on the port 5432 so if I want to check I can give the command let start minus t PN and gra for 5432 but it is going to give me an error that I need to install this particular utility net hyphen tools because net start will be available only from this utility so let me go ahead and install this act install net hyphen tools this is done now I will check for the N startat command dripping for the P 5432 you can see here you know the post gray database this is a post gray database process which is learning on the port 5432 okay so now what is the next step now we will have to do some configurations at the OS level in order to have the sonar Cube application running fine on this instance what are all those configurations is we'll have to put some settings in the ETC cctl docf the settings like this VM Max map account FS file U limit all these settings has to be put in the cctl docon similarly there is a system file called limits.on in that we are defining a limit for the the sonar Cube application okay so this link will detail about the prerequisites needed for setting up the sonar Cube application so as part of that only we are going to add these two system level settings right so first let me open this etcc c.f and I'm going to add these entry um so we go back to my instance I will say VI btcc C.C probably I'll just go to the end of the line and I'm going to add these uh four settings okay so now let me save this file and on the other file I'm going to add this setting that is one Cube no file allocate the memory bi Etc security limits. conif maybe before the end of the file I insert these lines okay now the next step would be to reboot the server so I'm going to use the init six command in order to reboot the server right so let me say init phas six okay so now the instance will be rebooted in few minutes we'll check after couple of minutes okay so I think now the instance would have come up again we close this session now we'll try to reconnect to this instance okay log us so now we have completed till this part right we have rebooted the server the next comes the setup of the sonar Cube where in first we need to download the binaries I'm going to install the sonar Cube version 8.9.2 from the community Edition so let me directly give this command and download this binaries so before that I go to the group directory and I'll go to opt and under opt I'm going to download this binaries okay now I want to unzip this package so I just say unzip but it it it is asking us to install a utility called unzip right so let me go ahead and install this app install unzip okay let us go ahead and unzip this package we'll say unzip package name okay done now what is our next step so now we need to update the sonar. properties with some information related to the database credentials because here we are going to use the post gr SQL database right so we need to tell sonar Cube what is database and to which with which user it has to connect to the database so we have to edit some parameters so what I will do is I will go into the sonar Cube directory and here we have a con of directory so in the con of directory there is a file called as sonar. properties so let me open this file and here we need to do some configurations one is sonar JD BC username so the username what we created in the database it is sonar right and what is the password that we set in the database for this user it is admin that is a password right so I'm going to just uncommon this line so this is our user credentials then let us go to the the post gr section wherein we need to uncomment this URL also so sonar. JD C URL is equal to jdbc colon post gr SQL colon col Local Host because our post gr SQL is also running on the same instance so it would be Local Host and what is the database name it is sonar CU so I will just leave it till here and remove the other part okay so this would be with jdbc do URL configuration for host grade SQL so it will be Local Host SL sonar Q okay then there is one more parameter that is this sonar web Java opts so we need to uncommon this particular line also now let me go ahead and save the file okay so this is a setting that we need to do for the solar cube in the solar. properties file now we will also need to create a sonar cube. service file whenever you want sonar Cube to automatically start at the system boot up so we will have to create this service file okay so now what I will do I'm going to create this onr cube. service and in that under the service section here you can see that we are anyway using the user sonar only to start the application and you can see from where it is starting op on R Cube bin LX x84 so it is just navigating to this directory but I think our directory is different it is not sonar Cube but instead of that it is sonar Cube Hy 8.9.2 right so in order to make it uniform what I will do is I will first remove this Z file then I will rename this sonar Cube 8922 just sonar cube right so that we will not have any conflict so when we are creating this service file so what I will do I'm just going to copy everything so here exe start is opt sonr Cube that is what we have here right it's only sonr Cube and under that it will go into the this Vin directory then line X X8 664 which is our operating system architecture and from there it is going to execute the solar. SS script okay so now let me go ahead and copy this full section F this we say enter it looks like it's not properly align I guess just give me a moment to properly align this things so you can see here we are directly starting the application with the user as son on and group also is pH on and we have one more block called block okay so now let me copy this okay great now this file has been created successfully is the sonar cube. service file so now what we will do we will have to create a user called as sonar this is at application Level right and we are going to make the home directory as slop sonar Cube that is what this command is doing okay usern name will be sonar and the home directory will be SL opt sonar CU let me go ahead and execute this okay done now ch1 minus r for this sonar user we are giving full permissions that is for sonar user as well as sonar group to this particular directory SL opq okay now if you go into opt and check sonar Cube folder we can see that it is now owned by the sonar user and sonar so that is another prerequisite step now let us go ahead and reload the the sonar Cube Services ideally it is going to start only with the sonar user even if you execute this from the root prompt right so now what I will do is let me copy this command CTL system CTL demand relo and system CTL start the conar cube service okay now let us verify the status of the sonar Cube service some CTL status onar Cube you can see that the services active and running so now we know that sonar cube is going to run on the port 9,000 right so let me go ahead and uh just check for this in netar N minus tpn for 9,000 you can see that the application is listening on the port 9,000 right now let us also verify in the instance Security Group if at all this port 9,000 has been added we go into the security open the security group edit inbound rules okay let me add the rule for opening the 9,000 Port anywhere ipv4 and then save the rules okay so now anyway the sonar Cube application is up and running we have verified it as well now straight away we will be accessing this application from the browser so I will grab the the sonar Cube instance IP address right and then let me put it in the browser and since it is running on Port 9,000 I will say colon 9,000 now you can see that you know the application is starting up and it is typically now connected to the PO gray SQL database right right so I'm going to give the default credentials username is admin and password is admin now it will ask us to change the the default password right so the old password will be admin new new password maybe I'm giving it something different just updating the the admin password and then I just update okay so now you can see here now the application is up and running successfully and uh it is basically connecting or communicating with the post gr SQL database right so if at all we want to check again in the post gr SQL database so we can switch user to postgress right and then if you give the command P SQL okay so you are going to be inside the database now if you want to give a slash L it is going to list all the data bases so similarly slash Q will get you out of the database okay so now this is how you you basically uh spin up your post gr SQL database and configure your sonar Cube to connect to the post gr SQL database okay I hope this content was helpful so basically these are all the sequence of steps that we did okay so team also I wanted to let you know that I'm I do conduct trainings on AWS and devops right so AWS training would be typically aligned to the AWS sop certification exam and devops I cover all the tools predominantly the you know the popularly used tools across the various life cycle in devops and with give with typical with more Focus I would say on kubernetes hemp charts terraform Etc so if at all anyone would be interested to take up this training from me you can feel free to send send an email to the mentioned email ID so I'll be sharing the details on the course content as well as the course fee so the training mode is going to be an online session via zoom and the class recordings at the end of each and every class will be uploaded onto the Google Drive in which you will be given access so whether it is AWS or devops it is typically going to span for five to six weeks it's going to be an interactive course completely focused on the handson lab exercise right so if at all you want to get your hands dirty with AWS and devops you can definitely send an email to me and I'll I'll make you comfortable with the very good Hands-On exercises across all the you know tools and services within these two technologies so I think that's all I had uh in this video If you like this content uh please press the like button and if you have not subscribed to my channel yet please feel free to subscribe to my channel and if you feel this content would be useful to any of you are known circles please feel free to share it to them as well so thank you all and I will meet you all in my next video
Info
Channel: awsdevopsniche11
Views: 348
Rating: undefined out of 5
Keywords: aws, devops, sonarqube tutorial, sonarqube, join devops, sonarqube integration with jenkins, create ec2 instance in aws, aws ec2 tutorial, sonarqube installation linux, postgres, postgres tutorial, postgres and pgadmin install, postgres sql, postgres database, install postgres, how to install postgres
Id: q4Rgh5sdnYs
Channel Id: undefined
Length: 35min 3sec (2103 seconds)
Published: Tue Dec 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.