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 }'
12/17/2010
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:
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
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
Labels:
centos,
lifehack,
Open Source,
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();"
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):
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:
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.
After you've edited this field, it should look like this:
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:
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:
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
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
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:::
Code:
vim shadow
Code:
root::10852:0:99999:7:::
Code:
cd / umount /mnt/sda1
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
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
9/14/2010
installin JDK and JRE gentoo way
had a task to install JDK and JRE on customer server. And when I found that on server Gentoo has been installed it was too late for me :) ( it is my first experience with Gentoo)
so there are the steps
1. update portage
#emerge --sync
2. install JDK/JRE
# emerge virtual/jdk
or
# emerge virtual/jre
3. Configuring JVM
ref http://www.gentoo.org/doc/en/java.xml
so there are the steps
1. update portage
#emerge --sync
2. install JDK/JRE
# emerge virtual/jdk
or
# emerge virtual/jre
3. Configuring JVM
list of java virtual machines
# java-config --list-available-vms
out put should be like:
# java-config --list-available-vms The following VMs are available for generation-2: 1) IcedTea6-bin 1.4.1 [icedtea6-bin] 2) Sun JDK 1.5.0.20 [sun-jdk-1.5] (Build Only)
3) Sun JDK 1.6.0.16 [sun-jdk-1.6]set VM
(By handle (preferred)) # java-config --set-system-vm sun-jdk-1.6 Now using sun-jdk-1.6 as your generation-2 system JVM (By number) # java-config --set-system-vm 3 Now using sun-jdk-1.6 as your generation-2 system JVM
ref http://www.gentoo.org/doc/en/java.xml
9/10/2010
Mysql master-master replication
Today I’m going to write a short manual how to create failover mysql cluster.
What we need:
Server1 = master 1/slave2
Server2 = master2/slave2
Internal or external IPs (in this example I will use server1 _ip and server2_ip)
Replication user = replicau
Step-by-step how to:
Step 1.
On server 1 in my.cnf we need to add following lines
[mysqld]
#master config
Server-id =1
Log-bin = mysql-bin
binlog-do-db = test_db
… #we can add as many DB as we need to replicate
#slave config
replicate-do-db = test_db
… #we can add as many DB as we need to replicate
master-host = server2_ip
master-user= replicau
master-password =password_of_user_replicau
master-port = 3306
same lines we should add in my.cnf on server2, the only thing we should change is master-host parameter to use server1_ip instead of server2_ip and change server-id parameter
Step 2
Restart mysql servers
Step 3
On each server we need to create replication user:
Server1
mysql>GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server2_ip' IDENTIFIED BY 'password';
server2
mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server1_ip' IDENTIFIED BY 'password';
Step 4
Add server2 as slave to server1
- we need to set read_only parameter as ON on server1 (master 1)
mysql> SET GLOBAL read_only = ON;
mysql> show master status;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000006 | 7984 | | |
+------------------+----------+--------------+------------------+
1 row in set (0,00 sec)
on server2
mysql>slave stop;
mysql> CHANGE MASTER TO MASTER_HOST = "server2_ip", MASTER_USER = "replicau", MASTER_PASSWORD = "password_of_user_replication", MASTER_LOG_FILE = "mysql-bin.000006", MASTER_LOG_POS = 7984;
mysql> slave start;
on server1
mysql> SET GLOBAL read_only = OFF;
on server2 check connection status
mysql> show slave status;
if we do not receive any errors, everything is perfect
Step 5
Do Step 4 for connecting server 1 as slave to server2.
Step 6
Check if everything is fine, if no try from step 1
Step 7
It’s time to have a cup of coffee/tea of a bottle of beer
What we need:
Server1 = master 1/slave2
Server2 = master2/slave2
Internal or external IPs (in this example I will use server1 _ip and server2_ip)
Replication user = replicau
Step-by-step how to:
Step 1.
On server 1 in my.cnf we need to add following lines
[mysqld]
#master config
Server-id =1
Log-bin = mysql-bin
binlog-do-db = test_db
… #we can add as many DB as we need to replicate
#slave config
replicate-do-db = test_db
… #we can add as many DB as we need to replicate
master-host = server2_ip
master-user= replicau
master-password =password_of_user_replicau
master-port = 3306
same lines we should add in my.cnf on server2, the only thing we should change is master-host parameter to use server1_ip instead of server2_ip and change server-id parameter
Step 2
Restart mysql servers
Step 3
On each server we need to create replication user:
Server1
mysql>GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server2_ip' IDENTIFIED BY 'password';
server2
mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replicau'@'server1_ip' IDENTIFIED BY 'password';
Step 4
Add server2 as slave to server1
- we need to set read_only parameter as ON on server1 (master 1)
mysql> SET GLOBAL read_only = ON;
mysql> show master status;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000006 | 7984 | | |
+------------------+----------+--------------+------------------+
1 row in set (0,00 sec)
on server2
mysql>slave stop;
mysql> CHANGE MASTER TO MASTER_HOST = "server2_ip", MASTER_USER = "replicau", MASTER_PASSWORD = "password_of_user_replication", MASTER_LOG_FILE = "mysql-bin.000006", MASTER_LOG_POS = 7984;
mysql> slave start;
on server1
mysql> SET GLOBAL read_only = OFF;
on server2 check connection status
mysql> show slave status;
if we do not receive any errors, everything is perfect
Step 5
Do Step 4 for connecting server 1 as slave to server2.
Step 6
Check if everything is fine, if no try from step 1
Step 7
It’s time to have a cup of coffee/tea of a bottle of beer
Labels:
Debian,
lifehack,
Linux,
master-master,
mysql,
Open Source,
replication,
відкрите ПЗ,
загальна інфа
9/09/2010
enable snmp windows 7
To install SNMP on Windows 7, open Control Panel and then click on Programs and Features. Then, click on "Turn Windows features on or off" link in the left pane. If UAC prompted, then click on Yes. Then, in the Windows Features window, scroll down and select "Simple Network Management Protocol (SNMP)" check box and click on OK. Then, wait for some time to install SNMP.
After installing SNMP, click on Start Orb and then type Services.msc in the Search box and hit Enter. Then, scroll down in the right pane and right click on SNMP Services and select Properties. Then, click on Traps tab. Now, in the Community Name box, type the community name to which your computer will send trap messages and then click on "Add to list" button. Then, click on Apply and then OK.
After installing SNMP, click on Start Orb and then type Services.msc in the Search box and hit Enter. Then, scroll down in the right pane and right click on SNMP Services and select Properties. Then, click on Traps tab. Now, in the Community Name box, type the community name to which your computer will send trap messages and then click on "Add to list" button. Then, click on Apply and then OK.
8/19/2010
7/12/2010
Subscribe to:
Posts (Atom)