Tuesday 23 December 2014

How to Configuration Raid level 5 in CentOs 6.4/Rhel 6.4



Raid level 5 Configuration
If you wanted to configure Raid level 5 .You need 3 same size Partition.Here i create 1 extended Partition then create 3 Logical Partition.After create 3 partition i am convert 3 partition into 'fd' for Linux raid Auto detect. 

[root@amir /]# fdisk -l
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris

Creating Extended Partition
[root@amir /]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (2805-26108, default 2805):
Using default value 2805
Last cylinder, +cylinders or +size{K,M,G} (2805-26108, default 26108):
Using default value 26108

Command (m for help): p
Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bba2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris
/dev/sda3            2805       26108   187183486    5  Extended  {created new partition}
Command (m for help): w
The partition table has been altered!

[root@amir /]# init 6 {reboot}

Create  3 Logical Partition into Extended Partition
[root@amir /]# fdisk –cu /dev/sda
Command (m for help): p
Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bba2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris
/dev/sda3            2805       26108   187183486    5  Extended

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (2805-26108, default 2805):
Using default value 2805
Last cylinder, +cylinders or +size{K,M,G} (2805-26108, default 26108): 5805

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (5806-26108, default 5806):
Using default value 5806
Last cylinder, +cylinders or +size{K,M,G} (5806-26108, default 26108): 8806

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (8807-26108, default 8807):
Using default value 8807
Last cylinder, +cylinders or +size{K,M,G} (8807-26108, default 26108): 11807
Command (m for help): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bba2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris
/dev/sda3            2805       26108   187183486    5  Extended
/dev/sda5            2805        5805    24099607   83  Linux     #Created logical volume
/dev/sda6            5806        8806    24105501   83  Linux    
#Created logical volume
/dev/sda7            8807       11807    24105501   83  Linux   
#Created logical volume


Command (m for help): t                                #t for changing partition id
Partition number (1-7): 5                                 # 5 for volume no
Hex code (type L to list codes): fd                 # fd for raid partition id
Changed system type of partition 5 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): fd
Changed system type of partition 6 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)

Command (m for help): p
Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bba2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris
/dev/sda3            2805       26108   187183486    5  Extended
/dev/sda5            2805        5805    24099607   fd  Linux raid autodetect
/dev/sda6            5806        8806    24105501   fd  Linux raid autodetect
/dev/sda7            8807       11807    24105501   fd  Linux raid autodetect
Command (m for help): w
The partition table has been altered!
[root@amir /]# fdisk -l                                           [check again your Partition Status]
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   83  Linux
/dev/sda2            2550        2805     2048000   82  Linux swap / Solaris
/dev/sda3            2805       26108   187183486    5  Extended
/dev/sda5            2805        5805    24099607   fd  Linux raid autodetect
/dev/sda6            5806        8806    24105501   fd  Linux raid autodetect
/dev/sda7            8807       11807    24105501   fd  Linux raid autodetect


[root@amir /]#reboot
[root@amir /]# partprobe /dev/sda5
[root@amir /]# partprobe /dev/sda6
[root@amir /]# partprobe /dev/sda7

Creating Raid Level 5
Note:md0,md1,md2 is raid Device .
[root@amir /]# mdadm –create /dev/md0 –level=5 –raid-devices=3 /dev/sda{5,6,7}
mdadm: largest drive (/dev/sda7) exceeds size (24098304K) by more than 1%
Continue creating array?
Continue creating array? (y/n) y [press y]
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Check Raid Status
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda7[3] sda6[1] sda5[0]  [ Your Raid is Running ]
      48196608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]
      [>………………..]  recovery =  0.6% (160332/24098304) finish=37.3min speed=10688K/sec
     
unused devices: <none>

[root@amir /]# mkfs.ext4 /dev/md0 { Format your '/dev/md0' device into 'ext4' }
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
3014656 inodes, 12049152 blocks
602457 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
368 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424

Writing inode tables: done                          
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@amir /]# mkdir /Raid5

