Tuesday, 27 January 2009

Repair a MySQL database or table - Linux

You have a MySQL database that needs to be repaired. There are a couple of ways you can do this. It is ideal to do these while mysqld is not running.

The first way is to use mysqlcheck

mysqlcheck -oCvf --auto-repair 


The next way is it use myisamchk. Myisamchk is used only to repair myisam tables so you would need to be within the database directory to run this command on .MYI files.

cd /var/lib/mysql/
myisamchk -r -q *MYI


If you know what table needs to be repaired then you can use myisamchk and repair just that .MYI file or you can use mysql directly. This of course will be done while mysqld is running.

mysql -uroot -p 
mysql> repair table ;


Please use these at your own discretion. We take no responsibility for data loss

Saturday, 24 January 2009

How to configure remote backups through NFS.

First, you have to make the appropriate directories available to nfs by "exporting" them. On the remote server, edit the /etc/exports file to expose the directories you need to the hosts that need to access them. See the man page for exports to find out all your options, but here's a simple example from my setup

# /etc/exports

/backup 192.168.1.0(rw,no_root_squash,async)

/backup2 192.168.1.1(rw,no_root_squash,async)


The /etc/exports file must contain a directory, (in this example the directory being exported is /home), as well as the networks (or hosts) the file system is exported to.

In this case it's exported a range of hosts in the network 192.168.1.0. Alternately, it could be exported to a single host using the configuration:

Then go to virtozzo and mount the destination as given below:
[root@sertechs]# mount -t nfs 192.168.1.0:/backup2 /vz/backups

To check if it is mounted or not you can use showmount -e or mount command

Then write /etc/fstab as given below:

198.168.0.1:/backup2 /vz/backup nfs rsize=1024,wsize=1024,noauto 0 0



Then restart nfs and portmap on Virtuzzo server


[root@sertechs]# /etc/init.d/portmap restart

[root@sertechs]# /etc/init.d/nfs restart

Then go to backup server and check if its mounted on this server as well, you can use to check it showmount -e or mount command

If everything is ok, fire the command to effect the changes of /etc/exports:
[root@backup01 backup2]# exportfs -r


and restart both services on this server as well:


[root@sertechs]# /etc/init.d/portmap restart

[root@sertechs]# /etc/init.d/nfs restart


Feel free to contact incase you need any further information or help @

admin@servertechs.co.cc



Monday, 19 January 2009

Microsoft OLE DB Provider for SQL Server error '80004005'

Error Message:

Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/test.asp, line 6

Cause:

1. You have connected to a wrong MSSQL server
2. Your database username and password might be incorrect.

Solutions:

1. Make sure that the database connection is well defined with the correct MSSQL host, port (if required, else optional), database username and password.

Additional Information:

1. If you are Windows 2003 hosting client, you may double check on your database information by :
a. Login into HELM control panel
b. Go to "Domains" >> select the domain name >> "Database Manager"
c. Click on the database name from the list
d. Refer "Connection Information" for MSSQL Server Host, database user is listed under the"Database Users" section.
e. You may manage the database user by click on the database user name or click on "Add New" to setup a new database user

2. If you are Windows 2000 hosting client, please contact our System Engineer for further information as domain hosted on Windows 2000 server has been migrated to Windows 2003 server.

Tuesday, 13 January 2009

Removing old Kernels | cPanel moaning about / partition

You’ll often find lots of kernels sitting on the server when it’s moaning about the / partition being full. It’s a simple job to remove them.

First, we’ll find out what kernels are sitting on the server:

rpm -qa | grep kernel

Once we know which ones are on the server, we need to find out what kernel we’re running:

uname -r

Now, we need to remove all the old kernels from the server and keep the one we’re running (the output from uname -r)

