How DNS works

When you type yahoo.com into your web browser, your browser sends a query over the Internet to find the website for yahoo.com. The first server you query interacts with is the recursive resolver, which is typically operated by your ISP. The recursive resolver knows which other DNS severs it needs to ask to get the IP for yahoo.com.

The 1st type of DNS server the recursive resolver talks to is called a root server. The root servers are running all over the world and each one knows the DNS information about TLD such as ‘.com’. The recursive resolver ask a root server for DNS information about ‘.com’. Each TLD’s DNS stores the address information for the second level domain (yahoo.com) within the top level domain (.com). When your query reaches the TLD server, the TLD server answers with the IP address of the domain’s nameserver which will provide the next piece of information. Next the recursive resolver sends the query to the domain’s nameserver. This DNS server knows the IP address for the full domain, yahoo.com, and that answer is returned to the recursive resolver.

Now, that the recursive resolver knows the IP address for the domain name in your query, the recursive resolver tells the browser what the IP address is. Finally, your browser can send a request to the website to retrieve the website’s content, using the IP address.

Advertisements

Restrict users to add Cron job in Linux

Regular users can modify and install their own cron configuration or jobs.

If you want to restrict users to add new cron jobs, then you have to first remove (or backup) cron.deny file and then create a new file cron.allow and add one line for each users. It will deny all those users who are not in this list from adding a cron job.

[root@nagios ~]# mv /etc/cron.deny /etc/cron.deny.bak

[root@nagios ~]# vi /etc/cron.allow

I added 2 users other than user ‘soj’. Now, as user soj, I am trying to add a new cronjob and as you can see the user soj is denied from add a new cron job.

[soj@nagios ~]$ crontab -e
You (soj) are not allowed to use this program (crontab)
See crontab(1) for more information

You can implement the same for ‘at’ as well by placing allowed users to /etc/at.allow.

Deleting an LVM partition

Following are the steps to delete an LVM partition:

1. Unmount LVM partition
2. Disable the LVM partition
3. Delete the LVM partition
4. Disable the Volume Group
5. Delete the Volume Group
6. Delete the physical Volume

So, let’s start:

Unmount LVM partition:
[root@nagios soj]# umount /dev/exampleVG/exampleLV

Disable LVM partition:
[root@nagios soj]# lvchange -an /dev/exampleVG/exampleLV

Delete LVM volume:
[root@nagios soj]# lvmremove /dev/exampleVG/exampleLV

Disable Volume Group
[root@nagios soj]# vgchange -an exampleVG

Delete the Volume Group
[root@nagios soj]# vgremove exampleVG

Delete the Physical Volume
[root@nagios soj]# pvremove /dev/sdc1 /dev/sdc2

Reducing LVM logical volume size

First of all make sure you have sufficient disk space available before reducing logical volume (otherwise it would result in data loss). Also, make sure to have valid data backup before going forward and making changes.

It’s important to shrink the file system before reducing it to prevent data loss/corruption. The resize2fs program will resize ext2, ext3 or ext4 file systems. It can be used to enlarge or shrink an unmounted file system located on the device.

Here we are redicing the LVM size by 500GB.

Unmount the file system
[root@nagios soj]# umount /dev/exampleVG/exampleLV

Scan and check the file system to be on the safer side
[root@nagios soj]# e2fsck /dev/exampleVG/exampleLV

Shrink the file system with resize2fs as follows:
[root@nagios soj]# resize2fs /dev/exampleVG/exampleLV 500GB

Reduce the logical volume by 500GB with lvreduce:
[root@nagios soj]# lvreduce -L -500GB /dev/exampleVG/exampleLV

Mount the filesystem and check the disk space with df -h command

Extending LVM Volume

This is in continuation of the previous topic – Managing Storage with LVM
Check the initial size of our lvm volume:


[root@nagios soj]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 3.3G 2.3G 60% /
tmpfs 836M 0 836M 0% /dev/shm
/dev/xvdj1 40G 1.3G 37G 4% /drive
/dev/mapper/exampleVG-exampleLV
20G 2.9G 16G 16% /lvmdata
<=

