Issue the command fdisk -l, you can see the new hard disk connected to the server.
For example:
----------------------------------------------------
Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 182401 1465031610 8e Linux LVM
Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
-------------------------------------------------------
Then you need to create a partition in the new server. Using the command 'n', you can create a new partition. Select the partition number and issue the command "w" to write write the partition.
------------------------------------------------------
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 182401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-182401, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-182401, default 182401):
Using default value 182401
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
----------------------------------
Then you have to create a file system in the new hard disk.
mkfs -t ext3 /dev/sdb1 or mkfs.ext3 /dev/sdb1
------------------------------------------
[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
183091200 inodes, 366181585 blocks
18309079 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
11175 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
---------------------------------------------
Then you have to mount the hard disk to the directory /home1
mount /dev/sdb1 /home1
ABHIONLINUX
Site useful for linux administration and web hosting
2010/01/26
2010/01/25
Exim : 451-The server has reached its limit for processing requests from your host.n451 Please try again later.
451-The server has reached its limit for processing requests from your host.n451 Please try again later.
its probably exim's ratelimiting, add your servers IP's to the whitelist in WHM > Exim Configuration
Also check the value of the 'Maximum Emails a Domain Can Send In 1 Hour' value in WHM > Tweak Settings
retry time not reached for any host after a long failure period
exim_tidydb -t 10m /var/spool/exim retry
exim_tidydb -t 10m /var/spool/exim wait-remote_smtp
its probably exim's ratelimiting, add your servers IP's to the whitelist in WHM > Exim Configuration
Also check the value of the 'Maximum Emails a Domain Can Send In 1 Hour' value in WHM > Tweak Settings
retry time not reached for any host after a long failure period
exim_tidydb -t 10m /var/spool/exim retry
exim_tidydb -t 10m /var/spool/exim wait-remote_smtp
2010/01/24
How to create a swap file
To add a swap file:
- Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536.
- At a shell prompt as root, type the following command with
count
being equal to the desired block size:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
- Setup the swap file with the command:
mkswap /swapfile
- To enable the swap file immediately but not automatically at boot time:
swapon /swapfile
- To enable it at boot time, edit
/etc/fstab
to include the following entry:
The next time the system boots, it enables the new swap file./swapfile swap swap defaults 0 0
- After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command
cat /proc/swaps
orfree
.
TCP vs UDP
TCP:
Reliability: TCP is connection-oriented protocol. When a file or message send it will get delivered unless connections fails. If connection lost, the server will request the lost part. There is no corruption while transferring a message.
Ordered: If you send two messages along a connection, one after the other, you know the first message will get there first. You don't have to worry about data arriving in the wrong order.
Heavyweight: - when the low level parts of the TCP "stream" arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together.
Streaming: Data is read as a "stream," with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call.
Examples: World Wide Web (Apache TCP port 80), e-mail (SMTP TCP port 25 Postfix MTA), File Transfer Protocol (FTP port 21) and Secure Shell (OpenSSH port 22) etc.
UDP:
Reliability: UDP is connectionless protocol. When you a send a data or message, you don't know if it'll get there, it could get lost on the way. There may be corruption while transferring a message.
Ordered: If you send two messages out, you don't know what order they'll arrive in i.e. no ordered
Lightweight: No ordering of messages, no tracking connections, etc. It's just fire and forget! This means it's a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.
Datagrams: Packets are sent individually and are guaranteed to be whole if they arrive. One packet per one read call.
Examples: Domain Name System (DNS UDP port 53), streaming media applications such as IPTV or movies, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and online multiplayer games etc
Reliability: TCP is connection-oriented protocol. When a file or message send it will get delivered unless connections fails. If connection lost, the server will request the lost part. There is no corruption while transferring a message.
Ordered: If you send two messages along a connection, one after the other, you know the first message will get there first. You don't have to worry about data arriving in the wrong order.
Heavyweight: - when the low level parts of the TCP "stream" arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together.
Streaming: Data is read as a "stream," with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call.
Examples: World Wide Web (Apache TCP port 80), e-mail (SMTP TCP port 25 Postfix MTA), File Transfer Protocol (FTP port 21) and Secure Shell (OpenSSH port 22) etc.
UDP:
Reliability: UDP is connectionless protocol. When you a send a data or message, you don't know if it'll get there, it could get lost on the way. There may be corruption while transferring a message.
Ordered: If you send two messages out, you don't know what order they'll arrive in i.e. no ordered
Lightweight: No ordering of messages, no tracking connections, etc. It's just fire and forget! This means it's a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.
Datagrams: Packets are sent individually and are guaranteed to be whole if they arrive. One packet per one read call.
Examples: Domain Name System (DNS UDP port 53), streaming media applications such as IPTV or movies, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and online multiplayer games etc
Simple steps for SSH Server Hardening.
SSH Server Hardening in one of the security part to secure your server.Refer following steps to secure SSH.
root@serevr[~]#pico /etc/ssh/sshd_config
Uncomment #Protocol 2, 1
Change to Protocol 2
Append these lines to the bottom:
LoginGraceTime 120
IgnoreRhosts yes
X11Forwarding no
Save file and restart the SSH service.
root@serevr[~]#/etc/rc.d/init.d/sshd restart
Note : SSH Protocol one based servers are facing many automated root kits attacks.As a result to step up the security Protcol 2 should be enabled on server.The reason to use SSH Protocol 2 on any webserver is that it is more secure as compare to protocol 1.
root@serevr[~]#pico /etc/ssh/sshd_config
Uncomment #Protocol 2, 1
Change to Protocol 2
Append these lines to the bottom:
LoginGraceTime 120
IgnoreRhosts yes
X11Forwarding no
Save file and restart the SSH service.
root@serevr[~]#/etc/rc.d/init.d/sshd restart
Note : SSH Protocol one based servers are facing many automated root kits attacks.As a result to step up the security Protcol 2 should be enabled on server.The reason to use SSH Protocol 2 on any webserver is that it is more secure as compare to protocol 1.
2010/01/22
Basic sed tricks
- What is sed? - sed is stream editor, a Unix tool for working with streams of text data. See the awful truth about sed.
- How do you substitute strings with sed? - Use ’s/old/new’ command, so sed ’s/hello/goodbye/’ would substitute the occurrence of the word hello to goodbye.
- How do you inject text with sed? - & in the substitution string defines the pattern found in the search string. As an example, here’s us trying to find a word ‘hello’ and replacing it with ‘hello and how are you’:
echo ‘hello there’ | sed ’s/^hello/& and how are you/’ - Can I find several patterns and refer to them in the replacement string? - Yes, use (pattern) and then refer to your patterns as \1, \2, \3 and so on.
- If the string is ‘old old old’ and I run ’s/old/new’, I get ‘new old old’ as the result. I need ‘new new new‘. - You forgot the global modifier, which would replace every occurrence of the pattern with the substitution. ’s/old/new/g‘ will work.
- But I want ‘old old new’ from the previous example. - Just use the numeric modifier saying you want the third occurrence to be replaced. ’s/old/new/3‘ will work.
- I wrote a rather complex sed script. How do I save and run it? - Assuming that your file is named myscript1.sed, you can invoke sed -f myscript1.sed.
- How do I delete trailing whitespaces from each line? - sed ’s/[ \t]*$//’ Here we’re replacing any occurrence of a space or a tab with nothing. Check sed one-liners for more examples.
- How do you print just a few first lines of the file? - sed 1q will give you just the first line, sed 10q the first 10 lines.
- How do you replace a pattern only if it’s found, so that it’s executed faster? - Nest the replacement statement: sed ‘/old/ s/old/new/g’ file.txt
How to assign a range of IP's to server
Create a file /etc/sysconfig/network-scripts/ifcfg-eth0-range0 add the following entries
IPADDR_START=192.168.0.0
IPADDR_END=192.168.0.100
CLONENUM_START=1
Save it and restart network
/etc/init.d/network restart
IPADDR_START=192.168.0.0
IPADDR_END=192.168.0.100
CLONENUM_START=1
Save it and restart network
/etc/init.d/network restart
2010/01/20
Mbox vs Maildir: Mail Storage Formats
The Unix world has two ways of storing mail messages, the traditional mbox format and the newer maildir format. Postfix and Dovecot supports the two mail storage format so you can use any format, but I highly recommend you use the maildir format.
Mbox Format:
This is the traditional way of storing mail messages in the Unix world. In this format, a regular text file which serves as the mail user’s mailbox file is created.
How Mbox works
Receiving and storing a mail
1. Lock the mailbox.
2. Append the header (usually “From [sender's email address] [date and time received]“) and the mail into the mailbox file.
3. Unlock the mailbox.
Retrieving a mail
1. Lock the mailbox.
2. Locate and read the mail.
3. Update the mail status flag.
4. Unlock the mailbox.
Deleting a mail
1. Lock the mailbox.
2. Move the contents of the mailbox, beginning from the position right after the mail to be deleted until the end of the mailbox, into the position of the mail to be deleted.
3. Reduce the size of the mailbox file by the size of the deleted mail.
4. Unlock the mailbox.
Searching a mail
1. Lock the mailbox.
2. Search the mailbox.
3. Unlock the mailbox.
Advantages
* Format is universally supported.
* Appending a new mail into the mailbox file is fast.
* Searching text inside a single mailbox file is fast.
Disadvantages
* Has file locking problems.
* Has problems when used with network file systems.
* Format is prone to corruption.
The Maildir Format
This is a new way of storing mail messages. In this format, a directory usually named Maildir is created for each mail user.
Under this directory are three more directories named new, cur and tmp.
How Maildir works
Receiving and storing a mail
1. Create a unique file in the tmp directory.
2. Write the mail into the newly created file.
3. Move the completely written mail into the new directory.
Retrieving a mail
1. Locate and read the mail.
2. Move the mail from new into the cur directory and append the mail status flag into the filename.
Deleting a mail
1. Delete the file containing the mail.
Searching a mail
1. Search each and every mail file.
Advantages
* Locating, retrieving and deleting a specific mail is fast.
* Minimal to no file locking needed.
* Can be used on network file system.
* Immune to mailbox corruption (assuming the hardware will not fail).
Disadvantages
* Some filesystems may not efficiently handle a large number of small files.
* Searching text, which requires all mail files to be opened is slow.
Mbox Format:
This is the traditional way of storing mail messages in the Unix world. In this format, a regular text file which serves as the mail user’s mailbox file is created.
How Mbox works
Receiving and storing a mail
1. Lock the mailbox.
2. Append the header (usually “From [sender's email address] [date and time received]“) and the mail into the mailbox file.
3. Unlock the mailbox.
Retrieving a mail
1. Lock the mailbox.
2. Locate and read the mail.
3. Update the mail status flag.
4. Unlock the mailbox.
Deleting a mail
1. Lock the mailbox.
2. Move the contents of the mailbox, beginning from the position right after the mail to be deleted until the end of the mailbox, into the position of the mail to be deleted.
3. Reduce the size of the mailbox file by the size of the deleted mail.
4. Unlock the mailbox.
Searching a mail
1. Lock the mailbox.
2. Search the mailbox.
3. Unlock the mailbox.
Advantages
* Format is universally supported.
* Appending a new mail into the mailbox file is fast.
* Searching text inside a single mailbox file is fast.
Disadvantages
* Has file locking problems.
* Has problems when used with network file systems.
* Format is prone to corruption.
The Maildir Format
This is a new way of storing mail messages. In this format, a directory usually named Maildir is created for each mail user.
Under this directory are three more directories named new, cur and tmp.
How Maildir works
Receiving and storing a mail
1. Create a unique file in the tmp directory.
2. Write the mail into the newly created file.
3. Move the completely written mail into the new directory.
Retrieving a mail
1. Locate and read the mail.
2. Move the mail from new into the cur directory and append the mail status flag into the filename.
Deleting a mail
1. Delete the file containing the mail.
Searching a mail
1. Search each and every mail file.
Advantages
* Locating, retrieving and deleting a specific mail is fast.
* Minimal to no file locking needed.
* Can be used on network file system.
* Immune to mailbox corruption (assuming the hardware will not fail).
Disadvantages
* Some filesystems may not efficiently handle a large number of small files.
* Searching text, which requires all mail files to be opened is slow.
Unable to start apache " pid file /usr/local/apache/logs/httpd.pid overwritten — Unclean shutdown of previous Apache run? semget: No space left on device"
If you are unable to start apache and you are getting the error log as
It means There is no more space left in Semaphore Arrays for Apache.
semaphore is a location in memory whose value can be tested and set by more than one process.
you can check the semaphore arrays on your server using the following command
ipcs -s
It results
------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 360448 nobody 600 1
0x00000000 393217 nobody 600 1
0x00000000 425986 nobody 600 1
0x00000000 458755 nobody 600 1
0x00000000 524292 nobody 600 1
0x00000000 1114117 nobody 600 1
0x00000000 1441798 nobody 600 1
0x00000000 3604487 nobody 600 1
0x00000000 3702792 nobody 600 1
0x00000000 3768329 nobody 600 1
0x00000000 6422538 nobody 600 1
0x00000000 7077899 nobody 600 1
If here you get big list of semaphores it means some semaphores are stuck. You can clear them out with this command:
for i in `ipcs -s | awk '/nobody/ {print $2}'`; do (ipcrm -s $i); done
Restart apache
#/etc/init.d/httpd restart
[Sat Oct 10 00:11:01 2008] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten — Unclean shutdown of previous Apache run? semget: No space left on device
It means There is no more space left in Semaphore Arrays for Apache.
semaphore is a location in memory whose value can be tested and set by more than one process.
you can check the semaphore arrays on your server using the following command
ipcs -s
It results
------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 360448 nobody 600 1
0x00000000 393217 nobody 600 1
0x00000000 425986 nobody 600 1
0x00000000 458755 nobody 600 1
0x00000000 524292 nobody 600 1
0x00000000 1114117 nobody 600 1
0x00000000 1441798 nobody 600 1
0x00000000 3604487 nobody 600 1
0x00000000 3702792 nobody 600 1
0x00000000 3768329 nobody 600 1
0x00000000 6422538 nobody 600 1
0x00000000 7077899 nobody 600 1
If here you get big list of semaphores it means some semaphores are stuck. You can clear them out with this command:
for i in `ipcs -s | awk '/nobody/ {print $2}'`; do (ipcrm -s $i); done
Restart apache
#/etc/init.d/httpd restart
2010/01/05
VPS : tty device is not owned by group `tty’
If you’re unable to SSH into a VPS server, try accessing the VPS from the OpenVZ hardware node.
[root@VS ~]# vzctl enter VID
entered into VE 1022
mesg: error: tty device is not owned by group `tty’
Here you can see that there is an error related to tty. This error can be resolved by changing the group of the tty files.
vzctl exec VIS'chgrp tty /dev/ttyp* /dev/ptyp*'
There can be many other reasons related to SSH failures.
You might like check on udev package also (You will normally find this issue on CentOS5)
Find the udev rpm on the VPS server,
root@vps1 [/]# rpm -qa | grep udev
udev-095-14.16.el5
Remove it from the server
root@vps1 [/]# rpm -e –nodeps udev
Once this is done, your SSH should start working fine.
[root@VS ~]# vzctl enter VID
entered into VE 1022
mesg: error: tty device is not owned by group `tty’
Here you can see that there is an error related to tty. This error can be resolved by changing the group of the tty files.
vzctl exec VIS'chgrp tty /dev/ttyp* /dev/ptyp*'
There can be many other reasons related to SSH failures.
You might like check on udev package also (You will normally find this issue on CentOS5)
Find the udev rpm on the VPS server,
root@vps1 [/]# rpm -qa | grep udev
udev-095-14.16.el5
Remove it from the server
root@vps1 [/]# rpm -e –nodeps udev
Once this is done, your SSH should start working fine.
Subscribe to:
Posts (Atom)