Saturday, 28 April 2018

How To Install cPanel on a Virtual Server Running Centos 6

 

About cPanel

cPanel is a convenient application that allows users to administer servers through a GUI interface instead of the traditional command line. Although the installation for cPanel is relatively simple, the script does take several hours to run.

Notes

  • Once cPanel is installed, it cannot be removed from the server without a complete server restore. cPanel does not offer an uninstaller
  • Additionally, cPanel is subject to a licensing fee which may come out to be around $200 a year. DigitalOcean does not cover the cost of cPanel. You can find out more about cPanel pricing here

Setup

Before installing cPanel on our droplet, we need to take two additional steps.
First we need to make sure that Perl is installed on the server
sudo yum install perl
After installing perl we need to take one more preliminary step. cPanel is very picky about making sure that server that it is installed on has a Fully Qualified Domain Name. To that effect, we need to provide it with a valid hostname. Skipping this step will inevitably get you the following, very common, error.
2012-11-01 16:00:54  461 (ERROR): Your hostname () is not set properly. Please
2012-11-01 16:00:54  462 (ERROR): change your hostname to a fully qualified domain name,
2012-11-01 16:00:54  463 (ERROR): and re-run this installer.
Luckily this error has a very easy solution. If you have a FQDN, you can type it in with the command:
hostname your FQDN
Otherwise, if you want to proceed with the cPanel installation but do still lack the hostname, you can input a temporary one. Once cPanel is installed, you will be able to change the hostname to the correct one on one of the first setup pages.
hostname  host.example.com

Install cPanel

Although the cPanel installation only has several steps, the installation does take a long time. Although using program "screen" is not necessary in order to install cPanel, it can be a very helpful addition to the installation process. It can be especially useful if you know that you may have issues with intermittent internet or that you will need to pause the lengthy install process.
To start off, go ahead and install screen and wget:
sudo yum install screen wget
Once screen is installed, start a new session running:
screen
After opening screen, you can proceed to install cPanel with WHM or a DNS only version of cPanel.
  • Use this this command to install cPanel with WHM:
    wget -N http://httpupdate.cPanel.net/latest
  • Use this command to install the DNS only version of cPanel:
    wget -N http://httpupdate.cPanel.net/latest-dnsonly
With the requested package downloaded, we can go ahead and start the script running:
sh latest
Then close out of screen. The script, which may take one to two hours to complete will continue running while in the background—even if you close out the of server.
In order to detach screen type: Cntrl-a-d
To reattach to your screen you can use the command:
screen -r
Once cPanel finally installs, you can access the login by going to your ip address:2087 (eg. 12.34.45.678:2087l) or domain (example.com:2087)
Your login will be:
username: your_server_user
password: your_password
From there, you can create your cpanel user and finally login in at ipaddress/cpanel or domain/cpanel

