воскресенье, 3 апреля 2011 г.

Удаление триггеров bucardo в Postgres

Для сервисных нужд я иногда использую bucardo. Утилита внятная. Четкая документация. Работает и не жужжит :)

У нее есть одна особенность - она не удаляет триггеры из базы, даже если мы убираем ее из обработки. Это было бы не страшно, если бы лишние триггеры не замедляли работу базы. Поэтому для удаления bucardo-триггеров была написана следующая функция:


Исполнение, как обычно:

select strip_bucardo_triggers();

вторник, 29 марта 2011 г.

"Raising Elephants" mnemonic device

The section was removed from Wiki with the following comment: Removed section. I strongly feel it doesn't belong. There's no magic formula and REISUB doesn't seem like a good idea either.

I do not think so. So here is the removed section:

---
A common idiom to perform a safe reboot of a Linux computer which has otherwise locked up, the QWERTY (or AZERTY) mnemonic "Raising Elephants Is So Utterly Boring", "Reboot Even If System Utterly Broken" or simply remembering the word "BUSIER" backwards, is often useful. It stands for:
unRaw       
 tErminate 
 kIll       
  Sync     
  Unmount  
reBoot.
This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work.
In practice, each command may require a few seconds to complete, especially if feedback is unavailable from the screen due to a freeze or display corruption. For example, sending SIGKILL to processes which have not yet finished terminating can cause data loss.
---

четверг, 21 октября 2010 г.

Установка grub

Выдержка из документации по GRUB Legacy


Installing GRUB natively

Caution: Installing GRUB's stage1 in this manner will erase the normal boot-sector used by an OS.

GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD directly, so using it on a boot sector (the first sector of a partition) should be okay. But generally, it would be a good idea to back up the first sector of the partition on which you are installing GRUB's stage1. This isn't as important if you are installing GRUB on the first sector of a hard disk, since it's easy to reinitialize it (e.g. by running `FDISK /MBR' from DOS).

If you decide to install GRUB in the native environment, which is definitely desirable, you'll need to create a GRUB boot disk, and reboot your computer with it. Otherwise, see 3.3 Installing GRUB using grub-install.

Once started, GRUB will show the command-line interface (see section 12.1 The flexible command-line interface). First, set the GRUB's root device(4) to the partition containing the boot directory, like this:
 
grub> root (hd0,0)

If you are not sure which partition actually holds this directory, use the command find, like this:
 
grub> find /boot/grub/stage1

This will search for the file name `/boot/grub/stage1' and show the devices which contain the file.

Once you've set the root device correctly, run the command setup (see section 13.3.34 setup):
 
grub> setup (hd0)

This command will install the GRUB boot loader on the Master Boot Record (MBR) of the first drive. If you want to put GRUB into the boot sector of a partition instead of putting it in the MBR, specify the partition into which you want to install GRUB:

grub> setup (hd0,0)

If you install GRUB into a partition or a drive other than the first one, you must chain-load GRUB from another boot loader. Refer to the manual for the boot loader to know how to chain-load GRUB.

воскресенье, 10 октября 2010 г.

Наращивание swap-памяти.

К счастью подобное может понадобиться редко. Но иногда на машине начинает нехватать даже swap-памяти. В этом случае ее можно увеличить создав дополнительный файл подкачки.

Создаем файл нужного размера:
# dd if=/dev/zero of=/mnt/swapfile bs=1024k count=3072

Подгатавливаем для использовения в качестве swap-файла:
# mkswap /mnt/swapfile

Подключаем в систему с нужным приоритетом. Чем выше значение, тем выше приоритет
# swapon -p 5 /mnt/swapfile

Переподключаем текущий раздел подкачки с более высоким приоритетом:
# swapoff /dev/sda3
# swapon -p 10 /dev/sda3

Правим /etc/fstab в соответствии с новыми реалиями (не забываем добавить параметр приоритета pri=):

---
/dev/sda3 swap swap defaults,pri=10 0 0
/mnt/swapfile swap swap defaults,pri=5 0 0
---

Посмотреть текущее состояние разделов/файлов подкачки можно следующей командой:
# swapon -s