Nombre total de pages vues

mercredi 19 janvier 2011

Automatically load kernel modules at boot time

If you need to load some modules when server boot, you have to do the following:
echo "modprobe [module_name]" > /etc/sysconfig/modules/[module_name].modules
chmod +x /etc/sysconfig/modules/[module_name].modules
Here is an example with fuse module:
echo "modprobe fuse" > /etc/sysconfig/modules/fuse.modules
chmod +x /etc/sysconfig/modules/fuse.modules
On the next reboot, /etc/rc.sysinit script will load all scripts that located into /etc/sysconfig/modules directory.

How to compile MySQL 5.5 from sources

MySQL released 5.5 version in December 2010. This version seems to be more efficient with improvements like better improved scalability on multi-core CPU, InnoDB storage engine becomes the default engine for new tables or integration of semisynchronous replication. This version is recommended for production environments. It's interesting for administrator to thinking about upgrading. Much systems executes 5.1 version and sometimes the upgrade can be scary ... Here we are going to see how to install 5.5 version on new systems. First we need to install some packages that are needed by MySQL. So installs (or be sure that they all have been installed): bison, bzr, cmake, gcc-c++ ncurses-devel.
yum install -y bison bzr cmake gcc-c++ ncurses-devel
Then add new mysql account and group:
groupadd mysql
useradd -r -g mysql mysql
Now we need download last mysql 5.5 tar.gz archive, choose the mirror directly on mysql website.
wget http://URL_OF_MIRROR/mysql-5.5.16.tar.gz
Extracting tar.gz archive
tar -xvzf /downloads/mysql-5.5.16.tar.gz
Now go into extracted directory and execute cmake:
cd /downloads/mysql-5.5.16/
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_DATADIR=/var/lib/mysql \
-DSYSCONFDIR=/etc \
-DINSTALL_PLUGINDIR=/opt/mysql/lib/mysql/plugin
Note that I use /opt/mysql for basedir /var/lib/mysql for datadir, you can use others directories by specifing them with 'DCMAKE_INSTALL_PREFIX' and '-DMYSQL_DATADIR' options. When cmake finish to work, we can launch the make .
make
Next, if we don't encounter errors, we launch the install:
make install
Now, we create symbolic links to have mysql commands in shell:
ln -s /opt/mysql/bin/* /usr/bin/
Assign owner and group:
cd /opt/mysql/
chgrp -R mysql .
chown -R root .
chown -R mysql data
Default database installation:
scripts/mysql_install_db --user=mysql \
--datadir=/var/lib/mysql/
Copy a mysql default configuration file:
cp support-files/my-medium.cnf /etc/my.cnf
Copy mysql init.d script and make it executable:
cp support-files/mysql.server /etc/init.d/mysql.server
chmod 755 /etc/init.d/mysql.server
Now edit this init.d script for customize both basedir and datadir paths:
vim /etc/init.d/mysql.server
## replace
basedir=
basedir=

## by
basedir=/opt/mysql
datadir=/var/lib/mysql

## save and exit
:wq
Finally, we can launch mysql server and begin to use it:
/etc/init.d/mysql.server start

samedi 15 janvier 2011

Download RPM packages with yum

Yum don't keeps RPM packages when you install from itself. So when you need to backup those packages locally, it's interesting to have a way for do this. There is few methods that permit to do it. First method is to configure yum.conf with keepcache=1, packages will be archived into path who is specified into cachedir parameter. Problem is that system will download packages for the future but packages that have already been installed will be not stocked in the cachedir path.
vi /etc/yum.conf

cachedir=/var/cache/yum
keepcache=1
Second method is to use yum-downloadonly. This is a yum plugin that adds --downloadonly flag to yum. With this method yum is going to download RPM packages without install or update them. Plugin adds two options to yum: --downloadonly : indicates to yum to just download without install or update packages. --downloaddir=/path/to/dir : specifies directory for storing packages. Here we are going to download and install this yum plugin:
yum install yum-downloadonly -y
Now we can use two news flags that were added to yum: Here we donwload vsftpd in the current directory (we can use install or update, done the same):
yum install vsftpd -y --downloadonly
Or we can download vsftpd to home directory:
yum update vsftpd -y --downloadonly --downloaddir=/home
vsftpd package is now stored into /home:
ls /home/*
Same problem for this second method: if packages are already installed on this CentOS server, yum don't downloads packages and says "already installed and latest version" or "No Packages maked for Update". Third method consists to use yumdownloader which is included into yum-utils. yum-utils is a collection of tools that permit yum to be most complete. So we have to install yum-utils with:
yum install yum-utils -y
Now we can download easily packages from CentOS repositories. This method is more fun because we can now download packages that are already installed on server. For example we check that vsftpd is already installed:
rpm -qa | grep vsftpd
vsftpd-2.0.5-16.el5_5.1
And now we download this package from repository to store it into home directory:
yumdownloader vsftpd --destdir /home
Then:
ls /home/*
vsftpd-2.0.5-16.el5_5.1.i386.rpm
Possibles options for yumdownloader are: --destdir : to specify where to store packages --urls : list the urls it would download instead of downloading --resolve : resolve dependancies and download required packages --source: operate on source packages --archlist: only download packages of certain architectures (i386,i686,x86_64,noarch) Last method can be an alternative method, but it's not the better way. It consists to use wget. With wget we can download directly packages from an url but we have to know exactly where packages are stored on the web. Sometimes it's difficult to guess if package come from base repo or from updates repo, so this method is useful in some context. If wget command isn't available you have to install it with:
yum install wget -y
Then you can download package from url with wget:
wget http://mirror.ate.info/ftp.centos.org/5.5/updates/i386//RPMS/vsftpd-2.0.5-16.el5_5.1.i386.rpm
Package will be stored into current directory. To store it into another directory, use this command instead:
wget http://mirror.ate.info/ftp.centos.org/5.5/updates/i386//RPMS/vsftpd-2.0.5-16.el5_5.1.i386.rpm -P /home
It will be stored into home directory. I hope this article can help you and it will give you better way to handle RPM packages with the powerful yum.