9/03/2011

reboot hung server

The "magic SysRq key" provides a way to send commands directly to the kernel through the /proc filesystem. It is enabled via a kernel compile time option, CONFIG_MAGIC_SYSRQ, which seems to be standard on most distributions. First you must activate the magic SysRq option:
    echo 1 > /proc/sys/kernel/sysrq
When you are ready to reboot the machine simply run the following:
    echo b > /proc/sysrq-trigger
This does not attempt to unmount or sync filesystems, so it should only be used when absolutely necessary, but if your drive is already failing then that may not be a concern.

7/14/2011

How to upgrade Postgres 8.4.x to 9.0.x

I've found a couple of manuals where this procedure is described, but I faced with the problem with postgres-libs which were required for my SVN.

so there is my way how to perfom upgrade

1. service postgresql stop
2. rsync -a -v --progress /var/lib/pgsql/ /var/lib/pgsql.old/ #this will backup everything
3. wget http://yum.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm
4. rpm -i pgdg-centos-9.0-2.noarch.rpm
5. /etc/yum.repos.d/CentOS-Base.repo and add 'exclude=postgresql*' to the [base] and [updates] sections
6. yum remove postgresql84*
7. rpm -e postgresql-libs --nodeps
8. yum install postgresql90 postgresql90-server postgresql90-libs postgresql90-contrib postgresql90-devel
9. service postgresql-9.0 initdb
10. export PATH=/usr/pgsql-9.0/bin:$PATH
11. su - postgres ; export PATH=/usr/pgsql-9.0/bin:$PATH ; pg_upgrade --old-datadir "/var/lib/pgsql.old/data" --new-datadir "/var/lib/pgsql/9.0/data" --old-bindir "/usr/bin" --new-bindir "/usr/pgsql-9.0/bin"
12. cp /var/lib/pgsql.old/data/pg_hba.conf /var/lib/pgsql/9.0/data/pg_hba.conf
13. service postgresql-9.0 start
14. vacuumdb --all --analyze-only


Have fun with new Psql version :)

5/31/2011

hackmysql mirror

I've created mirror of hackmysql for personal usage

replace mysql-server with percona server

what is percona-server:

Quote:
Percona Server is an enhanced drop-in replacement for MySQL. With Percona Server,

Your queries will run faster and more consistently.
You will consolidate servers on powerful hardware.
You will delay sharding, or avoid it entirely.
You will save money on hosting fees and power.
You will spend less time tuning and administering.
You will achieve higher uptime.
You will troubleshoot without guesswork.

Does this sound too good to be true? It's not. Percona Server offers breakthrough performance, scalability, features, and instrumentation. Its self-tuning algorithms and support for extremely high-performance hardware make it the clear choice for companies who demand the utmost performance and reliability from their database server


now if you want to have such miracle on your cpanel server you need to do this steps for replacing mysql-server with percona-server:

1. backup VPS.
2. dump all dbs.
3. stop all services on the vps
Code:
/etc/init.d/httpd stop ; /etc/init.d/exim stop ; /etc/init.d/pure-ftpd stop ; /etc/init.d/dovecot stop ; /etc/init.d/cpanel stop ; /etc/init.d/lfd stop ; /etc/init.d/munin-node stop ; /etc/init.d/crond stop ; /etc/init.d/mysql stop ; /etc/init.d/exim stop ;


4. make sure that everything is stopped
5. check what mysql packages are installed

Code:
rpm -qa | grep -i mysql


in my case it was MySQL-client MySQL-devel MySQL-test MySQL-bench MySQL-shared MySQL-server
so I run this command to completely remove mysql from vps
Code:
yum remove MySQL-client MySQL-devel MySQL-test MySQL-bench MySQL-shared MySQL-server


6. add percona repo

Code:
rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm


7. check what packages are available in percona repo

Code:
yum list | grep percona


should be something like

Code:
# yum list | grep percona
percona-release.x86_64                    0.0-1                        installed
Percona-SQL-50-debuginfo.x86_64           5.0.92-b23.85.rhel5          percona
Percona-SQL-client-50.x86_64              5.0.92-b23.85.rhel5          percona
Percona-SQL-devel-50.x86_64               5.0.92-b23.85.rhel5          percona
Percona-SQL-server-50.x86_64              5.0.92-b23.85.rhel5          percona
Percona-SQL-shared-50.x86_64              5.0.92-b23.85.rhel5          percona
Percona-SQL-shared-compat.x86_64          5.1.43-2                     percona
Percona-SQL-test-50.x86_64                5.0.92-b23.85.rhel5          percona
Percona-Server-51-debuginfo.x86_64        5.1.56-rel12.7.224.rhel5     percona
Percona-Server-55-debuginfo.x86_64        5.5.11-rel20.2.115.rhel5     percona
Percona-Server-client-51.x86_64           5.1.56-rel12.7.224.rhel5     percona
Percona-Server-devel-51.x86_64            5.1.56-rel12.7.224.rhel5     percona
Percona-Server-server-51.x86_64           5.1.56-rel12.7.224.rhel5     percona
Percona-Server-shared-51.x86_64           5.1.56-rel12.7.224.rhel5     percona
Percona-Server-test-51.x86_64             5.1.56-rel12.7.224.rhel5     percona
gnuplot.x86_64                            4.2.6-14                     percona
gnuplot-emacs.x86_64                      4.2.6-14                     percona
maatkit.noarch                            7284-1                       percona
xtrabackup.x86_64                         1.6-245.rhel5                percona
xtrabackup-debuginfo.x86_64               1.6-245.rhel5                percona