[root@amir /]# df -h
[root@amir /]# mount /dev/md0 /Raid5/
[root@amir /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              20G  3.0G   16G  17% /
tmpfs                 250M  264K  250M   1% /dev/shm
/dev/md0               46G   52M   43G   1% /Raid5  {raid partition}

[root@amir /]# vim /etc/fstab              {editing for permanently Mount}
 

/dev/md0            /Raid5           ext4                defaults        0 0

[root@amir /]# vim /etc/mdadm.conf
 

add the following line to automatically active raid device upon reboot  
ARRAY /dev/md0 level=raid5 num-devices=3 devices=/dev/sda5,/dev/sda6,/dev/sda7
  
            OR

[root@amir /]# mdadm –detail –scan >> /etc/mdadm.conf
[root@amir /]# cat /etc/mdadm.conf 
ARRAY /dev/md0 metadata=1.2 spares=1 name=amir.server.com:0 UUID=5a879bae:78809be1:8da3


[root@amir /]# mdadm –detail /dev/md0      {Check the Raid Devices Status }
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 18:14:12 2013
          State : clean, degraded, recovering
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

 Rebuild Status : 44% complete [ this is your Rebuild Status when 100% the rebuild will done]
           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 20

    Number   Major   Minor   RaidDevice State
       0       8        5        0      active sync   /dev/sda5
       1       8        6        1      active sync   /dev/sda6
       3       8        7        2      spare rebuilding   /dev/sda7  [spare Rebuilding now]
 
After 15 minute check your Raid Devices Status again
[root@amir /]# mdadm –detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 18:33:57 2013
          State : clean
 Active Devices : 3  [Your Active Device is 3]
Working Devices : 3  [Working device 3]
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 44

    Number   Major   Minor   RaidDevice State
       0       8        5        0      active sync   /dev/sda5 [working]
       1       8        6        1      active sync   /dev/sda6 [working]
       3       8        7        2      active sync   /dev/sda7 [working]


Stop  Raid
[root@amir /]# umount /Raid5
[root@amir /]# mdadm –stop /dev/md0
mdadm: stopped /dev/md0
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]  [Your Raid is Not working]
unused devices: <none>

Starting the Raid Array
    (assuming its stopped)
[root@amir /]# mdadm –assemble –scan
mdadm: /dev/md0 has been started with 3 drives.
[root@amir /]# cat /proc/mdstat 
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda5[0] sda7[3] sda6[1]                        [Your Raid Devices is working ]
      48196608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]    
unused devices: <none>


Raid 5 Configuration 'Partition Remove,add,DiskFailor Checking' Part-3
Note: Now i will 'test' Fault in Disk failor if one disk (/dev/sda5)' Failor my all data is reserved in '/dev/sda6 & /dev/sda7'.But 2 disk failor data completely lost.

[root@amir /]# cd /Raid5/
[root@station1 Raid5]# mkdir testing
[root@station1 Raid5]# ls
testing
[root@station1 Raid5]# mdadm /dev/md0 –fail /dev/sda5
mdadm: set /dev/sda5 faulty in /dev/md0
[root@station1 Raid5]# mdadm –detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 18:56:15 2013
          State : clean, degraded
 Active Devices : 2  
Working Devices : 2   [Working devices 2]
 Failed Devices : 1   [Faild Device ]
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 45

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8        6        1      active sync   /dev/sda6
       3       8        7        2      active sync   /dev/sda7

       0       8        5        –      faulty spare   /dev/sda5  [sda5 is Fault]
Note: Now reboot your pc & check your /Raid5 directory data…if data is live your Raid5 is working.
[root@amir /]# reboot
[root@amir /]# umount /Raid5/
[root@amir /]# mdadm –stop /dev/md0
mdadm: stopped /dev/md0
[root@amir /]# cat /proc/mdstat 
Personalities : [raid6] [raid5] [raid4]
unused devices: <none>
[root@amir /]# mdadm –assemble –scan
mdadm: /dev/md0 has been started with 2 drives (out of 3).
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda6[1] sda7[3]
      48196608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU]
     
unused devices: <none>
[root@amir /]# cd /Raid5/
[root@station1 Raid5]# ls
testing              {Raid is Working}

Add one raid Partion '/dev/sda5'
[root@station1 Raid5]# cd
[root@amir /]# mdadm –detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 19:08:40 2013
          State : clean, degraded
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 57

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8        6        1      active sync   /dev/sda6
       3       8        7        2      active sync   /dev/sda7
