Change mysql server time zone

Filed Under (Databases) by jc on 30-03-2009

If you want mysql to have a different timezone than your server’s, here are the steps:

1) Run the following command to populate mysql’s timezone tables:

mysql_tzinfo_to_sql /usr/share/zoneinfo |mysql mysql

2) in the [mysqld] section of /etc/my.cnf, add the following line:

default-time-zone='US/Eastern'
(change US/Eastern with the desired timezone of course. It should match the format of /usr/share/zoneinfo)

3) Restart mysql

To check you mysql server’s time run the following query:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-03-30 16:21:20 |
+---------------------+
1 row in set (0.00 sec)

–JC

md5sum on MySQL results

Filed Under (Databases) by jc on 25-03-2009

Tagged Under :

This morning I read a twit about a blog post from xapbr.com (http://www.xaprb.com/blog/2009/03/25/mysql-command-line-tip-compare-result-sets/).

Pretty nifty tip on how to get a MD5 Checksum on a result set from a query. This can be very helpful when you are optimizing queries that return a very large set of results and you need to make sure they match.

mysql> pager md5sum -
PAGER set to 'md5sum -'
mysql> select * from test;
a09bc56ac9aa0cbcc659c3d566c2c7e4 -
4096 rows in set (0.00 sec)

–JC

LogFilesList->init() failed: filemng failed: filemng: stat failed: Permission denied

Filed Under (Plesk) by jc on 21-02-2009

Tagged Under : , ,

If you get this error when trying to access Log Manager, this happens because filemng which runs as psaadm user does not have permission to access the directory. You can get a similar error on the File Manager:

Error: Unable to change directory to /statistics: filemng failed: filemng: opendir failed: Permission denied

To fix this problem make sure psaadm is part of the psaserv group in /etc/group

–JC

How to have Tomcat bind to port 80 and still run as a non-root user

Filed Under (Installations, Web) by jc on 26-07-2008

Tagged Under :

In order to have Tomcat listen on port 80, you either have to have it running as root (which by the way is not a very good idea), or configure a wrapper like JSCV.

Here is how you do it (This is an example using tomcat 6 please adapt to your install):

# cd /opt/apache-tomcat-6.0.16/bin/
# tar -zxvf jsvc.tar.gz
# cd jsvc-src
# chmod +x configure
# ./configure ; make
# cp jsvc ..

——————

Change your connection in server.xml to use port 80.

—————–

Start tomcat with a variation of the following init script:

tomcatjsvc.txt

As usual, let me know if you find any errors or a better way of doing it.

–JC

Bind Mounts are Hot

Filed Under (File Systems, OS, Red Hat) by jc on 24-05-2008

Tagged Under : , , , , ,

Bind mounts are awesome to mount stuff that is already mounted somewhere else. In my case, a customer added a additional hard drive to his server because he needed some extra space for one of the domains he was hosting on the server. Other than messing with RAID and trying to extend the file system we had a couple of options:

1. We could mount the whole drive as /path/to/his/domain

2. Mount the new drive as something like /mnt/newdrive and sym linking the domain to the new drive.

3. Mount the new drive as something like /mnt/newdrive and mount the domain directory as a bind mount.

I thought the third option was sexier since option number one could be a waste if the domain did not use all the available space on the drive and for option number two, some applications sometimes do not like the idea of following sym links, including open_basedir restrictions, etc.

Here is what I did:

On /etc/fstab mount new drive:

/dev/sdb1 /mnt/newdrive ext3 defaults 0 0

Move domain contents to new drive:

mv /var/www/vhosts/bigdomain.com /mnt/newdrive/bigdomain.com

On /etc/fstab add the bind mount:

/mnt/newdrive/bigdomain.com /var/www/vhosts/bigdomain.com bind defaults,bind 0 0

Now, for the new mounting points just run:

mount -a

Any suggestions are welcome.

–JC