Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, 24 November 2019

How To Configure SonarQube on Ubuntu 16.04



Q. What is SonarQube ?

-- SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages. SonarQube offers reports on duplicated code, coding standards, unit tests, code coverage, code complexity, comments, bugs, and security vulnerabilities.

SonarQube includes support for the programming languages Java (including Android), C#, PHP, JavaScript, TypeScript, C/C++, Ruby, Kotlin, Go, COBOL, PL/SQL, PL/I, ABAP, VB.NET, VB6, Python, RPG, Flex, Objective-C, Swift, CSS, HTML, and XML.


Requirements:
  • Ubuntu 16.04 Server
  • 2 GB of RAM to run efficiently and 1 GB of free RAM (Preferred 4 GB RAM) 
  • Disk Space: Depending on utilization (Preferred 50 GB) 
  • Instance volume type must be excellent read & write performance 
  • SonarQube does not support 32-bit systems on the server side. 
  • Open JDK 8 or Oracle Java 8
  • Database MySQL 5.7 (Preferred MSSQL)

Installation:

Step: 1. Update System & Install required Packages :

# apt-get update && apt-get -y upgrade
# apt-get -y install -y wget unzip zip
 

Step: 2.  Install Oracle Java :

# cd /opt
# mkdir java
# wget https://github.com/frekele/oracle-java/releases/download/8u212-b10/jdk-8u212-linux-x64.tar.gz
# tar -xzvf jdk-8u212-linux-x64.tar.gz -C /opt/java --strip-components=1
# update-alternatives --install /usr/bin/java java /opt/java/bin/java 100
# update-alternatives --install /usr/bin/javac javac /opt/java/bin/javac 100
# java -version
# echo $JAVA_HOME

Step: 3. Create user for SonarQube :

 
# sudo adduser --system --no-create-home --group --disabled-login sonarqube


Step: 4. Install MySQL Server & Create User for SonarQube :

 
# apt-get -y install mysql-server-5.7 mysql-server-core-5.7

# mysql_secure_installation

# mysql -u root -p

Enter Password:

MySQL> CREATE DATABASE sonardb CHARACTER SET utf8 COLLATE utf8_bin;
MySQL> GRANT ALL on sonardb.* TO 'sonarqube'@'localhost' IDENTIFIED BY 'sonardb#321';
MySQL> FLUSH PRIVILEGES;
MySQL> exit;