[root@nagios ~]# lvdisplay
--- Logical volume ---
LV Name /dev/exampleVG/exampleLV
VG Name exampleVG
LV UUID xMd0My-l7Ez-dqYb-JM75-cKH3-YOfK-HSV1zx
LV Write Access read/write
LV Status available
# open 0
LV Size 20.00 GiB <=
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

In order to extend an LVM partition, you have to use lvextend command as follows:

[root@nagios soj]# lvextend -L +10G /dev/exampleVG/exampleLV
Extending logical volume exampleLV to 30.00 GiB
Logical volume exampleLV successfully resized

Here we are adding additional 500 megs of space to the existing exampleLV logical volume. Note the output of df command now. You will see the additional 500 megs is not reflected on the /lvmdata although we have already added 500 megs to it. This is because we have extended the underlying logical volume, but not the file system itself. The command ‘resize2fs’ will do the trick.


[root@nagios soj]# resize2fs /dev/exampleVG/exampleLV
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/exampleVG/exampleLV is mounted on /lvmdata; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/exampleVG/exampleLV to 7864320 (4k) blocks.
The filesystem on /dev/exampleVG/exampleLV is now 7864320 blocks long.

Now, check the ‘df -h’ command and see the difference. You will see the additional 500 megs added to the /lvmdata/ partition.


[root@nagios soj]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 5.8G 3.3G 2.3G 60% /
tmpfs 836M 0 836M 0% /dev/shm
/dev/xvdj1 40G 1.3G 37G 4% /drive
/dev/mapper/exampleVG-exampleLV
30G 2.9G 26G 11% /lvmdata <=

[root@nagios soj]# lvdisplay
--- Logical volume ---
LV Name /dev/exampleVG/exampleLV
VG Name exampleVG
LV UUID xMd0My-l7Ez-dqYb-JM75-cKH3-YOfK-HSV1zx
LV Write Access read/write
LV Status available
# open 1
LV Size 30.00 GiB <=
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

So, now we have extended the logincal volume size.

Swapping and Paging

Swapping occurs when an entire process gets transferred to disk from physical memory or is read back into physical memory from the disk

[root@nagios ~]# vmstat -s -S M | grep M
         1740 M total memory
         1723 M used memory
         1411 M active memory
           91 M inactive memory
           16 M free memory
           36 M buffer memory
          142 M swap cache
         1895 M total swap
            5 M used swap
         1890 M free swap

Paging occurs when part of a process gets transferred to disk from physical memory or is read back into physical memory from disk.

[root@domU-12-31-39-01-C1-54:~] getconf PAGESIZE
4096

For more info, you can check out the URL @ what-is-difference-between-swapping-and.html

Quick notes on SAN, ISCI, DAS and NAS

SAN Advantage

Share storage among different application servers

Data is stored at a block level

Physical elements of the SAN (servers, switches, storage arrays, etc.) are connected with Fibre Channel

SAN is scalability and flexibility.

Storage can be added without disrupting the applications and different types of storage can be added to the pool.

Backups is centralized so reducing workload and providing greater assurance that the backups are complete.

Backup traffic never impacts users on the LAN.

iSCSI SAN Advantages

iSCSI is a lower cost alternative to Fibre Channel SAN infrastructure.

Interconnect is Ethernet cable and the switches are Gigabit Ethernet.

Protocol used is TCP/IP.

iSCSI presents volumes as a block storage device which makes them ideal for use by enterprise applications such as Microsoft Exchange and Microsoft SQL Server. In particular, the Microsoft iSCSI Software Initiator is the component of the overall iSCSI environment that makes it possible to make the iSCSI SAN attached disks appear to be local attached disks.

DAS (Direct Attached Storage) Advantages

The disks may be internal to the server or in an array that is connected directly to the server.

Backups must either be performed on each individual server.

Storage can only be added by taking down the application server, then adding physical disks and then rebuilding the storage array.

NAS (Network Attached Storage) Advantages

NAS accesses data by file.

NAS manages its own file system.

NAS can be accesses across multiple operating systems.

NAS backups are more efficient. (With NAS feature called Snapshot provides an almost instantaneous way for the systems administrator to recover lost, deleted, or corrupted files.)

Administrators can assign shares, security settings as they would for a regular file server.