Engineering and technology

Install Grafana on Ubuntu 20.04 

1. Install Grafana

Update the system packages.

$ sudo apt update

Install required system packages.

$ sudo apt-get install -y gnupg2 curl software-properties-common

Add Grafana GPG key.

$ curl https://packages.grafana.com/gpg.key | sudo apt-key add -

Install the Grafana repository.

$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

Update the system packages.

$ sudo apt update

Install Grafana

$ sudo apt -y install grafana

Start Grafana service.

$ sudo systemctl start grafana-server

Enable Grafana service to start on system boot.

$ sudo systemctl enable grafana-server

Check the service status.

$ sudo systemctl status grafana-server

By default, Grafana is accessible on port 3000. To use Grafana on port 80, you can run a reverse proxy to forward all traffic on port 3000 to port 80. To do this, you can follow the instructions in the next step. Otherwise, use port 3000 to access the Grafana web interface.

2. Install and Configure Nginx Reverse Proxy (Optional)

Install Nginx.

$ sudo apt install nginx -y

Start Nginx service.

$ sudo systemctl start nginx

Enable Nginx service to start on system boot.

$ sudo systemctl enable nginx

Check Nginx service status.

$ sudo systemctl status nginx

Unlink the default configuration file.

$ sudo unlink /etc/nginx/sites-enabled/default

Create a new configuration file.

$ sudo nano /etc/nginx/sites-available/grafana.conf

Add the following code in the new file, save and close the file:

server {
    listen 80;
    location / {
        proxy_pass http://localhost:3000;
    }
}

Link and activate the new configuration file.

$ sudo ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/grafana.conf

Test the configuration file.

$ sudo service nginx configtest

Restart Nginx service.

$ sudo systemctl restart nginx

3. Access Grafana Dashboard

To access the Grafana Web Interface without reverse proxy, go to your browser and visit http://Server_IP:3000/. For example:

http://192.0.2.10:3000/

To access the Grafana Web Interface over the reverse proxy, go to your browser and visit http://Server_IP/. For example:

http://192.0.2.10/

Source: Install Grafana on Ubuntu 20.04 – Vultr.com

How to Extend LVM Partition with lvextend command in Linux

How to Extend LVM Partition with lvextend command in Linux

Resizing the file system size is an important task of Linux admin’s profile. In Linux , LVM(Logical Volume Manager) provides the facility to increase and reduce the file system size. In this tutorial we will discuss the practical examples of lvextend and will learn how to extend LVM partition on the fly using lvextend command.

Scenario : Suppose we have a LVM partition(/home) and running out of space and want to extend or increase file system size. So to increase the size of the file system first we must see whether in volume group has free space or not. If the Volume group has free space then use the below steps :

Step:1 Type ‘ df -h’ command to list the file system

Run the “df -h” command followed by the file system to view total ,used and available disk space

[root@cloud home]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                       9.7G  9.2G     0 100% /home

As we can see /home is 100 % utilized.

Step:2 Now check whether free space is available space in the volume group

To display volume group details, execute the vgdisplay command followed by volume group name,

# vgdisplay < Volume-Group-Name>

[root@cloud home]# vgdisplay vg_cloud
   --- Volume group ---
 VG Name                      vg_cloud
 System ID
 Format                       lvm2
 Metadata Areas               1
 Metadata Sequence No         4
 VG Access                    read/write
 VG Status                    resizable
 MAX LV                       0
 Cur LV                       3
 Open LV                      3
 Max PV                       0
 Cur PV                       1
 Act PV                       1
 VG Size                      27.01 GiB
 PE Size                      4.00 MiB
 Total PE                     6915
 Alloc PE / Size              5256 / 20.53 GiB
 Free  PE / Size              1659 / 6.48 GiB
 VG UUID                      1R89GB-mIP2-7Hgu-zEVR-5H02-7GdB-Ufj7R4

Step:3 Use lvextend command to increase the size.

Run below lvextend command to extend the file system,

[root@cloud ~]# lvextend -L +2G /dev/mapper/vg_cloud-LogVol00
     Extending logical volume LogVol00 to 11.77 GiB
     Logical volume LogVol00 successfully resized

Above command will extend the file system size by 2GB. You can also specify the size in MB , just replace G with M.

Step:3 Run the resize2fs command

In above step we have executed the lvextend command to extend the file system size by 2 GB but still the file system is not updated, so execute the following resize2fs command

[root@cloud ~]# resize2fs /dev/mapper/vg_cloud-LogVol00

Step:4 Use df command and verify /home size .

Re-run the df -h command followed by /home file system, now we can see that file system has been extended by 2 GB, before the extension size was 10 GB

[root@cloud ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                        12G  9.2G  1.9G  84% /home

Source: How to Extend LVM Partition with lvextend command in Linux