Архив рубрики: Linux

mod_fcgid: Too many open files

Сегодня возникла проблема с некоторыми сайтами, они долго грузились и выдавало в итоге 5хх ошибку. Всё это работает в связке nginx <-> apache <-> mod_fcgid на линухе. Глянув логи апача увидел:

[Wed Oct 21 10:11:20 2009] [error] (24)Too many open files: mod_fcgid: couldn't set child process attributes: /var/lib/apache2/fcgid/sock/12336.1878
[Wed Oct 21 10:11:20 2009] [warn] (24)Too many open files: mod_fcgid: spawn process /home/*.php error

Сразу же полез смотреть /proc/sys/fs/file-max и /proc/sys/fs/file-nr, но всё было нормально. Максимальное количество файлов установлено выше крыши — 203364.

Но, вдруг, я вспомнил о такой замечательной вещи как ulimit. Само собой… стандартное ограничение на количество открытых файлов для каждого процесса — 1024. Чтобы быстро решить эту проблему, добавил ulimit -n 3072 в init скрипт апача.

Copying a Filesystem between Computers

If you need to transfer an entire filesystem from one machine to another, for example, when you get a new computer, do the following steps.

1) Boot both PCs with any Linux live CD (for example, Knoppix), and make sure they can access each other via the network.

2) On the source machine, mount the partition containing the filesystem to be copied, and start the transfer using netcat and tar:

cd /mnt/sda1
tar -czpsf - . | pv -b | nc -l 3333

3) On the destination machine, mount the partition to receive the filesystem, and start the process:

cd /mnt/sda1
nc 192.168.10.101 3333 | pv -b | tar -xzpsf -

The nc (netcat) command is used for any kind of TCP connections between two hosts. The pv (progress viewer) command is used to display the progress of the transfer.
tar is used to archive the files on the source machine and un-archive them on the destination.

Источник: Linux Journal Issue 175

VIM: Find and Replace

There are a variety of options, but these are what you most probably want:

:%s/foo/bar/g find each occurance of 'foo' and replace it with 'bar' without asking for confirmation
:%s/foo/bar/gc find each occurance of 'foo' and replace it with 'bar' asking for confirmation first
:%s/<foo>/bar/gc find (match exact word only) and replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gci find (case insensitive) and replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gcI find (case sensitive) and replace each occurance of 'foo' with 'bar'

NB: Without the ‘g’ flag, replacement occurs only for the first occurrence in each line.