Posts Tagged Linux

Dec 10 2012

perl – uninstall module

perl -MCPAN -e shell
install CPANPLUS
exit

perl -MCPANPLUS -e shell
help
[General]
h | ? # display help
q # exit
v # version information
[Search]
a AUTHOR … # search by author(s)
m MODULE … # search by module(s)
f MODULE … # list all releases of a module
o [ MODULE … ] # list installed module(s) that aren’t up to date
w # display the result of your last search again
[Operations]
i MODULE | NUMBER … # install module(s), by name or by search number
i URI | … # install module(s), by URI (ie http://foo.com/X.tgz)
t MODULE | NUMBER … # test module(s), by name or by search number
u MODULE | NUMBER … # uninstall module(s), by name or by search number
d MODULE | NUMBER … # download module(s)
l MODULE | NUMBER … # display detailed information about module(s)
r MODULE | NUMBER … # display README files of module(s)
c MODULE | NUMBER … # check for module report(s) from cpan-testers
z MODULE | NUMBER … # extract module(s) and open command prompt in it
[Local Administration]
b # write a bundle file for your configuration
s program [OPT VALUE] # set program locations for this session
s conf [OPT VALUE] # set config options for this session
s mirrors # show currently selected mirrors

Dec 5 2012

mysql trigger

DELIMITER |
CREATE TRIGGER `klienci_before_insert` BEFORE INSERT ON `klienci`
FOR EACH ROW
set NEW.sha1 = sha1(NEW.klient_id+NEW.time_add);
|

DELIMITER ;

May 25 2012

reinstaling lilo

Boot from any Live CD

mkdir /myraid
mount /dev/md0 /myraid
mount /dev/sda1 /myraid/boot
mount –bind /dev /myraid/dev
mount -t devpts devpts /myraid/dev/pts
mount -t proc proc /myraid/proc
mount -t sysfs sysfs /myraid/sys
chroot /myraid
lilo
exit

 

May 25 2012

umounting and deleteing array

umount /dev/md0
mdadm –stop /dev/md0
mdadm –zero-superblock /dev/sda1
mdadm –zero-superblock /dev/sdb1
mdadm –zero-superblock /dev/sdc1
mdadm –zero-superblock /dev/sdd1

Apr 19 2012

software RAID repair (naprawa macierzy RAID)

1. In this example RAID  contents two disks (/dev/sda, /dev/sdb)  and 4 partitions ( md0, md1, md2, md3)
cat /proc/mdstat

Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md1 : active raid1 sdb5[1] sda5[0]
 20979264 blocks [2/2] [UU]
md2 : active raid1 sda6[0] sdb6[1]
 20979968 blocks [2/2] [UU]
md3 : active raid1 sdb7[1] sda7[0]
 880264320 blocks [2/2] [UU]
md0 : active raid1 sdb1[1] sda1[0]
 20979648 blocks [2/2] [UU]
unused devices: <none>

2. If the RAID fail you will see

cat /proc/mdstat
 Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
 md1 : active raid1 sda5[0]
       20979264 blocks [2/1] [U_]
 md2 : active raid1 sda6[0]
       20979968 blocks [2/1] [U_]
 md3 : active raid1 sda7[0]
       880264320 blocks [2/1] [U_]
 md0 : active raid1 sda1[0]
       20979648 blocks [2/1] [U_]
 unused devices:

3. Disconnect failed hdd

4. Connect new hdd

5. Loook into dmesg for hdd letter

6. remove failed hdd from raid (usuniecie uszkodzonego dysku z macierzy)

mdadm /dev/md0 --fail detached --remove detached
mdadm /dev/md1 --fail detached --remove detached
mdadm /dev/md2 --fail detached --remove detached
mdadm /dev/md3 --fail detached --remove detached

7. copy partitions structure from old GOOD HDD to the new one ( kopiujemy strukture partycji z jednego dysku na drugi)

sfdisk -d /dev/sda | sfdisk /dev/sde

8. Add new hdd into RAID (# dodajemy nowo wsadzony dysk)

mdadm --add /dev/md0 /dev/sde1
mdadm --add /dev/md1 /dev/sde5
mdadm --add /dev/md2 /dev/sde6
mdadm --add /dev/md3 /dev/sde7

9. Rebuilding starts automaticaly, You can see RAID status by

cat /proc/mdstat

 10. 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.

 

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.)