[root@amir /]# mdadm /dev/md0 –add /dev/sda5
mdadm: added /dev/sda5
[root@amir /]# mdadm –detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 19:13:47 2013
          State : clean, degraded, recovering
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1  [/dev/sda5 partition rebuilding]

         Layout : left-symmetric
     Chunk Size : 512K

 Rebuild Status : 2% complete
           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 61

    Number   Major   Minor   RaidDevice State
       4       8        5        0      spare rebuilding   /dev/sda5  {added partition}
       1       8        6        1      active sync   /dev/sda6
       3       8        7        2      active sync   /dev/sda7

[root@amir /]# mdadm –detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Jul 24 17:52:58 2013
     Raid Level : raid5
     Array Size : 48196608 (45.96 GiB 49.35 GB)
  Used Dev Size : 24098304 (22.98 GiB 24.68 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 19:47:39 2013
          State : clean
 Active Devices : 3 [it’s working Fine]
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : amir.server.com:0  (local to host amir.server.com)
           UUID : 5a879bae:78809be1:8da3ad40:1ab922de
         Events : 124

    Number   Major   Minor   RaidDevice State
       4       8        5        0      active sync   /dev/sda5
       1       8        6        1      active sync   /dev/sda6
       3       8        7        2      active sync   /dev/sda7
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda5[4] sda6[1] sda7[3]
      48196608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
     
unused devices: <none>
[root@amir /]# mdadm –stop /dev/md0
mdadm: stopped /dev/md0
[root@amir /]# mdadm –assemble –scan
mdadm: /dev/md0 has been started with 3 drives.

###################### Now we will destroy our 2 Raid Partition in this case all data are destroyed #################
[root@amir /]# mdadm /dev/md0 –fail /dev/sda6
mdadm: set /dev/sda6 faulty in /dev/md0
[root@amir /]# mdadm /dev/md0 –fail /dev/sda7
mdadm: set /dev/sda7 faulty in /dev/md0
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda5[4] sda7[3](F)
      48196608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/1] [U__]
     