rpm -e [list all the kernels we don't want here]

MAKE SURE YOU RETAIN THE PACKAGE WITH -utils-

How to install APF (Advanced Policy Firewall)

1. cd /root/downloads or another temporary folder where you store your files

2. wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz

3. tar -xvzf apf-current.tar.gz

4. cd apf-0.9.5-1/ or whatever the latest version is.

5. Run the install file: ./install.sh

You will receive a message saying it has been installed

Installing APF 0.9.5-1: Completed.

Installation Details:
Install path:         /etc/apf/
Config path:          /etc/apf/conf.apf
Executable path:      /usr/local/sbin/apf
AntiDos install path: /etc/apf/ad/
AntiDos config path:  /etc/apf/ad/conf.antidos
DShield Client Parser:  /etc/apf/extras/dshield/

Other Details:
Listening TCP ports: 1,21,22,25,53,80,110,111,143,443,465,993,995,2082,2083,2086,2087,2095,2096,3306
Listening UDP ports: 53,55880
Note: These ports are not auto-configured; they are simply presented for information purposes. You must manually configure all port options.

Now you will have to edit /etc/apf/conf.apf and change

DEVEL_MODE from 1 to o and also add TCP and UDP posts as provided the installation complete message.

Saturday, 10 January 2009

Modifying SMTP Relay Settings for Exim

cPanel’s stock installation of Exim includes a Tailwatchd driver called Antirelayd . Antirelayd is a daemon that checks /var/log/maillog for POP3 and IMAP logins and keeps track of valid logins for SMTP relaying. It reads /etc/relayhosts file automatically which is dynamically-updated, so any IPs that you add to this file will not be retained.

By default on all cPanel servers, authentication is required to send email via SMTP. Exim lets you authenticate two ways:

  • Directly through SMTP with a valid username/password

  • Through POP3 login, which allows the user to relay through the mail server for 30 minutes without re-authenticating


To always force SMTP authentication regardless of POP authentication, type the following command via SSH as root:
/usr/local/cpanel/bin/tailwatchd –disable=Cpanel::TailWatch::Antirelayd

To reverse this setting back to the default:
/usr/local/cpanel/bin/tailwatchd –enable=Cpanel::TailWatch::Antirelayd

You can alternatively disable/enable Antirelayd in WHM > Service Manager.

It’s generally not a good idea to allow open relaying through your mail server unless you want to get blacklisted.  There may be situations where you need to permanently let another server send mail through your server without authentication, in which case you can add their IP to /etc/alwaysrelay . A post in the cpanel forums suggests an alternate solution as well:

In WHM > Exim Configuration Editor > Advanced Editor, find this section:

accept hosts = +auth_relay_hosts
endpass
message = $sender_fullhost is currently not permitted to
relay through this server. Perhaps you
have not logged into the pop/imap server in the
last 30 minutes or do not have SMTP Authentication turned on in your email client.
authenticated = *


Appended to this suggestion is changing:

accept hosts = +auth_relay_hosts

to

accept hosts = /etc/exim_smtp_whitelist

There are minor tweaks you can make to exim.conf to remove SMTP authentication altogether, but you won’t find that information here. We don’t want to encourage bad mail server setup that will make the SPAM problem on the Internet even worse.

You can test to see if your server is open relay by sending an email via Telnet and getting a 550 error:

:~$ telnet thecpaneladmin.com 25
Trying 69.174.52.38...
Connected to thecpaneladmin.com.
Escape character is '^]'.
220-thecpaneladmin.com ESMTP Exim 4.69 #1 Tue, 23 Feb 2010 20:37:54 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
helo thecpaneladmin.com
250 thecpaneladmin.com Hello myserver.com [x.x.x.x]
mail from: admin@thecpaneladmin.com
250 OK
rcpt to: test@test.com
550-vaoffice.inmotionhosting.com (thecpaneladmin.com) [68.106.154.170] is
550-currently not permitted to relay through this server. Perhaps you have not
550-logged into the pop/imap server in the last 30 minutes or do not have SMTP
550 Authentication turned on in your email client.

Thursday, 1 January 2009

Installing PHP from source on CentOS x86_64 (w/ apache)

Installing PHP from source is much easier than most people think. In this tutorial I will describe how to install a bare PHP build with mysql/mysqli support in addition to configuring apache to interpret PHP scripts.

Compiling PHP Source

Alright, well in order to compile the php source code you must first have gcc install (# yum install gcc). Also if you want to be able to use PHP in apache then you need to have httpd and httpd-devel packages installed. Here is how I did my install. (Please note that I used PHP 5.2.6 for my install, but this will work with just about any php version, just be sure to untar and cd into the proper directory for your version of php.)

[root@nitrogen ~]# yum install gcc-c++ httpd httpd-devel apr-devel libxml2-devel zlib zlib-devel mysql-devel openssl-devel
[root@nitrogen ~]# wget http://www.php.net/get/php-5.2.6.tar.gz/from/this/mirror
[root@nitrogen ~]# tar -zxvf php-5.2.6.tar.gz
[root@nitrogen ~]# cd php-5.2.6
[root@nitrogen cd php-5.2.6]# ./configure –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-apxs2 –with-libdir=lib64 –with-mysql –with-mysqli –with-zlib
[root@nitrogen cd php-5.2.6]# make clean
[root@nitrogen cd php-5.2.6]# make
[root@nitrogen cd php-5.2.6]# make install


You’re also going to want to place a php.ini into /etc/php.ini and make the /etc/php.d directory if you have not done so already.

[root@nitrogen cd php-5.2.6]# cp php.ini-recommended /etc/php.ini
[root@nitrogen cd php-5.2.6]# mkdir /etc/php.d


Installing PHP into apache

To install PHP into apache all you need to do is place the following configuration file in /etc/httpd/conf.d/php.conf.

# /etc/httpd/conf.d/php.conf
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages
#


LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php


#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php


#
# Uncommenting the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps


Finalizing our install is fairly simple, just restart apache by typing the following command and you should be good to run PHP applications for the web.

[root@nitrogen ~]# /sbin/service httpd restart