Postfix manages following types of Mail Queue
Incoming Queue
Active Queue
Postdrop
Deferred
Hold
Corrupt
Damaged queue files kept inside this queue .
Friends last few days were so busy days for most of my seniors.
Actually one of our client has deleted (accidently) some important configuration files from server. We did lot’s of troubleshooting to make server up.
On those trouble shootings I got opportunity to learn some precious things. For me it was like practical review of LINUX BOOTING SEQUENCE TROUBLE SHOOTINGS.
Let me share some boot troubleshooting topics.
Linux boot process
a) Bios initialization
b) Boot loader
c) Kernel initialization
d) init
a) BIOS is the interface between hardware & software in very basic level. It runs POST, and then it looks for peripherals & a device to boot from. at the end of POST , a boot device is selected from list of detected boot device.(it may be floopy,hddcd-rom,NIC)
b) BIOS reads & executes the 1st physical sector of chosen boot media on system. Usually this is contained in the 1st 446 byte of hard disk.(in case of GRUB)
1) So BIOS 1st pass control to IPL within MBR.(This stage is called 1st stage of booting of Linux)
Note: - If in system more than one OS is installed then boot loader must be configured to pass control to other desired OS.
2) If 1st stage of booting pass control to Linux then it seeks /boot partition & by finding grob.conf,initrd & other files it completed 2nd stage of booting.
c) Kernel initialization: - lots of process generated for compiling device driver & to attempt to locate their corresponding drivers.
You can see /var/log/dmesg that contains snapshoot of kernel messages taken just after control pass to init.
Note: - if essential (need to boot) drivers have been compiled as modules instead of into the kernel, and then they must be include in initrd.img. This is then temporarily mounted by kernel on RAM disk to make module available for initialization process.
After loading of all essential drivers, kernel mounts root file system (/) read-only & pass the control to 1st process (init).
d) INIT:-init reads /etc/inittab (because now / is read-only) & execute all that written in this file as follows
1) Selection of desired run level
2) Execute /etc/rc.d/rc.sysinit
A) Activate udev & selinux
B) Set kernel parameter from /etc/sysctl.conf
C) Set system clock
D) Enable swap partition
E) Set hostname
F) Checking root file system & remount (in read write mode)
G) Activate RAID & LVM
H) Enable disk Quota
I) Check & mount other file system read write mode
J) Clean up stale lock & PID files
3) Runs /etc/rc.d/rc?.d/
(/etc/rc.d/init.d has soft link for corresponding run level)
4) It runs /etc/rc.d/rc.local
5) It starts xinetd service.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This is the complete booting sequence of Linux. While troubleshooting Linux booting problem it helps to find actual cause for booting failure
Linux booting troubleshooting is as follows
LINUX BOOTING SEQUENCE TROUBLESHOOTING
Case 1: No boot loader splash screen or prompt appears
Cause:
1) Grub.conf miss configures
2) Initrd misplaced or deleted
3) MBR cruuppet
4) /boot partition miss
Grub.conf miss configures
Remedy: try to pass boot location initrd location & kernel module location as follows
Step a) Grub > root (hd0,0)
Note: here hd0,0 means boot partition is in 1st partition of 1st hdd.(please use hd for SATA & SCSI hdd also )
Step b) grub > kernel /vmlinuz-$(uname -r) root=LABEL=/ rhgb quiet
Step c) grub > initrd /initrd-$(uname -r).img
Step d) grub > boot
Then after rebooting try to recreate grub.conf file
Initrd misplaced or deleted
Case a) system is up
This is the most fortunate situation for system admins who are managing the server remotely because now once the system will down it will not be up without rescue mode
Remedy:
[root@dh-localhost ~]# mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Case b) system is down
Then boot from system via DVD & start it by rescue mode
Remedy:
Step 1) Boot: linux recue
After some process & ittrective prompt you will be on sh prompt
Step 2) chroot /mnt/sysimage
cd /boot
mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Then reboot the system by HDD
Note: - in case of fstab is also misconfigured (ie / & other partition will not mount after boot) then chroot command will not work. So in this case your 1st step would be to correct fstab then perform above steps as follows
Step a) boot from DVD or other bootable media
Step b) chroot /mnt/sysimage (you will find chroot error here )
Step c) mkdir /test
e2label /dev/sda1 (if it will show boot them mount it otherwise try to search by e2label /dev/sda2 ownwards)
mount /dev/sda1 /test
cd /test
cd grub
vi grub.conf (please make it correct)
mkdir /data
mount /dev/sda2 /data (mounting / partition on /data )
cd /data
cd /etc
vi fstab (please correct it )
Then reboot the system & follow previous step
Mbr corrupt
Case a) system is up
Method 1
[root@dh-localhost ~]# /sbin/grub-install /dev/sda
Method 2
[root@dh-localhost ~]# grub
grub> root (hd0,0)
grub > setup (hd0)
grub > quit
Case b) system is down
Boot system by rescue mode
Sh #Chroot /mnt/sysimage
Sh # /sbin/grub-install /dev/sda
Note : A smart system admin always take backup of MBR as follows
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
&
For restoration for MBR
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
/boot partition miss
In this case if you have backup of /boot then you can recover it otherwise you need to rebuild the server again.
RewriteCond %{HTTP_USER_AGENT} Malicious_User_Agent [NC]
RewriteRule .* - [F,L]
tcpdump -s 1500 -Svni eth0 tcp and port 80
Today my client claimed to reset the log rotation of access_log to 1 day and 1 log of all his 532 websites hosted in a server .
Also he claimed that all rotated log will be mailed to him .
Then I did :->
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Step 1:-> create a file
# vi logger.conf
/var/www/vhosts/*/statistics/logs/access_log
{daily
rotate 1
mail amit@abc.com
compress
}
:wq!
Then I simply type
Step2:-> logrotate logger.conf
++++++++++++++++++++++++++++++++++++++++++++
There are other options here :->
| compress | This is used to compress the rotated log file with gzip. |
| nocompress | This is used when you do not want to compress rotated log files. |
| copytruncate | This is used when processes are still writing information to open log files. This option copies the active log file to a backup and truncates the active log file. |
| nocopytruncate | This copies the log files to backup, but the open log file is not truncated. |
| create mode owner group | This rotates the log file and creates a new log file with the specified permissions, owner, and group. The default is to use the same mode, owner, and group as the original file. |
| nocreate | This prevents the creation of a new log file. |
| delaycompress | When used with the compress option, the rotated log file is not compressed until the next time it is cycled. |
| nodelaycompress | This overrides delaycompress. The log file is compressed when it is cycled. |
| errors address | This mails logrotate errors to an address. |
| ifempty | With this, the log file is rotated even if it is empty. This is the default forlogrotate. |
| notifempty | This does not rotate the log file if it is empty. |
| mail address | This mails log files that are cycled to an address. When mail log files are cycled, they are effectively removed from the system. |
| nomail | When mail log files are cycled, a copy is not mailed. |
| olddir directory | With this, cycled log files are kept in the specified directory. This directory must be on the same filesystem as the current log files. |
| noolddir | Cycled log files are kept in the same directory as the current log files. |
| prerotate/endscript | These are statements that enclose commands to be executed prior to a log file being rotated. The prerotate and endscript keywords must appear on a line by themselves. |
| postrotate/endscript | These are statements that enclose commands to be executed after a log file has been rotated. The postrotate and endscript keywords must appear on a line by themselves. |
| daily | This is used to rotate log files daily. |
| weekly | This is used to rotate log files weekly. |
| monthly | This is used to rotate log files monthly. |
| rotate count | This specifies the number of times to rotate a file before it is deleted. A count of 0 (zero) means no copies are retained. A count of 5 means five copies are retained. |
| tabootext [+] list | This directs logrotate to not rotate files with the specified extension. The default list of extensions is .rpm-orig, .rpmsave, v, and ~. |
| size size | With this, the log file is rotated when the specified size is reached. Size may be specified in bytes (default), kilobytes (sizek), or megabytes (sizem) |
For more detail you can read man page of logrotate .