Archive for the Linux Category

Apr 18 2012

raid1 on existing filesystem -> Example

Existing filesystem is on /dev/sda

/dev/root  /
/dev/sda5 /var
/dev/sda6 /usr
/dev/sda8  /home

Connect new disk (for example /dev/sdb)

Copy partition structure from sda to sdc:

sfdisk -d /dev/sda | sfdisk /dev/sdb

or if disk has differ size

create the same size ( or bigger) partitions on sdb

end change type for fd (Linux raid autodetect)

change disk’s blkid

tune2fs -U random /dev/sdb

Next, create the single-disk RAID-1 array. Note the “missing” keyword is specified as one of our devices. We are going to fill this missing device later.

mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1

or

mdadm --create /dev/md0 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdb1

and for other partitions

mdadm --create /dev/md1 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdb5
mdadm --create /dev/md2 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdb6
mdadm --create /dev/md3 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdb7

cat /proc/mdstat shows just created raid

Use the file system of your preference here. I'll use ext4 for this guide.
mkfs -t ext4 -j -L RAID-ONE /dev/md0
mkfs -t ext4 -j -L RAID-ONE /dev/md1
mkfs -t ext4 -j -L RAID-ONE /dev/md2
mkfs -t ext4 -j -L RAID-ONE /dev/md3

Make a file system on the swap partition:

mkswap -L NEW-SWAP /dev/sdb2

The new RAID-1 array is ready to start accepting data! So now we need to mount the array, and copy everything from the old system to the new system

 mkdir /tmp/md0 /tmp/md1 /tmp/md2 /tmp/md3
 mount /dev/md0 /tmp/md0

 mount /dev/md1 /tmp/md1
 mount /dev/md2 /tmp/md2
 mount /dev/md3 /tmp/md3
 rsync -avxHAXS --delete --progress /home/ /tmp/md3
 rsync -avxHAXS --delete --progress /var/ /tmp/md2
 rsync -avxHAXS --delete --progress /usr/ /tmp/md1
 rsync -avxHAXS --delete --progress / /tmp/md0

edit /etc/fstab and change mounting points to appropriate /dev/md0 .. /dev/md3

and add line:

/dev/sdb2  swap swap defaults 0 0

reboot with opition  root=/dev/md0 (where my root filesystem was located).

telinit 1 ?

First, open /dev/sda with fdisk and change all the partittions you want to have added to the array to type fd – linux raid autodetection.

Then, for each degraded array, add the appropriate non-array device to it:

mdadm /dev/md0 -a /dev/sda1

(wait for finish recovery)

(umount/dev/sda5)
mdadm /dev/md1 -a /dev/sda5

(wait for finish recovery)

umount/dev/sda6
mdadm /dev/md2 -a /dev/sda6

(wait for finish recovery)

umount/dev/sda8
mdadm /dev/md3 -a /dev/sda8

(wait for finish recovery)

Ensure your /etc/lilo.conf has the correct setup:
boot=/dev/md0
raid-extra-boot=mbr-only
root=/dev/md0

and type:

lilo

LILO will write boot information to each of the individual raid devices boot sectors, so if either /boot or your root partition are on failed disks, you’ll still be able to boot.

Create /etc/mdadm/mdadm.conf.
in /etc/mdadm/mdadm.conf put line:
DEVICE /dev/sda* /dev/sdb*

and WHEN ALL PARTITIONS ARE REBUILDED run:

mdadm --detail --scan >> /etc/mdadm.conf

					
Feb 13 2012

pecl ERROR: `phpize’ failed

Solution from:  http://kagan.mactane.org/blog/2009/05/11/workaround-for-pearpecl-failure-with-message-error-phpize-failed/

If you’ve gotten an “ERROR: `phpize’ failed” message when trying to run a “pecl install” or “pear install” command, try running phpinfo() — if you see --enable-sigchild in the “Configure Command” section near the very top, then you’re most likely being bitten by this bug.

 

Potential Fixes and Workarounds

The PHP dev team recommends recompiling without the offending flag.

However, you may not be able to do that, for any of various reasons. (You may have installed from a binary package, for instance — like most people these days.) Or it may simply seem like an excessive hassle. I offer the following patch as-is, without any guarantee or support.

First, ensure that you have the latest version of PEAR::Builder. Look in your PEAR/Builder.php file — On most Linux and Unix installations, this is likely to be in /usr/lib/php/PEAR/Builder.php, or possibly /usr/local/lib/php/PEAR/Builder.php.