Step: 5. Install SonarQube :

 
# cd /opt/
# wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.7.zip
# unzip sonarqube-7.7.zip
# mv sonarqube-7.7 sonarqube
# sudo chown -R sonarqube:sonarqube /opt/sonarqube
# vi sonarqube/conf/sonar.properties

     sonar.jdbc.username=sonarqube
     sonar.jdbc.password=sonardb#321
     sonar.jdbc.url=jdbc:mysql://localhost:3306/sonardb?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
     sonar.web.javaOpts=-server
     sonar.web.host=0.0.0.0
     sonar.web.port=9000
     sonar.web.context=/sonarqube (for If you want to web access like https://www.example.com/sonarqube)


-- Save & Quit (:wq)


Step: 6. Create Service for SonarQube :

 
# vi /etc/systemd/system/sonarqube.service
 
  [Unit]
  Description=SonarQube service
  After=syslog.target network.target

  [Service]
  Type=forking

  ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
  ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

  User=sonarqube
  Group=sonarqube
  Restart=always

  [Install]
  WantedBy=multi-user.target


-- Save & Quit (:wq)

# systemctl daemon-reload

Step: 7. SonarQube Service Commands :

 
# service sonarqube start
# service sonarqube status
# service sonarqube stop

Step: 8. Install SonarScanner for Scanning :

 
# cd /opt
# wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip
# unzip sonar-scanner-cli-3.3.0.1492-linux.zip
# mv sonar-scanner-3.3.0.1492-linux sonarscanner
# sudo chown -R sonarqube:sonarqube /opt/sonarscanner
# vi sonarscanner/conf/sonar-scanner.properties
    
    sonar.host.url=http://localhost:9000

-- Save & Quit (:wq)

# chmod +x sonarscanner/bin/sonar-scanner
# sudo ln -s /opt/sonarscanner/bin/sonar-scanner /usr/local/bin/sonar-scanner



Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

Thursday, 11 April 2019

How To Configure GlusterFS on Ubuntu 16.04

GlusterFS_Cluster




Introduction:


-- GlusterFS is a free, open source and scalable network filesystem specially designed for 
data-intensive tasks such as cloud storage and media streaming. GlusterFS made up of two 
components a server and a client. The server runs glusterfsd and the client used to mount the
exported filesystem. You can achieve high availability by distributing the data across the multiple 
volumes/nodes using GlusterFS. GlusterFS client can access the storage like local storage. GlusterFS is a file-based scale-out storage that allows you to combine large numbers of 
commodity storage and compute resources into a high performance and virtualized pool. 
You can scale both capacity and performance on demand from terabytes to petabytes.

Requirements:

1. Two AWS EC2 instance for GlusterFS server with Ubuntu 16.04 and 20 GB external 
HDD on each. 
2. One AWS EC2 instance for GlusterFS client with Ubuntu 16.04 installed.
3. A static IP address 172.31.85.78 on glusterfs1 172.31.83.5 on glusterf2 and 172.31.82.27 

on glusterclient client is configured.

Note: On security group of all instances we need to allow the ports 111,24007,24008,
38465 to 38467,49152 to 49154,All ICMP port.


Installation Process of GlusterFS Servers:


Step: 1. Update your base system with the latest available packages :

# apt-get -y update

Step: 2. Login to the GlusterFS Servers & set the hostnames as glusterfs1 & glusterfs2 :

# hostname glusterfs1
# hostname glusterfs2

# vi /etc/hostname

glusterfs1

-- Save & Quit (:wq)

Step: 3. Configure Hostname Resolution:

# vi /etc/hosts

-- Add the following lines:

172.31.83.5 glusterfs2
172.31.85.78 glusterfs1

-- Save & Quit (:wq)

Step: 4. Install GlusterFS on Server1 & Server2:

# apt-get -y install apt-transport-https
# add-apt-repository -y ppa:gluster/glusterfs-4.1
# apt-get update -y
# apt-get -y install glusterfs-server
# systemctl enable glusterd.service
# systemctl start glusterd.service

Note: If facing any issue while adding GlusterFS Repository then do the following:

# vi /usr/bin/add-apt-repository

-- Change package header from `python3` to `python3.5` (or lower)

-- Save & Quit (:wq)

Step 5. Configure GlusterFS Storage:

# mkdir -p /gshare

Next, create a persistent mount point by editing /etc/fstab file:

# vi /etc/fstab

-- Add the following line:

/dev/xvdb /gshare ext4 defaults 0 0

-- Save & Quit (:wq)

# mount -a

Step: 6. Configure GlusterFS Storage Pool:

-- Run this command on GlusterFS Server 1:

# gluster peer probe glusterfs2
# gluster volume create gdata replica 2 glusterfs1:/gshare glusterfs2:/gshare force

-- You can verify the status of the trusted storage pool with the following command Output should
be like this peer probe: success.

#  gluster peer status

Step: 7. Configure GlusterFS Volume:

# gluster volume create gdata replica 2 glusterfs1:/gshare glusterfs2:/gshare force
# gluster volume start gdata

-- Checking the volume status on both server:

# gluster volume status

-- You can now check the status of created volume with the following command:

# gluster volume info gdata

Installation Process of GlusterFS Client:


Step: 1. Update your base system with the latest available packages:

# apt-get -y update

Step: 2. Login to the client and set the hostnames:

# hostname glusterclient

# vi /etc/hostname

glusterclient

-- Save & Quit (:wq)

Step: 3. Configure Hostname Resolution:

# vi /etc/hosts

-- Add the following lines:

172.31.83.5 glusterfs2
172.31.85.78 glusterfs1
172.31.82.27 glusterclient

-- Save & Quit (:wq)

ping glusterfs1
ping glusterfs2
ping glusterclient

Step: 4. Install GlusterFS Client:

# apt-get install apt-transport-https -y
# add-apt-repository ppa:gluster/glusterfs-4.1
# apt-get -y update

# apt-get -y install glusterfs-client

Note: If facing any issue while adding GlusterFS Repository the do the following:

# vi /usr/bin/add-apt-repository

-- Change package header from `python3` to `python3.5` (or lower)

-- Save & Quit (:wq)

Step 5. Create a directory to mount GlusterFS filesystem:

# mkdir /storage-pool

-- Create a persistent mount point by editing fstab file:

# vi /etc/fstab file

glusterfs2:/gdata /storage-pool glusterfs defaults,_netdev 0 0

-- Save & Quit (:wq)

# mount -a

-- Testing the Replication Features:

On our client machine (glusterclient), we can type this to add some files into our storage-pool directory:

# cd /storage-pool
# touch file.txt

If we look at our /gshare directories on each storage server, we will see that file is present on each system:

# cd /gshare (on glusterfs1 and glusterfs2 server)
# ls

-- Testing the High-availability Features:

To check the high-availability, shutdown the glusterfs2 instance. Now, goto the
glusterclient client instance and check the availability of the files:

On glusterclient:

# ls -l /storage-pool

You should see the file even though the glusterfs2 is down.

Next, create some files on glusterclient

# touch /storage-pool/file21.txt
# touch /storage-pool/file22.txt

All the files are now written on glusterfs1. Now, start the glusterfs2 instance.

Now, check the /gshare directory on both servers.

# ls -l /gshare

You should see all files there.

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog
Copyright © 2016 Kousik Chatterjee's Blog