Resolving df and du reporting different output
Thu, 01/14/2010 - 14:54 — sandipIf df and du give different output of disk usage. Then, most probably it is due to "open file descriptors".
Run `lsof +L1` to get a listing of open files that have been unlinked or removed. Note the file size and kill or restart the respective service.
Reference: walkernews.net
- sandip's blog
- Login or register to post comments
- Read more
HP Deskjet F2430 printing in Ubuntu-9.10
Sat, 12/19/2009 - 16:20 — sandipAlthough the printer HP Deskjet F2430 was automatically detected upon usb connection to my ubuntu-9.10 desktop, the 3.9.8 version of hplip that came via apt repository did not quite get printing to work.
I headed off to hplipopensource.com, downloaded and installed the latest driver (version 3.9.12 as of this writing) and got the all-in-one printer to work just following the install wizard.
I have yet to test the scanner... but that's going to be another update.
Extending ext3 partition
Sat, 12/19/2009 - 14:09 — sandip*** Make sure you have a back up prior to proceeding. ***
-
Boot into rescue mode.
Unmount partition if mounted and check disk:
umount /dev/sda1
e2fsck -vn /dev/sda1
fdisk /dev/sda
Run partprobe and resize2fs utility with no size arguments:
partprobe /dev/sda
resize2fs /dev/sda1
- sandip's blog
- Login or register to post comments
Shrinking ext3 partition
Sat, 12/19/2009 - 00:59 — sandip*** Make sure you have a back up prior to proceeding. ***
-
Boot into rescue mode.
Unmount partition if mounted and check disk:
umount /dev/sda1
e2fsck -vn /dev/sda1
tune2fs -O ^has_journal /dev/sda1
e2fsck -vf /dev/sda1
resize2fs /dev/sda1 6000M
dumpe2fs /dev/sda1
fdisk /dev/sda
Run partprobe and resize2fs utility with no size arguments:
partprobe /dev/sda
resize2fs /dev/sda1
Note: If resize2fs errors out, you may need to further increase the block size by a small percentage (3 to 5%).
Run a disk check for the final time before restoring the journal.e2fsck -vn /dev/sda1
tune2fs -j /dev/sda1
- sandip's blog
- Login or register to post comments
Exclamations in the body of phplist emails resolved
Thu, 12/17/2009 - 22:23 — sandipPHPlist using phpmailer, by default sets to send email with Content-Transfer-Encoding set to 8-bit. However, mail transport standards forbid lines longer than 998 characters and has to handle such non-compliant lines by breaking/folding them, or the next hop MTA (Mail Transfer Agent) might reject the message or truncate the lines.
The fix for the problem is to use "base64" or "quoted-printable" encoding, which will fold the lines in a way that can be undone by the recipient MUA (Mail User Agent).
If using phplist with phpmailer, the file to edit would be "admin/phpmailer/class.phpmail
var $Encoding = "base64";
PostgreSQL role based password authentication
Wed, 12/16/2009 - 14:30 — sandipTo manage/setup role based password authentication for postgresql database.
Modify "/var/lib/pgsql/data/pg_hba.co
host samerole &nbs p; all &nb sp; 127.0.0.1/32 md5
Save the below script and run:
./db_setup.sh <DBNAME> <DBMAINUSER> <DBMAINUSERPASS> create
#!/bin/bash
# db_setup.sh
USAGE="Usage: $0 <DBNAME> <DBMAINUSER> <DBMAINUSERPASS> <create|drop>"
DBNAME=${1?"$USAGE" ;}
DBMAINUSER=${2?"$USAGE& quot;}
DBMAINUSERPASS=${3?"$US AGE"}
# Create new database + main user
#
create_db_and_mainuser() {
psql -U postgres template1 -f - <<EOT
CREATE ROLE ${DBNAME} NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOLOGIN;
CREATE ROLE ${DBMAINUSER} NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${DBMAINUSERPASS}';
GRANT ${DBNAME} TO ${DBMAINUSER};
CREATE DATABASE ${DBNAME} WITH OWNER=${DBMAINUSER};
EOT
}
# Remove database + main user
#
drop_db_and_mainuser() {
psql -U postgres template1 -f - <<EOT
-- TERMINATE CONNECTIONS OF ALL USERS CONNECTED TO <DBNAME>
DROP DATABASE ${DBNAME};
DROP ROLE ${DBMAINUSER};
DROP ROLE ${DBNAME};
EOT
}
# Main
case "$4" in
create)
create_db_and_mainuser
;;
drop)
drop_db_and_mainuser
;;
*)
echo $USAGE
exit 1
;;
esac
exit 0
You should now be able to connect using:
psql -U <DBMAINUSER> -d <DBNAME> -h 127.0.0.1
- sandip's blog
- Login or register to post comments
- Read more
Relay email via SMTP provider using sendmail
Wed, 12/16/2009 - 00:02 — sandipThe below is specific to CentOS-5.4 and may work similarly with other distros.
-
Additional packages required if not installed already:
Edit ”/etc/mail/sendmail.mc”:sendmail-cf
m4
make
cyrus-sasl-plain
define(`SMART_HOST', `{smtprelay.domain.tld}') dnl
FEATURE(`authinfo',`has h -o /etc/mail/authinfo.db')dn l
AuthInfo:smtprelay.domain.tld "U:{username}" "P:{password}" "M:PLAIN"
cd /etc/mail
make
Now mails sent to localhost is relayed via your SMTP provider.
- sandip's blog
- Login or register to post comments
- Read more
drweb antivirus update cron output
Fri, 12/11/2009 - 14:20 — sandipA cron is run every 30 minutes to check on virus database updates via /etc/cron.d/drweb-update, which cause a slew of emails addressed to drweb and filling up mail queue, since drweb does not have a maildir.
To resolve, direct the output to /dev/null or to a log file instead... if you need to keep a watch on the updates.
Edit /etc/cron.d/drweb-update redirecting the output to a log file:
*/30 * * * * drweb /opt/drweb/update.pl >>/tmp/drweb_update.log
If you still want to deliver the output, this can be done by directing drweb mail to root via "/var/drweb/.qmail" or "/var/qmail/alias/.qmail-drweb
- sandip's blog
- Login or register to post comments
Optimize PostgreSQL Database Size
Wed, 12/09/2009 - 11:55 — sandipRecently, I noticed that the postgresql database partition had been filled up. The general advice is to export data, drop and recreate database and import the data back in, since this would save a lot of time and also reduce the database size comparatively.
Reference: optimize postgresql database size.
Not too sure, if I wanted to go the dump and restore route, so decided to vacuum and reindex instead.
To my surprise, I did regain about 70% of space running the full vacuum and reindexing the database.
-
Full vacuum reduced the database size from 8GB to 4GB.
vacuumdb -afzv | tee /tmp/vacuumdb.log
reindexdb -a | tee /tmp/reindexdb.log
Check the vacuumdb.log for database optimization notices.
It is also advised to reindex prior to vacuuming to further save on vacuum time.
- sandip's blog
- Login or register to post comments
- Read more
#2002 - The server is not responding
Fri, 12/04/2009 - 17:13 — sandipPhpMyAdmin Error:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
There are various reasons for this error. Several things to check are:
-
Edit config.inc.php file, and specify '127.0.0.1' (instead of any other value like 'localhost) for the $cfg['Servers'][$i]['host'] setting as follows:
$cfg['Servers'][$i][ 'host'] = '127.0.0.1';
[mysqld]
socket=/tmp/mysql.sock
old-passwords
[client]
socket=/tmp/mysql.sock
Only add the 'old-passwords' mentioned above if you are using an older version of PHP (PHP4).
Make sure that you do not have any older versions of MySQL installed that are conflicting.Edit config.inc.php file, and specify the MySQL socket location (as seen in the above [mysqld] socket setting):
For example, if your MySQL socket is /tmp/mysql.sock, find the line in config.inc.php that has the $cfg['Servers'][$i]['socket'] setting and change it to:
$cfg['Servers'][$i][ 'socket'] = '/tmp/mysql.sock';
$cfg['Servers'][$i][ 'connect_type'] = 'socket';
If there is no such setting, simply add in the above line and re-try.
Add this entry to php.ini file (again changing the '/tmp/mysql.sock' to your actual socket location) and restart Apache:mysql.default_socket = "/tmp/mysql.sock"
Edit the config.inc.php using the phpmyadmin /setup configuration page:In the setup screen, select the end-of-line character to be '\r' if you have a Macintosh, or '\n' for a Linux machine.
Disable SELinux if you are using it, and re-try. If it works, SELinux is the issue.Run the following at your mysql prompt (using the standard mysql client):
mysql> SELECT USER,HOST FROM mysql.user;
Next, identify the user your are using for phpMyAdmin, and then run:
mysql> SHOW GRANTS FOR 'user'@'host 39;;
Ensure that this userid has appropriate access rights.