Tuesday, February 27, 2007

postfix - mailbox size limit and message size limit

postfix is my MTA of choice. I use it for my mailserver because its simplicity , security and sendmail-compatible (the widely used smtp in the world but not as secure). It is also extensible by plugging other servers for various purposes (antispam, antivirus,database etc).

I had one problem with file attachment larger than 10MB. Users couldn't send it although I have setup squirrelmail (SM) to be able to attach files summed up more than 20MB and I had modified php settings as per here. The problem was not in SM setting. It was postfix. By default, attachment size that can be sent by postfix is 10MB ~ 10240000 byte. How did I know it? I looked in log file (for my system it is in /var/log/mail/errors. For other system, the file to look is /var/log/maillog). The line looked like this:

Feb 26 16:30:53 webmail postfix/sendmail[30775]: fatal: me@mymailserver.org(74): Message file too big


Solution
Open /etc/postfix/main.cf with a text editor of choice and find message_size_limit directive and change accordingly. If it is not there, add the directive like this:

message_size_limit = 20480000

This sets limit to 20MB.

Some other parameters you need to change are in file php.ini which is usually located in dir /etc. Set their parameters as above or higher values as below:

post_max_size = 20M
upload_max_filesize = 20M

reload or restart postfix when you're done:


service postfix reload

or

service postfix restart

There's also mailbox_size_limit directive. You need to change this if SM can not open mailbox sized more than 10 MB.

reference :
http://www.tek-tips.com/viewthread.cfm?qid=1073614&page=1

Sunday, February 25, 2007

Tips for MySQL

MySQL is the most popular database in the world. I'm not doubt about it. Most of forums, portals and web-based database applications use it as the back-end engine.

Some tips of using MySQL on Linux

Login to MySQL using mysql client in console/terminal:

mysql -u username -p dbname

or

mysql -u username -ppassword dbname

or (using current username to log in)

mysql -ppassword dbname

security tip: username root is the default administrator. Do not use it in a live environment. Create a new one and set the appropriate permission for it.

Create a new database:
mysqladmin -u username -ppassword create databasename

(username is the administrator username that able to create a new database ie root)

or you can log in to mysql using mysql client in console. Example:

//create table with myisam engine.

CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=MYISAM


//create table with HEAP engine.

CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=HEAP

Delete a database:
Login to mysql and issue command drop database databasename.

(Make sure you use usernames with correct priviledge to drop a database)

What is the size of my database?
database size = the sum of all table sizes + all index sizes
  1. Open a text editor (eg. Notepad)
  2. Copy and paste the code below into your text editor ( replace username, password and dbid accordingly):

    mysql database size

    if ($filesize < filesize ="">

    # in at least kilobytes.

    for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;

    $file_size_info['size'] = ceil($filesize);

    $file_size_info['type'] = $bytes[$i];

    return $file_size_info; } $db_server = 'mysqlhost'; $db_user = 'username'; $db_pwd = 'password'; $db_name = 'dbid';

    $db_link = @mysql_connect($db_server, $db_user, $db_pwd)

    or exit('Could not connect: ' . mysql_error()); $db = @mysql_select_db($db_name, $db_link) or exit('Could not select database: ' . mysql_error());

    // Calculate DB size by adding table size + index size:

    $rows = mysql_query("SHOW table STATUS"); $dbsize = 0;

    while ($row = mysql_fetch_array($rows)) {$dbsize += $row['Data_length'] + $row['Index_length']; } print "database size is: $dbsize bytes "; print 'or';

    $dbsize = file_size_info($dbsize); print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>


put this php script into your accessible directory. (taken from here).

Nice reading : Overcoming MySQL's 4GB limit by Jeremy Zawodny.

To know what engine your database is using:

SHOW TABLE STATUS FROM yourdbname

MySQL has support for ISAM,MyISAM , HEAP, BerkeleyDB and InnoDB database engine. Depending on how your MySQL packages are compiled, it may or may not support for all these engines.

Bear in mind that ISAM and MyISAM engines lack foreign key and transactional support. BerkeleyDb and InnoDB overcome that limitation. However, BerkeleyDB and InnoDB are much slower compared to ISAM and MyISAM. If your database is of type ISAM/MyISAM, fortunately you can convert it to InnoDB using this command:

ALTER TABLE isamtable CHANGE TYPE=InnoDB

or you can use utility mysql_convert_table_format :

mysql_convert_table_format --user=username --pasword=password --type=innodb databasename tables

(if tables is omitted, all tables will be converted. That means you can convert certain tables to InnoDB and leave the rest with ISAM. One database uses more than one engine. That's the flexibility MySQL provides. Flexibility is the key here.)

MySQL makes this happen with three steps. First, an exact copy of the table is created. Next, any incoming data changes are queued, while the copy is moved to the other engine. Finally, any queued data changes are committed to the new table, and the original one is deleted.


Thursday, February 15, 2007

yum - 'yummy' package management for Fedora Core

As a Mandriva (aka Mandrake) user, I used to use urpmi to install, urpme to remove and etc2 for package management. As a Slackware user, I used to use slapt-get and in Fedora, I am learning yum. I love it but in commandline. Why? because it is faster that way than using the gui front-end. I don't know why but they need to improve its speed.

Some useful examples of usage :

Check available updates (without installing anything) : yum check-updates
Check updates and install : yum -y check-updates
Search for a particular package using wildcard : yum list "ogg*"
Installing particular package : yum install ogg-vorbis.blablaba.fc6.rpm
Upgrading a package : yum update ogg-vorbis.blablaba.fc6.rpm

Default repositories provided by FC6 is good enough but lack of commercial and copyrighted packages. You need more than that. Notable repositories are freshrpms and livna. I personally added freshrpms as one of the repositories used by yum to install xmms-mp3, mplayer, dvdrip and some other packages. Thus enables me to hear mp3 and watch movies. I just found out that adding fedora's update-testing repository is risky. Don't add it unless you want to live at the bleeding edge and could afford to lose all your data. :)

How to add 3rd-party repos?
Usually there are instructions on the websites on how to add their repos into your system or you can read my article on how to add livna and kde repositories. I read somewhere to not add both livna and freshrpms repos. Add ONLY one of them or conflicts of packages will happen. You have been warned!.

To add freshrpms repo, just run this command as root:

yum install http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/6/freshrpms-release/
freshrpms-release-1.1-1.fc.noarch.rpm (all in one line.)

Tuesday, February 6, 2007

On a quest to get a 3D desktop part 2



You might still wondering whether i am still on a quest to get a 3D desktop? Not really. After reading an article of Fedora Core 6 in LinuxFormat magazine, I thought I need to give it a try. Firstly, I tried it on a laptop with built-in graphic card Intel 915. It ran smoothly. 3D effects for compiz and beryl worked out of the box. I just had to activate it.

After too much coin tossing and coffee, I decided to give FC6 a try on my office's PC. After backing up all important files, I inserted the DVD and rebooted into the nice Fedora installer a.k.a anaconda. I decided to repartition my drive to give larger part for my / partition and created 3 more partitions for /home,/boot and of course a /swap. As a rule of thumb, /swap size is 2 times RAM size.

GNOME is some sort of 'official' window manager for Fedora and RedHat. That's why after booting into X, GNOME was loading. To get 3D effects, click on System -> Preferences -> Desktop Effects. This was compiz actually loading replacing metacity. Future release of GNOME and KDE will support 3D effects on the fly. As for time being, compiz or Beryl compositing window manager provides the effects. Beryl provides much more effects as anyone could imagine. Experiment it and you will be amazed what it can do. The 3D cube is superb!.

Now the quest has ended. The 3D desktop is mine!. Try it.

Some tips for beryl :
F9 or place mouse cursor at the topleft corner - tiled windows in a viewport
Ctrl+Alt+LeftArrow - spin cube to the left
Ctrl+Alt+RightArrow - Spin cube to the right
Ctrl+Alt+Shift+RightArrow/LeftArrow - Spin cube to the right or left with active window follows.
place mouse cursor at the bottomright corner - centers active window.

Second monitor no display after latest update - KDE-neon

 After latest update as of Oct 3, 2023, my second monitor was undetected with latest kernel (6.2.0-33-generic). If I boot with previous kern...