8. decide what version you need 5.1 or 5.5
in my case I've installed percona 5.5

Code:
# rpm -qa | grep Percona
Percona-Server-client-55-5.5.11-rel20.2.115.rhel5
Percona-Server-server-55-5.5.11-rel20.2.115.rhel5
Percona-Server-shared-55-5.5.11-rel20.2.115.rhel5
Percona-Server-shared-compat-5.5.11-rel20.2.115.rhel5
Percona-Server-devel-55-5.5.11-rel20.2.115.rhel5
Percona-Server-test-55-5.5.11-rel20.2.115.rhel5


9. after Percona-server installation it is necessary to check if it started correctly as some variables in my.cnf are not supported.
10. after successful start it is necessary to run mysql_upgrade.
11. for finishing installation run easyapache and recompile apache/php/etc
12. Go to Server Configuration -> Update Config and set MySQL to "never", save, double check it has been done
13. Test new Apache to be sure server is working

3/25/2011

add json support into Flex4

Adobe itself made a JSON library that you can find at https://github.com/mikechambers/as3corelib Follow these steps to add your JSON library to your Flex project:
  1. Download the .zip archive and extract it. What you need is the .swc file in the lib folder.
  2. In Flex Builder / Flash Builder, go to your project’s properties, and then to the Flex Build Path panel.
  3. Click on Add SWC, and select the as3corelib.swc file
  4. In your project, add the following line: import com.adobe.serialization.json.JSON;
You should be able now to use JSON functionalities in your Flex project :)

12/17/2010

where is my free disk space :)

To list files larger than 10M:
find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

To list files larger than 100M:
find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

11/29/2010

how to convert tables to InnoDB

Using nice tool from Maatkit, we can easy convert tables from any storage engine to other. there is example how to convert from myisam to  innodb

mk-find db-name --engine MyISAM --exec "ALTER TABLE %D.%N ENGINE=INNODB" --print

11/22/2010

how to install php5.3.x & 5.2.x centos

there are 3 steps how to install/upgrade php on centos server/vps

1. install webtatic repo:

rpm -ivh http://repo.webtatic.com/yum/centos/5/`uname -i`/webtatic-release-5-1.noarch.rpm

2. install/upgrade php 5.3.x

yum --enablerepo=webtatic install php
yum --enablerepo=webtatic upgrade php

3. install/upgrade php 5.2.x


yum --enablerepo=webtatic --exclude=php*5.3* update php
yum --enablerepo=webtatic --exclude=php*5.3* install php

10/08/2010

reset CPAN first run

to reset CPAN configuration it is necessary to run this command

perl -e "use CPAN::FirstTime; CPAN::FirstTime::init();" 

9/20/2010

3 ways to reset root password in linux

today I'm gonna to explain how to reset root password in linux. 2 of this ways can be applied only if you have access to PC physically. 3rd way can be applied if your service provider have recovery console or something like that:)

so lets start:

1 EDITING LOADER (in my case it will be GRUB)

boot machine
when the GRUB menu appears, use arrow keys to choose OS to be booted
press letter "e'' on the keyboard to enter edit mode
use arrow keys to select the kernel line for kernel to be booted
press "e" to edit line
go to end of line and type "single" (without quotes) as a separate word
press ESC key to exit the edit mode
press "b" to boot into single user mode
after booting you can set password for root by running passwd  commnad
reboot and login with new pw

2. MAGIC WAY :)

If the easy method doesn't work on your machine, another way to solve the "lost root password" problem is to boot your computer from your Linux Installation CD/DVD, or from a live-CD/DVD such as Knoppix.

Boot with the live-disk then go to a terminal and su to root (no password is required) then issue the following commands (be sure to replace each /sda1 with your own root partition device):


Code:
mount -o dev,rw /mnt/sda1
 
cd /mnt/sda1/etc
Once you are into your system /etc directory, you can use a text editor (vim, nano, pico, etc.) to edit the /etc/shadow file where the password is stored. Various information about root and user accounts is kept in this plain-text file but we are only concerned with the password portion.

For example, the /etc/shadow entry for the "root" account may look something like this:

Code:
root:$1$aB7mx0Licb$CTbs2RQrfPHkz5Vna0.fnz8H68tB.:10852:0:99999:7:::
Now, using your favorite editor (I'll use vim) delete the password hash. For this example, the password is in green text and is all those characters between the 1st and 2nd colons.

Code:
vim shadow
After you've edited this field, it should look like this:

Code:
root::10852:0:99999:7:::
Now save the file and change back to the root directory and unmount the system root partition (don't forget to change the /sda1) as follows:

Code:
cd /
umount /mnt/sda1
Now reboot the computer.

Once the computer has booted and you're at the login prompt, type "root" and when asked for the password just press ENTER (entering no password). After a successful login, you need to set the new password for root using the following command:

Code:
passwd
this way was not tested by me and I found it in google :)
3.RECOVERY CONSOLE or LIVE CD/DVD

1.Boot from LIVECD or in RC
2. mount root partition
- if no raid on server than
mount /dev/hda2 /mnt/newroot
- if you have raid
mount /dev/md1 /mnt/newroot
NOTE make sure that you replace hhd name with your own

3. Bind /dev/random from your server
mount –bind /dev /mnt/newroot/dev
4. changing the root file system. (e.g.):  
# chroot /mnt/newroot /bin/bash
5.change root password
passwd
6. reboot in normal mode