On Windows systems, PHP might be installed nearly anywhere, but supposing it’s in c:\php, then the file you’re looking for will be in c:\php\PEAR\PEAR\Builder.php (yes, that’s two PEARs in a row).

Check the “@version” line in the big comment block at the beginning of the file; the line you want should be around line 19 or so. If says it’s less than version 1.38 (the latest one, at the time I’m writing this post), then try upgrading. Running “pear upgrade pear” should work. Then you can install this patch file:

 

Download the patch file and place it somewhere on your machine. Log in and cd to the PEAR directory that contains the Builder.php file. Then run the patch command. In the following example, I’ve placed the patch file in root’s home directory:

root@finrod:~# ls
loadlin16c.txt loadlin16c.zip patch-pear-builder-1.38.txt
root@finrod:~# cd /usr/lib/php/PEAR
root@finrod:/usr/lib/php/PEAR# cp Builder.php Builder.bak.php
root@finrod:/usr/lib/php/PEAR# patch -p0 < /root/patch-pear-builder-1.38.txt
patching file Builder.php
root@finrod:/usr/lib/php/PEAR#

Naturally, if the patch file doesn’t work for some reason, or it breaks things, you can just cp the backup file back into place.

 

Jan 9 2012

Postfix + Mysql + dovecot + Maildir

wpis w /etc/dovecot.conf.d/10-mail.conf
mail_location = maildir:/var/vmail/%d/%n/Maildir

auth-sql.conf.ext
passdb sql {
args = /etc/dovecot/dovecot-sql.conf
}

userdb static {
args = uid=5000 gid=5000 home=/var/vmail/%d/%n allow_all_users=yes
}

Nov 7 2011

Function ereg_replace() is deprecated

zamiast
$desc=ereg_replace(‘ +’,’ ‘,$desc); //reduce all multiple-space strings to single space
wpisujesz
$desc= preg_replace(‘/\s\s+/’, ‘ ‘, $desc); //reduce all multiple-space strings to single space

Sep 20 2011

postfix admin alias dla całej domeny

Dodajemy domenę przez  “Nowa domena”

Dodajemy alias, jako alias wpisujemy *

W pole do wpisujemy *@docelowa.domena.com

 

Sep 2 2011

mysql cluster

Pokaż zajętą pamięć: ndb_mgm , ALL REPORT MEMORY

Pierwsze uruchomienie clastra lub zmiana parametrów:

  • na managerze /etc/rc.d/rc.ndb_mgmd reload
  • na datanode po zmianie parametrów: ndbd –initial
  • na mysqlnode (API): /etc/rc.d/rc.mysqld restart

 

Apr 12 2011

Import bazy Teryt do MSQL

Baza danych teryt jest dostępna publicznie na tej stronie.

Ściągamy i rozpakowujemy pliki do jakiegoś katalogu dostępnego także z poziomu przeglądarki www.

Ściągamy plik Unserializer.php

Pliki php do importu simc.php terc.php ulic.php wmrodz.php
Tworzymy bazę teryt w mysql-u:teryt.create.sql_.
Dodajemy użytkownika z uprawnieniami (przynajmniej INSERT) do bazy teryt.
Po kolei uruchamiamy skrypty simc.php terc.php ulic.php wmrodz.php z przeglądarki.
Skrypty wykonują się dość długo i zajmują sporo pamięci, ja musiałem na czas impotu zmienić wpisy w php.ini (i zrestartować apache’a)
max_execution_time = 240 ; Maximum execution time of each script, in seconds
memory_limit = 1024M ; Maximum amount of memory a script may consume (128MB)

Dla leniwych: Baza danych teryt w formacie MYSQL (stan na 2011.04.12.)

Mar 26 2011

How to permit case-insensitive URLs with Apache

When mod_speling is installed, it may be turned on for a particular scope (such as a directory, virtual host, or the entire server) by setting the CheckSpelling directive to On.

Mar 23 2011

samba windows7 i “NT_STATUS_ACCESS_DENIED”

Control Panel - Administrative Tools - Local Security Policy 
Local Policies - Security Options
Network security: LAN Manager authentication level 
Send LM & NTLM responses 

Minimum session security for NTLM SSP 
Disable Require 128-bit encryption
Mar 17 2011

File does not exist: … favicon.ico

# Don’t bother looking for favicon.ico

Redirect 404 /favicon.ico

# Don’t bother sending the custom error page for favicon.ico

<Location /favicon.ico>

ErrorDocument 404 “No favicon

</Location>