unused devices: <none>
[root@amir /]# mdadm –stop /dev/md0
mdadm: stopped /dev/md0
[root@amir /]# mdadm –assemble –scan
mdadm: /dev/md0 assembled from 1 drive – not enough to start the array.
[root@amir /]# mdadm –detail /dev/md0
mdadm: md device /dev/md0 does not appear to be active.
[root@amir /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : inactive sda5[4](S) sda7[3](S) sda6[1](S)
      97955309 blocks super 1.2
     
unused devices: <none>


THE END

Sunday 21 December 2014

How to Install Cpanel/WHM in RHEL/CentOS 6/5


cPanel is one of the most popular Commercial control panel for Linux web hosting, I have been working with cPanel for 2+ years to manage all Shared, Reseller and business hosting customers. It comes with cPanel and Web Host Manager, which makes web hosting easier for you. WHM provides you root level access to your server whereas cPanel provides user level access interface to manage their own web hosting account on the server.
Install cPanel & WHM in Linux

Features of cPanel

cPanel control panel is very versatile control panel for managing your hosting servers, It has lots of features which make Web hosting easier for you. Some of them are listed below:
  1. Powerful GUI controls on your server with WHM.
  2. Can perform tedious tasks like Backups, Migrations and restorations in a very easy and smooth manner.
  3. Excellent DNS and mail server management for main server and as well as client account.
  4. Can easily switch/enable/disable services for server.
  5. Can configure SSL/TLS for all server services and client domains.
  6. Easy integration with Phpmyadmin to provide a web based interface to manage your MySQL databases.
  7. Feel free to Rebrand it.
  8. Can be easily integrated with WHMCS to automate billing management.
Here In this article, We’ll be covering cPanel & WHM installation on RHEL/CentOS 6.5 and share some more useful information which will help you to manage cPanel & WHM.

Installation Prerequisites

  1. A fresh and running VPS or dedicated CentOS 6.5 server.
  2. A minimum of 384MB RAM.
  3. A Minimum 20GB of free disk space required for cPanel installation.
  4. A cPanel license.

Installation of cPanel in RHEL/CentOS 5/6

First insure that OS version on which your Linux box is running, To do so, please use following command.
[root@tecmint ~]# cat /etc/redhat-release

CentOS release 6.4 (Final)
If you don’t have the latest version, please update your OS to its latest version, In CentOS and RHEL, we can simply do it with yum package installer.
[root@server1 ~]# yum update
Once updates completes, and then check the latest OS version with same above command.
[root@server1 ~]# cat /etc/redhat-release

CentOS release 6.5 (Final)
Once you’ve ensured the OS version, you don’t have to install any other dependency package cPanel auto installer script does all for you. We can download cPanel installer file with wget command under /home directory.
root@server1 [~]# cd /home
root@server1 [~]# wget -N http://httpupdate.cpanel.net/latest
Sample Output
--2013-12-18 21:59:23--  http://httpupdate.cPanel.net/latest
Resolving httpupdate.cPanel.net... 208.82.118.100, 208.109.109.239, 209.85.80.214, ...
Connecting to httpupdate.cPanel.net|208.82.118.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34087 (33K) [application/octet-stream]
Saving to: `latest'

100%[======================================>] 34,087      42.5K/s   in 0.8s

2013-12-18 21:59:24 (42.5 KB/s) - `latest' saved [34087/34087]
In above output you can see that we have downloaded a file “latest” in our home directory.
Next, execute the auto installer script, but we strongly recommended to run cPanel auto installer script in screen mode if you are doing it with SSH because it takes 3-4+ hours to complete the installation depending on your server resources.
root@server1 [~]# sh latest
Sample Output
Verifying archive integrity... All good.
Uncompressing cPanel & WHM Installer..............
        ____                  _
    ___|  _ \ __ _ _ __   ___| |
   / __| |_) / _` | '_ \ / _ \ |
  | (__|  __/ (_| | | | |  __/ |
   \___|_|   \__,_|_| |_|\___|_|
Installer Version v00029 r6849459174e3809f72de2bef81427a8a45399d66
Beginning main installation.
------------------------------------
------------------------------------
Now, you need to wait for the cPanel installer script to complete its installation.

What Auto Installer Script Does for You

cPanel heavily modifies your operating system and that is the reason that no cPanel Uninstaller available on the web so far, you need to reformat your server to remove cPanel completely from your server.
  1. It checks for various packages to ensure that there will be no conflicts and it finds any package conflict, it uninstalls previous packages with yum and that’s why its recommended to install cPanel on a Fresh OS.
  2. Downloads language and base files for installation.
  3. Installs various Perl modules through CPAN and other required packages with yum.
  4. Downloads and compiles PHP and Apache with various associated modules.
Once that script completes its installation, it will shows up that cPanel installation is complete. You may be asked to reboot the server after installation.
After that you need to complete the installation wizard from its web based interface and you can access WHM with the following URL.
http://your-server-ip:2087

OR

http://your-host-name:2087
cPanel will open up its web interface like similar to below.
cPanel Login
cPanel Login
Please login with user “root” and your password. There are some more clicks remaining to complete the cPanel installation. Agree End User License Agreement by clicking “I Agree?/Go to Step 2” button:
Accept cPanel Agreement
Accept cPanel Agreement
Please do provide the working email address and contact SMS address in the column of “Server Contact Email Address” and “Server contact SMS address” respectively because your cPanel sends all important alerts, notification to this EMail-id (Recommended). You can fill the rest details as well, if you have one.

cPanel Network Setup
cPanel Network Setup
Please provide a valid FQDN hostname and Resolver entries for your server in this Networking section, you can use Google resolvers in this section if you don’t have your ISP’s resolvers. Please see the image below.

Add Hostname
Add Hostname
If you have more than one IP attached with your NIC card and you want to set up a specific IP for your Server’s main IP, you can do that from here, to do so please choose the IP from the drop down and click on “Go to Setup 4”.

Setup IP Address
Setup IP Address
In the 4th setup wizard, you can select DNS server which you want to use. You can choose one of them according to their Advantages, disadvantages and your server resources. Please read the
comparison carefully and select the DNS server. Please see the image below.

Setup Name Servers
Setup Name Servers
In the same step, please write down Name Servers you want to use in format of ns1/ns2.example.com. Also, Add an A entry for your hostname and nameserver by selecting the check box, please see the image below.
Add Name Server

Add Name Server
You can select and set up different services like FTP, Mail and Cphulk in the Step 5 of this web based wizard, please see the snapshots and description below.
You can select FTP server of your choice from this wizard, which you want to use for your server depending on their advantages, disadvantages and depending upon your ease and requirements.
FTP Configurationq
FTP Configuration
In the same wizard, you can select your Mail server to be used for all your mailing activities in future. You can add MTAs like Exim with your cPanel in future.
Mail Configuration
Mail Configuration
Cphulk brute force protection detects and block false password attacks activities and block their IP for your server. You can enable/disable and configure it from this installation wizard. Please see the snapshot below.
Setup Cphulk Brute Force Protection
Setup Cphulk Brute Force Protection
Last Step 6, allows you to enable quotas which helps you to track down the disk space usages.
Setup User Quotas
Setup User Quotas
Please select “Use file system quotas” and click on “Finish setup wizard” to complete the Installation process. Once you are done with Installation, WHM’s home page will Appear like below..
cPanel Server Configuration

cPanel Server Configuration
You can see that Home page of WHM is displaying all Control panel option and sidebar with search facility which allows you to search options by just typing their names.
Sometimes, cPanel installer script is not able to update the licence because of firewall or resolvers entries and you’ll see trial warning in the page. You can do it manually with following command.
root@server1 [~]# /usr/local/cpanel/cpkeyclt
As I told you above that Cpanel is for user level access and WHM is for root level access, you need to create an account with option available in WHM. Here I have created an account with the username “tecmint” to show you the view of cPanel for users. Please see the image below.
cPanel Preferences
cPanel Preferences
Other Useful thing to know before you start working with Cpanel and WHM.

CPanel Backend Files

  1. Cpanel directory : /usr/local/cpanel
  2. Third Party tools : /usr/local/cpanel/3rdparty/
  3. Cpanel addons directory : /usr/local/cpanel/addons/
  4. Base files like Phpmyadmin, skins : /usr/local/cpanel/base/
  5. cPanel binaries : /usr/local/cpanel/bin/
  6. CGI files : /usr/local/cpanel/cgi-sys/
  7. Cpanel access & error log files : /usr/local/cpanel/logs/
  8. Whm related files : /usr/local/cpanel/whostmgr/

Important conf files

  1. Apache configuration file: /etc/httpd/conf/httpd.conf
  2. Exim mail server conf file:/etc/exim.conf
  3. Named conf file : /etc/named.conf
  4. ProFTP and Pureftpd conf file :/etc/proftpd.conf and /etc/pure-ftpd.conf
  5. Cpanel user file: /var/cpanel/users/username
  6. Cpanel configuration file (Tweak settings) : /var/cpanel/cpanel.config
  7. Networking configuration file: /etc/sysconfig/network
  8. Addons, parked and subdomain information: /etc/userdomains
  9. Cpanel update config file: /etc/cpupdate.conf
  10. Clamav conf file: /etc/clamav.conf
  11. Mysql configuration file: /etc/my.cnf
  12. PHP ini conf file : /usr/local/lib/php.ini

Sunday 14 December 2014

How to Install MySQL on Linux.




[root@amir ~]# yum -y install mysql-server

[root@amir ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# add
character-set-server=utf8
[root@amir ~]#/etc/rc.d/init.d/mysqld start

Initializing MySQL database:  WARNING: The host 'amir.server.world' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
...
...
...
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                              [  OK  ]
Starting mysqld:                      [  OK  ]

[root@amir ~]# chkconfig mysqld on

[2]
Initial settings for MySQL.

[root@amir ~]# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

# Enter

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

# set root password

Set root password? [Y/n]
y

New password:
# input any password

Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

# remove anonymous users

Remove anonymous users? [Y/n]
y

 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

# disallow root login remotely

Disallow root login remotely? [Y/n]
y

 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

# remove test database

Remove test database and access to it? [Y/n]
y

 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

# reload privilege tables

Reload privilege tables now? [Y/n]
y

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

# try to connect with root

[root@amir ~]# mysql -u root -p

Enter password:
# MySQL root password

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# display user list

mysql>select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | ***************************************** |
| root | 127.0.0.1 | ***************************************** |
+------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)

# display database list

mysql>show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql>
exit

Bye

How to install clamAV on Centos 6

  Install EPEL repo: Before we can do proceed, you must ensure that you have the EPEL yum repository enabled. To do this, CentO...