Logical Volume Manager (Linux) Interview questions

  1. Question1. What Is Lvm?

    Answer :
    LVM stands for Logical Volume Manager. LVM, is a storage management solution that allows administrators to divide hard drive space into physical volumes (PV), which can then be combined into volume groups (VG), which are then divided into logical volumes (LV) on which the filesystem and mount point are created.
  2. Question2. What Is The Difference Between Lvm And Raid?

    Answer :
    A RAID device is a physical grouping of disk devices in order to create a logical presentation of one device whereas LVM is a logical layer that that can be manipulated in order to create and, or expand a logical presentation of a disk device to an OS.
  3. Question3. Explain Lvm Snapshot?

    Answer :
    LVM snapshots allow the administrator to create a new block device which presents an exact copy of a logical volume, frozen at some point in time.
  4. Question4. How You Will Check On Your Server Or System Device-mapper Is Installed Or Not?

    Answer :
    Check the following file:
    #cat /proc/misc
    if this file contains “device-mapper” term it means device mapper is installed on your system.
  5. Question5. How Are Snapshots In Lvm2 Different From Lvm1?

    Answer :
    In LVM2 snapshots are read/write by default, whereas in LVM1, snapshots were read only.
  6. Question6. What Is The Maximum Size Of A Single Lv?

    Answer :
    For 2.4 based kernels, the maximum LV size is 2TB. For 32-bit CPUs on 2.6 kernels, the maximum LV size is 16TB. For 64-bit CPUs on 2.6 kernels, the maximum LV size is 8EB.
  7. Question7. If A Volume Group Named As Vgname Already Exists But We Need To Extend This Volume Group Up To 4gb. Explain All Steps?

    Answer :
    Firstly, create Physical volume (/dev/sdaX, where X is the partition number) of size 4GB.
    Now run following command: # vgextend vgname /dev/sdaX
  8. Question8. If A Volume Group Vgname Have 3 Pv’s (/dev/sda5, /dev/sda6, /dev/sda7) But We Want To Remove /dev/sda7 Pv From This Vgname?

    Answer :
    # vgreduce vgname /dev/sda7
  9. Question9. Which Command Is Used To Extend A Logical Volume?

    Answer :
    # lvextend -size +<addsize> /dev/<vgname>/<lvname>
    resize2fs /dev/<vgname>/<lvname>
  10. Question10. What Is The Partition Type Number For Swap, Raid And Lvm?

    Answer :
    SWAP (82), RAID (fd) and LVM (8e)
  11. Question11. How To Add A Disk To A Volume Group?

    Answer :
    suppose disk is /dev/sdb
    # pvcreate /dev/sdb
    # vgextend <vgname> /dev/sdb
  12. Question12. How To Remove A Disk From A Volume Group?

    Answer :
    Syntax:
    # vgreduce <vgname> <disk>
    Example:
    # vgreduce vgname /dev/sdb
  13. Question13. How To Backup New Lvm Data Structures?

    Answer :
    # vgcfgbackup /dev/vgname
  14. Question14. Is It Possible To Increase The Logical Volume On Fly?

    Answer :
    Yes. LVM has the feature to increase the volume without unmount it.
  15. Question15. How To Reduce The Logical Volume? Is It Possible To Reduce On Fly?

    Answer :
    No. we can't reduce the logical volume on fly. Here is the steps to reduce the logical volume.
    • Un-mount the filesystem
    • Run e2fsck on the volume device
    • Reduce the Filesystem using resize2fs
    • Reduce the logical Volume using lvreduce
    • Mount the filesystem back for production.
  16. Question16. How Do You Scan The New Lun Or Disk?

    Answer :
    Use "echo 1 > /sys/class/scsi_host/hostx/scan" to scan disk from newly connected SAN or DISKS and also replace the "x" with number of host id present under /sys/class/scsi_host/.
  17. Question17. How To Scan Disks For Existing Volume Group?

    Answer :
    Use "vgscan" to scan existing volume group from newly connected SAN or DISKS.
    But we should use "pvscan" prior to executing this command.
  18. Question18. How To Scan A Logical Volume From Exising Volume Group?

    Answer :
    lvscan
  19. Question19. How To Stop The Logical Volume? Or Deactivate The Logical Volume?

    Answer :
    "lvchange -an /dev/vg_name/lv_name"
  20. Question20. How To Activate The Logical Volume Which Is In Deactivated State?

    Answer :
    "lvchange -ay /dev/vg_name/lv_name".
  21. Question21. How To Disable The Volume Group? Or Deactivate The Volume Group?

    Answer :
    "vgchange -an volume_group_name".
  22. Question22. How To Enable The Volume Group? Or Activate The Volume Group?

    Answer :
    "vgchange -ay volume_group_name" .
  23. Question23. How Do You Find That What Are The Disks Are Used For Logical Volume Mirroring?

    Answer :
    use "lvs -a -o +devices"
  24. Question24. What Are Steps To Perform In Order To Increase The Logical Volume On Fly?

    Answer :
    • Extend the logical volume
    • Increase the Filesystem size
    • Verify the status using df command or lvs command.
  25. Question25. How To List The Imported Volume Groups?

    Answer :
    Use "vgs" command to display the imported volume group.
  26. Question26. How To Create Partition From The Raw Disk ?

    Answer :
    Using fdisk utility we can create partitions from the raw disk.Below are the steps to create partition from the raw dsik :
    • fdisk /dev/hd* (IDE) or /dev/sd* (SCSI)
    • Type n to create a new partition 
    • After creating partition , type w command to write the changes to the partition table.
  27. Question27. What Does Sar Provides And At Which Location Sar Logs Are Stored ?

    Answer :
    Sar Collect, report, or save system activity information. The default version of the sar command (CPU utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system resources. If CPU utilization is near 100 percent (user + nice + system), the workload sampled is CPU­bound. 
    By default log files of Sar command is located at /var/log/sa/sadd file, where the dd parameter indicates the current day.
  28. Question28. How To Reduce Or Shrink The Size Of Lvm Partition ?

    Answer :
    Below are the logical Steps to reduce size of LVM partition :
    Umount the filesystem using umount command, ­use resize2fs command ,
    e.g resiz2fs /dev/mapper/myvg­mylv 10G ­Now use the lvreduce command ,
    e.g lvreduce ­L 10G /dev/mapper/myvgmylv 
    Above Command will shrink the size & will make the filesystem size 10GB.
  29. Question29. How To Increase The Size Of Lvm Partition ?

    Answer :
    Below are the Logical Steps :
    Use the lvextend command (lvextend ­L +100M /dev/<Name of the LVM Partition> , in this example we are extending the size by 100MB. 
    resize2fs /dev/<Name of the LVM Partition>
    check the size of partition using ‘df ­h’ command

  30. Question30. Why Lvm Is Required?

    Answer :
    LVM stands for Logical Volume Manager , to resize filesystem's size online we required LVM partition in Linux. Size of LVM partition can be extended and reduced using the lvextend & lvreduce commands respectively.
  31. Question31. How To Create Partition From The Raw Disk?

    Answer :
    Using fdisk utility we can create partitions from the raw disk.Below are the steps to create partition from the raw disk :
    • fdisk /dev/hd* (IDE) or /dev/sd* (SCSI)
    • Type n to create a new partition
    • After creating partition , type w command to write the changes to the partition table.
  32. Question32. How To Decommission/remove Lvm Completely From The Host?

    Answer :
    • Un-mount all the logical filesystems
    • Remove the logical volumes using "lvremove" command.
    • Destroy the volume group using "vgremove" command.
    • Use "pvremove" command remove the physical volumes from the system.
  33. Question33. If The Vg02 Has Two Physical Volumes Called /dev/sdc/ & /dev/sdd. How Do You Remove /dev/sdd From Vg02?

    Answer :
    "vgreduce vg02 /dev/sdd/"
  34. Question34. Assume Volume Group "vg02" Is Already Exists. How Do You Extend The Volume Group With 50gb? Provide All The Steps With Commands?

    Answer :
    1. Get the 50GB lun from storage team.(/dev/sdd)
    2. Create physcical volume ( # pvcreate /dev/sdd )
    3. Extend the volume group (# vgextend vg02 /dev/sdd)
  35. Question35. How To Extent The Volume Group?

    Answer :
    Using "vgextend" we can increase the volume group.
  36. Question36. What Are The Steps Involved To Create The Logical Volume From Scratch?

    Answer :
    1. Create a physical volume using pvcreate command: #pvcreate /dev/sdc
    2. Create a volume group using "vgcreate" command: #vgcreate vg02 /dev/sdc
    3. Create a logical volume using "lvcreate" command: #lvcreate -L 100M -n vol1 vg02
    4. Create a filesystem on logical volume using mkfs command: #mkfs -t ext4 /dev/vg02/vol1
    5. Mount the filesystem using mount command for use: #mount -t ext4 /dev/vg02/vol1 /vol1
  37. Question37. How Are Snapshots In Lvm2 Different From Lvm1 In Redhat Linux?

    Answer :
    LVM1 snapshots are readonly by default where LVM2 snapshots were read/write.
  38. Question38. What Is Lvmdump?

    Answer :
    "lvmdump" is tool for LVM2 to collect the various information for diagnostic purposes.By default, it creates a tarball suitable for submission along with a problem report
  39. Question39. How To Re-create The Device Files For Lvm Volumes?

    Answer :
    Run "vgmknodes" to recreate the LVM devices files.
  40. Question40. How To Take A Lvm Configuration Backup?

    Answer :
    Use "vgcfgbackup vg_name" to take the latest configuration backup of volume group. The default volume group backup location is "/etc/lvm/backup" .
  41. Question41. How To Rename Volume Group? Can We Rename The Vg On Fly?

    Answer :
    Yes. Its possible to rename the volume group on fly. But the mounted volumes will not reflect the same unless you re-mount the volume with new VG name. Need to update the /etc/fstab with new VG name to mount the volumes across the system reboot.
  42. Question42. How To See The Detailed Physical Volume Information?

    Answer :
    Use "pvdisplay /dev/disk_name"  Ex: pvdisplay /dev/sde
  43. Question43. How To See The Detailed Logical Volume Information?

    Answer :
    Use "lvdisplay /dev/vg_name/lv_name"
  44. Question44. How To See The Detailed Volume Group Information?

    Answer :
    Use "vgdisplay vg_name"
  45. Question45. How To List The Available Physical Volumes In Lvm?

    Answer :
    Use "pvs" command to list the available physical volumes.
  46. Question46. How To List The Available Logical Volumes On The System?

    Answer :
    Use "lvs" command to list the available logical volumes on the system.

How To Install MongoDB on CentOS 6

MongoDB is a NoSQL database intended for storing large amounts of data in document-oriented storage with dynamic schemas. NoSQL refers to a database with a data model other than the tabular format used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL. MongoDB features include: full index support, replication, high availability, and auto-sharding.
Pre-Flight Check
  • These instructions are intended for installing MongoDB on a single CentOS 6 node.
  • I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.
Step #1: Add the MongoDB Repository

vim /etc/yum.repos.d/mongodb.repo
Option A: If you are running a 64-bit system, add the following information to the file you’ve created, using to insert:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
Then exit and save the file with the command :wq . You should see an output very similar to the following image:
How To Install MongoDB on CentOS 6 - 01
Option B: If you are running a 32-bit system, add the following information to the file you’ve created, using to insert:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1
Then exit and save the file with the command :wq .
Step #2: Install MongoDB
At this point, installing MongoDB is as simple as running just one command:
yum install mongo-10gen mongo-10gen-server
When prompted Is this ok [y/N]: , simply type and then hit the enter key. You should see an output very similar to the following image:
How To Install MongoDB on CentOS 6 - 02
Step #3: Get MongoDB Running
Start-Up MongoDB
service mongod start
You should see an output very similar to the following image:
How To Install MongoDB on CentOS 6 - 03
Check MongoDB Service Status
service mongod status
Summary List of Status Statistics
mongostat
Enter the MongoDB Command Line
mongo
You should see an output very similar to the following image:
How To Install MongoDB on CentOS 6 - 04
By default, running this command will look for a MongoDB server listening on port 27017 on the localhost interface.
If you’d like to connect to a MongoDB server running on a different port, then use the –port option. For example, if you wanted to connect to a local MongoDB server listening on port 22222, then you’d issue the following command:
mongo --port 22222
Shutdown MongoDB
service mongod stop
There are many, many more things we could say about MongoDB, but those will be detailed in follow-up articles in the Liquid Web Knowledge Base! Look for articles on: How To Install MongoDB and Run a Multi-Node Cluster on CentOS 6 Recommended Production Settings for MongoDB on CentOS 6 and more!