Using myisamchk for Crash Recovery in cPnael

If you run mysqld with external locking disabled (which is the default), you cannot reliably use myisamchk to check a table when mysqld is using the same table.

If the server is run with external locking enabled, you can use myisamchk to check tables at any time. In this case, if the server tries to update a table that myisamchk is using, the server will wait for myisamchk to finish before it continues.

If you use myisamchk to repair or optimize tables, you must always ensure that the mysqld server is not using the table (this also applies if external locking is disabled). If you do not stop mysqld, you should at least do a mysqladmin flush-tables before you run myisamchk. Your tables may become corrupted if the server and myisamchk access the tables simultaneously.

When performing crash recovery, it is important to understand that each MyISAM table tbl_name in a database corresponds to the three files in the database directory shown in the following table.

File Purpose
tbl_name.frm Definition (format) file
tbl_name.MYD Data file
tbl_name.MYI Index file

Each of these three file types is subject to corruption in various ways, but problems occur most often in data files and index files.

myisamchk works by creating a copy of the .MYD data file row by row. It ends the repair stage by removing the old .MYD file and renaming the new file to the original file name.

myisamchk -e tbl_name

This does a complete and thorough check of all data (-e means “extended check”). It does a check-read of every key for each row to verify that they indeed point to the correct row. This may take a long time for a large table that has many indexes. Normally, myisamchk stops after the first error it finds. If you want to obtain more information, you can add the -v (verbose) option. This causes myisamchk to keep going, up through a maximum of 20 errors.

Reference: http://dev.mysql.com/

Block IP Addresses With IPtables:

This command will simply drop any packet coming from the address 25.55.55.55. To list the chains:

iptables -I INPUT -s 25.55.55.55 -j DROP

The -n sticks with just IP addresses, rather than resolving the name. This is useful if you have a lot of IP addresses. It can take a lot of time to resolve all of the addresses.

iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all — 25.55.55.55 0.0.0.0/0

If you later decide that you don’t want to drop packets from a particular host, use the -D option instead of -I:

iptables -D INPUT -s 25.55.55.55 -j DROP

SSH Security On cPanel Servers.

1. Change SSH port number.

Edit your ssh configuration file under /etc/ssh/sshd_config and add/replace this line:

# What ports, IPs and protocols we listen for
Port 22

2. Allow only the IP’s that you would like to have access to SSH through your firewall.

iptables -A INPUT -i eth0 -s 192.168.1.1 -p tcp –dport 22 -j ACCEPT

3. Use a utility like BFD, BlockHosts and DenyHosts

denyhosts - a utility to help system admins thwart ssh crackers

4. Use iptables to limit the rate of incoming connections to SSH.

iptables -I INPUT -p tcp –dport 22 -i eth0 -m state –state NEW -m recent –update –seconds 60 –hitcount 4 -j DROP

This will limit incoming connections to port 22 to no more than 3 attempts in a minute. Any more will be dropped.

Managing an Exim 4 server.

Remove mails by ID.

/usr/sbin/exim -v -Mrm (MAIL ID HERE)

List queded mails.

/usr/sbin/exim -bp

Output the number of queded mails.

/usr/sbin/exim -bpc

Delete frozen mails.

/usr/sbin/exim -bp | awk ‘$6~”frozen” { print $3 }’ | xargs exim -Mrm

Deliver forcefully emails.

/usr/sbin/exim -qff -v -C /etc/exim.conf &

Freeze Mails from the sender.

/usr/sbin/exiqgrep -i -f (MAIL ADDRESS HERE) | xargs exim -Mf

Remove mails from the sender.

/usr/sbin/exiqgrep -i -f (MAIL ADDRESS HERE) | xargs exim -Mrm

Files in /var/spool/exim/msglog contain logging information for each message and are named the same as the message-id.

Exim includes a utility that is quite nice for grepping through the queue, called exiqgrep.
http://www.exim.org/exim-html-4.50/doc/html/spec_49.html#IX2895

Reference: http://www.exim.org/

Testing Link Status from the Command Line

mii-tool and ethtool commands command will provide reports on the link status and duplex settings for supported NICs.

root@laptop:~# mii-tool
eth0: negotiated 100baseTx-FD flow-control, link ok

ethtool - Display or change ethernet card settings.
ethtool is used for querying settings of an ethernet device and changing them. ethX is the name of the ethernet device on which ethtool should operate. ethtool with a single argument specifying the device name prints current settings of the specified device.

root@laptop:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0×00000000 (0)
Link detected: yes

« Prev - Next »