Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, March 16, 2008

VIM - Basic usage and commands
vim is the bestest editor ever. you must know commands to do it right. this is the commands that i use most times.

:w
write file to disk but don't quit

:q!
quit vim but don't write file to disk

:wq
write file to disk and quit

/
search for a word or search phrase in a file. example: to search for VirtualHost in an httpd.conf file, type: /VirtualHost

i
enter insert mode

a
enter insert mode after the current cursor position

r
replace the character under the cursor with a new character. example: if your cursor is on a 6 and you want to change the 6 to a 7, type: r7
This is useful for quickly incrementing the serial number in bind's lookup files.

d
deletes a character. To delete 9 characters, type: d9
to delete from the cursor position to the end of the line, type: d$
to delete an entire line and move everything subsequent line up one line, type: dd
to delete a word, type: dw


/
search for a word or search phrase in a file. example: to search for VirtualHost in an httpd.conf file, type: /VirtualHost

n
finds the next match
shift+n
finds the previous match

yy
copies the entire line

3yw
copies 3 words start from left of cursor

p
if a line was copied pastes below cursor
if a word was copied it pastes to the right of cursor

shift+p
if a line was copied pastes above cursor
if a word was copied pastes to the left of cursor

:s/dog/cat/
swithes the first word dog to cat on the line that the cursor is on

:s/dog/cat/g
all dog ->cat on current line

:%s/dog/cat/g
all dog ->cat in whole file

:!ls
executes a command (ls in this case)

:split someotherfile
if you want to do a lot of copying and pasting from one file to another you can open the second file
and then switch between them by hitting ctrl+w twice

Friday, July 07, 2006

How to setup a mirror of exist server

Setup a mirror will take over main server with a minimum of downtime when main server crashes

In this article, I show you some experiences to replicate a real machine when I have been involved in the small true system mirroring process.

The exist system specification
OS: Debian 4.0
Web server: Apache 2.x
Database: MySQL 2.x
1. Solutions considering
There' re two solutions which depends on exist system configuration.
- Using VM technology
- Not VM
In case of your system is running with Virtual Machine technology like OpenVZ, VMWare .. You can do live-migration ( I will post in a other article)

- Software

2. Implementation
- Database replication
- Resource replication
- Web Server load balancing