Welcome To My Blog
here i will try to collect as much as i can of articles and
toutorials talking about linux and open source software

if you want to share me this and be an author Contact me
subscribe to RSS or subscribe to Email Newsletter

how to color text in your shell scripts ;)

Posted by ahmedhamdy_27 Tuesday, July 13, 2010 View Comments

Use escape sequences: echo -e '\E[color1;color2mYour Text.'
(color1 is the foreground, color2 the background color)


  1. echo -e '\E[30m black \E[31mred \E[32mgreen \E[33myellow \E[34mblue \E[35mmagenta \E[36mcyan \E[37mwhite'
  2. echo -e '\E[30;41mblack on red'

  1. Color: Foreground: Background:
  2. ---------------------------------------------------------
  3. black 30 40
  4. red 31 41
  5. green 32 42
  6. yellow 33 43
  7. blue 34 44
  8. magenta 35 45
  9. cyan 36 46
  10. white 37 47
Regards,

If you want to force bots and browser to use the full domain with the www. prefix, you will need to test your Apache {HTTP_HOST} variable to see if it already exists and, if not, redirect.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomainname\.com$ [NC]
RewriteRule .? http://www.yourdomainname.com%{REQUEST_URI} [R=301,L]

If you have subdomains, however, preserve the subdomain like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z.]+\.)?yourdomainname\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%1yourdomainname.com%{REQUEST_URI} [R=301,L]

Nginx: Setup SSL Reverse Proxy (Load Balanced SSL Proxy)

A reverse proxy is a proxy server that is installed in a server network. Typically, reverse proxies are used in front of Web servers such as Apache, IIS, and Lighttpd. How do I setup nginx web server as SSL reverse proxy?

When you've multiple backend web servers, encryption / SSL acceleration can be done by a reverse proxy. Nginx can act as SSL acceleration software. It provided the following benefits:


Easy of use : Nginx is easy to setup and upgrade.
Security : Nginx provide an additional layer of defense as Apache is behind the proxy. It can protect against common web-based attacks too.
Load Distribution : nginx use very little memory and can distribute the load to several Apache servers. It can even rewrite urls on fly.
Caching : Nginx act as a reverse proxy which offload the Web servers by caching static content, such as images, css, js, static html pages and much more.
Compression : Nginx can optimize and compress the content to speed up the load time.
Our Sample Setup
Internet--
|
============= |---- apache1 (192.168.1.15)
| ISP Router| |
============= |---- apache2 (192.168.1.16)
| |
| |---- db1 (192.168.1.17)
| |eth0 -> 192.168.1.11 ----------/
|-lb0==| /
| |eth1 -> 202.54.1.1:443---/
|
| |eth0 -> 192.168.1.10 ----------\
|-lb1==| / |---- apache1 (192.168.1.15)
|eth1 -> 202.54.1.1:443---/ |
|---- apache2 (192.168.1.16)
|
|---- db1 (192.168.1.17)
lb0 - Linux box directly connected to the Internet via eth1. This is master SSL load balancer.
lb1 - Linux box directly connected to the Internet via eth1. This is backup SSL load balancer. This will become active if master networking failed.
202.54.1.1 A virtual IP address that moves between lb0 and lb1. It is managed by keepalived.
nginx - It is installed on lb0 and lb1.
SSL Certificate - You need to install ssl certificates on lb0 and lb1.
For demonstration purpose I'm going to use Self-signed SSL certificate, but you can use real SSL certificate signed by CAs.

+------+ +-------------+ +-------------------+
|Client| <---> |SSL-Nginx:443| <----> |Apache-HTTP_mode:80|
+------+ +-------------+ +-------------------+
You've the SSL connection between client and Nginx.
Then Nginx act as proxy server and makes unencrypted connection to Apache at port 80.
Nginx can cache all static file and other files.
Generating Self-signed Certificate
First, create required directories:
# cd /usr/local/nginx/conf
# mkdir ssl
# cd ssl

To create a private key, enter:
# openssl genrsa -des3 -out nixcraft.in.key 1024

Sample outputs:




Fig.01: OpenSSL - Create a Private Key


To create a CSR (Certificate Signing Request):
# openssl req -new -key nixcraft.in.key -out nixcraft.in.csr

Sample outputs:



Fig.02: OpenSSL - Create a CSR (Certificate Signing Request)


Please enter your domain name that you want to associate with the certificate. For example, for the Command Name I entered nixcraft.in as I'm going to use https://nixcraft.in/.
How Do I Remove The Passphrase? (Optional)

You can remove the passphrase so nginx can start on boot without entering the passphrase. Type the following commands
# cp nixcraft.in.key nixcraft.in.key.bak
# openssl rsa -in nixcraft.in.key.bak -out nixcraft.in.key

Finally, you should see three files as follows (note I've created all files as vivek user and than moved lb0 and lb1 server /usr/local/ngnix/conf/ssl/ directory):
# ls -l

Sample outputs:



Fig.03: All the files in ssl directory


# openssl x509 -req -days 365 -in nixcraft.in.csr -signkey nixcraft.in.key -out nixcraft.in.crt

Sample outputs:




Fig.04: Generating The Actual Self-signed SSL Certificate

How Do I Copy SSL Certificates Files To lb1?

You need to copy those files to lb1, enter:
# ssh root@lb1 mkdir /usr/local/ngnix/conf/ssl
# rsync -av /usr/local/ngnix/conf/ssl/* root@lb1:/usr/local/ngnix/conf/ssl/

Configure Nginx As SSL Reverse Proxy (lb0 and lb1)
Edit nginx.conf, enter (you need to edit files on both lb0 and lb1):
# vi /usr/local/ngnix/conf/nginx.conf

Edit / append as follows:


server {
### server port and name ###
listen 443 ssl;
server_name nixcraft.in;

### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;

### SSL cert files ###
ssl_certificate ssl/nixcraft.in.crt;
ssl_certificate_key ssl/nixcraft.in.key;
### Add SSL specific settings here ###
keepalive_timeout 60;

### Limiting Ciphers ########################
# Uncomment as per your setup
#ssl_ciphers HIGH:!ADH;
#ssl_perfer_server_ciphers on;
#ssl_protocols SSLv3;
##############################################
### We want full access to SSL via backend ###
location / {
proxy_pass http://nixcraft;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

### Set headers ####
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

### Most PHP, Python, Rails, Java App can use this header ###
proxy_set_header X-Forwarded-Proto https;

### By default we don't want to redirect it ####
proxy_redirect off;
}

Save and close the file. Reload nginx:
# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload

Verify port is opened:
# netstat -tulpn | grep :443

How Do I Test And Debug SSL Certificates From The Shell Prompt?
Use the openssl command as follows:
$ openssl s_client -connect nixcraft.in:443

See "How To Verify SSL Certificate From A Shell Prompt" for more details.
How Do I Cache Common Files?
Edit nginx.conf and add as follows to cache common files:

location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
proxy_buffering on;
proxy_cache_valid 200 120m;
expires 864000;
}
Save and close the file. Reload nginx:
# nginx -s reload

Handling nginx Failover With KeepAlived

Posted by Linux4all Friday, February 26, 2010 View Comments





How do configure to release and obtain VIP (virtual IP) when nginx is dead, down or system is rebooted for the kernel upgrades?

Edit /usr/local/etc/keepalived/keepalived.conf and add the following section to check whether nginx is alive or dead:
# vi /usr/local/etc/keepalived/keepalived.conf

Updated file on both lb0 and lb1:

vrrp_script chk_http_port {
script "/usr/bin/killall -0 nginx"
interval 2
weight 2
}
vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 101
authentication {
auth_type PASS
auth_pass Add-Your-Password-Here
}
track_script {
chk_http_port
}
virtual_ipaddress {
202.54.1.1/29 dev eth1
}
}

Save and close the file. Reload keealived:
# /etc/init.d/keepalived restart

If nginx died due to any issues keepalived will release master VIP and backup server will become active. When master nginx LB0 comes backs online, the backup LB1 will go down in backup state.





How do I configure nginx as failover reverse proxy load balancer in front of two Apache web servers under CentOS / RHEL 5.x?

nginx is a Web and Reverse proxy server. Nginx used in front of Apache Web servers. All connections coming from the Internet addressed to one of the Web servers are routed through the nginx proxy server, which may either deal with the request itself or pass the request wholly or partially to the main web servers.

Our Sample Setup
Internet--
|
============= |---- apache1 (192.168.1.15)
| ISP Router| |
============= |---- apache2 (192.168.1.16)
| |
| |---- db1 (192.168.1.17)
| |eth0 -> 192.168.1.11 ----------/
|-lb0==| /
| |eth1 -> 202.54.1.1 ----/
|
| |eth0 -> 192.168.1.10 ----------\
|-lb1==| / |---- apache1 (192.168.1.15)
|eth1 -> 202.54.1.1 ----/ |
|---- apache2 (192.168.1.16)
|
|---- db1 (192.168.1.17)
Where,

lb0 - Linux box directly connected to the Internet via eth1. This is master load balancer.
lb1 - Linux box directly connected to the Internet via eth1. This is backup load balancer. This will become active if master networking failed.
202.54.1.1 - This ip moves between lb0 and lb1 server. It is called virtual IP address and it is managed by keepalived.
eth0 is connected to LAN and all other backend software servers are connected via eth0.
nginx is installed on both lb0 and lb1. It will listen on 202.54.1.1. You need to configure nginx as reverse proxy server. It will connects to Apache1 and Apache2.
Install httpd server on Apache#1 and Apache#2 server. Configure them to listen on 192.168.1.15:80 and 192.168.1.16:80. Do not assign public IP to this box. Only activate eth0 via LAN.
Install MySQL / Oracle / PgSQL server on Db#1. Configure db server to listen on 192.168.1.17:$db_server_port. Do not assign public IP to this box. Only activate eth0 via LAN.
In short you need the following hardware:

2 load balancer reverse proxy servers (250GB SATA, 2GB RAM, Single Intel P-D930 or AMD 170s with RHEL 64 bit+keepalived+nginx)
2 Apache web servers (Software RAID-1, SCSI-73GBx2 15k disk, 6GB RAM, Dual Intel Xeon or AMD 64 bit CPU with RHEL 64 bit+Apache 2)
1 backup Apache web servers (Software RAID-1, SCSI-73GBx2 15k disk, 6GB RAM, Dual Intel Xeon or AMD 64 bit CPU with RHEL 64 bit+Apache 2)
1 database server (RAID-10, SCSI-73GBx4 15k disk, 16GB RAM, Dual Intel Xeon or AMD 64 bit CPU with RHEL 64 bit+MySQL 5)
1 Caching server (RAID-1, SCSI-73GBx2 15k disk, 8GB RAM, Dual Intel Xeon or AMD 64 bit CPU with RHEL 64 bit)
1 offsite backup server (RAID-6, 1TB SATAx4, 4GB RAM, Single Intel/AMD CPU with RHEL 64bit)
Slave database, storage, pop3 and SMTP server as per requirements.
Internet uplink 100Mbps+ or as per requirements.
Remove Unwanted Software From lb0 and lb1
Type the following commands:
# yum -y groupremove "X Window System"
# x=$(yum list installed | egrep -i 'php|httpd|mysql|bind|dhclient|tftp|inetd|xinetd|ypserv|telnet-server|rsh-server|vsftpd|tcsh' | awk '{ print $1}')
# yum -y remove $x
# yum -y install bind-utils sysstat openssl-devel.x86_64 pcre-devel.x86_64 openssl097a.x86_64
# /usr/sbin/authconfig --passalgo=sha512 --update
# passwd root

The above will remove X windows and other unwanted software from both lb0 and lb1.

Install Nginx On Both lb0 and lb1
Type the following commands to download nginx, enter:
# cd /opt
# wget http://sysoev.ru/nginx/nginx-0.8.33.tar.gz

Untar nginx, enter:
# tar -zxvf nginx-0.8.33.tar.gz
# cd nginx-0.8.33

Configure nginx for 64 bit RHEL / CentOS Linux:
# ./configure --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_fastcgi_module --without-http_empty_gif_module --with-openssl=/lib64

Sample outputs:

....
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
...
Install the same:
# make
# make install

Create nginx User Account
Type the following commands to create a user account:
# useradd -s /sbin/nologin -d /usr/local/nginx/html -M nginx
# passwd -l nginx

Configure nginx As Reverse Proxy Load Balancer On Both lb0 and lb1
Edit /usr/local/nginx/conf/nginx.conf, enter:
# vi /usr/local/nginx/conf/nginx.conf

Update it as follows:


pid logs/nginx.pid;
user nginx nginx;
worker_processes 10;

events {
worker_connections 1024;
}

http {
default_type application/octet-stream;

## Common options ##
include options.conf;

## Proxy settings ##
include proxy.conf;

## lb domains ##
include nixcraft.in.conf;
}
Edit /usr/local/nginx/conf/options.conf, enter:
# vi /usr/local/nginx/conf/options.conf

Update it as follows:


## Size Limits
client_body_buffer_size 128K;
client_header_buffer_size 1M;
client_max_body_size 1M;
large_client_header_buffers 8 8k;

## Timeouts
client_body_timeout 60;
client_header_timeout 60;
expires 24h;
keepalive_timeout 60 60;
send_timeout 60;

## General Options
ignore_invalid_headers on;
keepalive_requests 100;
limit_zone gulag $binary_remote_addr 5m;
recursive_error_pages on;
sendfile on;
server_name_in_redirect off;
server_tokens off;

## TCP options
tcp_nodelay on;
tcp_nopush on;

## Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.0;
gzip_min_length 0;
gzip_types text/plain text/css image/x-icon application/x-perl application/x-httpd-cgi;
gzip_vary on;

## Log Format
log_format main '$remote_addr $host $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
'"$gzip_ratio"';

Edit /usr/local/nginx/conf/proxy.conf, enter:


## Proxy caching options
proxy_buffering on;
proxy_cache_min_uses 3;
proxy_cache_path /usr/local/nginx/proxy_temp/ levels=1:2 keys_zone=cache:10m inactive=10m max_size=1000M;
proxy_cache_valid any 10m;
proxy_ignore_client_abort off;
proxy_intercept_errors on;
proxy_next_upstream error timeout invalid_header;
proxy_redirect off;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;

Edit /usr/local/nginx/conf/nixcraft.in.conf, enter:


## Connect to backend servers via LAN ##
## Reverse Proxy Load Balancer Logic ##
upstream nixcraft {
server 192.168.1.15 weight=10 max_fails=3 fail_timeout=30s;
server 192.168.1.16 weight=10 max_fails=3 fail_timeout=30s;
# only comes alive when above two fails
server 192.168.1.23 weight=1 backup;
}

server {
access_log logs/access.log main;
error_log logs/error.log;
index index.html;
root /usr/local/nginx/html;
server_name nixcraft.in www.nixcraft.in subdomain.nixcraft.in;

## Only requests to our Host are allowed
if ($host !~ ^(nixcraft.in|www.nixcraft.in|subdomain.nixcraft.in)$ ) {
return 444;
}

## redirect www to nowww
# if ($host = 'www.nixcraft.in' ) {
# rewrite ^/(.*)$ http://nixcraft.in/$1 permanent;
# }

## Only allow these request methods
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}

## PROXY - Web
location / {
proxy_pass http://nixcraft;
proxy_cache cache;
proxy_cache_valid 200 24h;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
proxy_ignore_headers Expires Cache-Control;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Start nginx web server:
# /usr/local/nginx/sbin/nginx
# netstat -tulpn | grep :80
# echo ' /usr/local/nginx/sbin/nginx' >> /etc/rc.local

Fire a webbrowser and type domain name such as nixcraft.in:
http://nixcraft.in

References:
nginx wiki
Stay tuned, for rest of the firewall, security, SELinux, database, helper scripts and optimization configuration.




Keepalived provides a strong and robust health checking for LVS clusters. It implements a framework of health checking on multiple layers for server failover, and VRRPv2 stack to handle director failover. How do I install and configure Keepalived for reverse proxy server such as nginx or lighttpd?

If your are using a LVS director to loadbalance a server pool in a production environment, you may want to have a robust solution for healthcheck & failover. This will also work with reverse proxy server such as nginx.

Our Sample Setup
Internet--
|
=============
| ISP Router|
=============
|
|
| |eth0 -> 192.168.1.11 (connected to lan)
|-lb0==|
| |eth1 -> 202.54.1.1 (vip master)
|
| |eth0 -> 192.168.1.10 (connected to lan)
|-lb1==|
|eth1 -> 202.54.1.1 (vip backup)
Where,

lb0 - Linux box directly connected to the Internet via eth1. This is master load balancer.
lb1 - Linux box directly connected to the Internet via eth1. This is backup load balancer. This will become active if master networking failed.
202.54.1.1 - This ip moves between lb0 and lb1 server. It is called virtual IP address and it is managed by keepalived.
eth0 is connected to LAN and all other backend software such as Apache, MySQL and so on.
You need to install the following softwares on both lb0 and lb1:

keepalived for IP failover.
iptables to filter traffic
nginx or lighttpd revers proxy server.
DNS settings should be as follows:

nixcraft.in - Our sample domain name.
lb0.nixcraft.in - 202.54.1.11 (real ip assigned to eth1)
lb1.nixcraft.in - 202.54.1.12 (real ip assigned to eth1)
www.nixcraft.in - 202.54.1.1 (VIP for web server) do not assign this IP to any interface.
Install Keepalived
Visit keepalived.org to grab latest source code. You can use the wget command to download the same (you need to install keepalived on both lb0 and lb1):
# cd /opt
# wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz
# tar -zxvf keepalived-1.1.19.tar.gz
# cd keepalived-1.1.19

Install Kernel Headers

You need to install the following packages:

Kernel-headers - includes the C header files that specify the interface between the Linux kernel and userspace libraries and programs. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the glibc package.
kernel-devel - this package provides kernel headers and makefiles sufficient to build modules against the kernel package.
Make sure kernel-headers and kernel-devel packages are installed. If not type the following install the same:
# yum -y install kernel-headers kernel-devel

Compile keepalived

Type the following command:
# ./configure --with-kernel-dir=/lib/modules/$(uname -r)/build

Sample outputs:

checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
...
.....
..
config.status: creating keepalived/check/Makefile
config.status: creating keepalived/libipvs-2.6/Makefile

Keepalived configuration
------------------------
Keepalived version : 1.1.19
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use Debug flags : No
Compile and install the same:
# make && make install

Create Required Softlinks

Type the following commands to create service and run it at RHEL / CentOS run level #3 :
# cd /etc/sysconfig
# ln -s /usr/local/etc/sysconfig/keepalived .
# cd /etc/rc3.d/
# ln -s /usr/local/etc/rc.d/init.d/keepalived S100keepalived
# cd /etc/init.d/
# ln -s /usr/local/etc/rc.d/init.d/keepalived .

Configuration

Your main configuration directory is located at /usr/local/etc/keepalived and configuration file name is keepalived.conf. First, make backup of existing configuration:
# cd /usr/local/etc/keepalived
# cp keepalived.conf keepalived.conf.bak

Edit keepalived.conf as follows on lb0:

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 101
authentication {
auth_type PASS
auth_pass Add-Your-Password-Here
}
virtual_ipaddress {
202.54.1.1/29 dev eth1
}
}
Edit keepalived.conf as follows on lb1 (note priority set to 100 i.e. backup load balancer):

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 100
authentication {
auth_type PASS
auth_pass Add-Your-Password-Here
}
virtual_ipaddress {
202.54.1.1/29 dev eth1
}
}
Save and close the file. Finally start keepalived on both lb0 and lb1 as follows:
# /etc/init.d/keepalived start

Verify: Keepalived Working Or Not

/var/log/messages will keep track of VIP:
# tail -f /var/log/messages

Sample outputs:

Feb 21 04:06:15 lb0 Keepalived_vrrp: Netlink reflector reports IP 202.54.1.1 added
Feb 21 04:06:20 lb0 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 202.54.1.1
Verify that VIP assigned to eth1:
# ip addr show eth1

Sample outputs:

3: eth1: mtu 1500 qdisc pfifo_fast qlen 10000
link/ether 00:30:48:30:30:a3 brd ff:ff:ff:ff:ff:ff
inet 202.54.1.11/29 brd 202.54.1.254 scope global eth1
inet 202.54.1.1/29 scope global secondary eth1
ping failover test
Open UNIX / Linux / OS X desktop terminal and type the following command to ping to VIP:
# ping 202.54.1.1

Login to lb0 and halt the server or take down networking:
# halt

Within seconds VIP should move from lb0 to lb1 and you should not see any drops in ping. On lb1 you should get the following in /var/log/messages:

Feb 21 04:10:07 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) forcing a new MASTER election
Feb 21 04:10:08 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Feb 21 04:10:09 lb1 Keepalived_healthcheckers: Netlink reflector reports IP 202.54.1.1 added
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 202.54.1.1
Conclusion

Your server is now configured with IP failover. However, you need to install and configure the following software in order to configure webserver and security:

nginx or lighttpd
iptables
Stay tuned, for more information on above configuration.

Auto mounting a Samba share in Linux

Posted by ahmedhamdy_27 Monday, February 22, 2010 View Comments

So you have that Samba server up and running and you can connect to it from Windows and Mac with ease. But when you turn to another Linux box that doesn’t have Konqueror, Nautilus, or Dolphin you can’t figure out the riddle of connecting. Or maybe you want to have this share mounted at boot time? How do you manage it?From the command line of course. Yes there are plenty of GUI tools that will allow you to connect to a Samba share easily, but they don’t help you set up anything to connect automatically. For that you will need to employ a few command line tools. But once it is finished, your system will be seamless.

What you will need
First I am going to assume you have your Samba server set up and you are able to connect to it from other machines. Outside of that you will need only one piece of software installed on your Linux machine: smbclient. This will be in your distributions’ repositories so just open up your Add/Remove Software utility, search for smbclient, select it, and click Apply.
Once smbclient is installed you are ready to go.

A test
Let’s first test to make sure your Linux box can see the Samba share. You will need either sudo or root access to do this. Issue the command:
smbclient //IP_TO_SAMBA_SERVER/SHARE_NAME -U USERNAME
Where:

  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
If all is well you should see something like this:
Enter wallenmusic’s password:
Domain=[MONKEYPANTZ] OS=[Unix] Server=[Samba 3.2.5]
smb: \>
If you see that you can type quit and then hit the Enter key to escape this prompt.

Setup
The first thing you need to do is create a directory to mount the Samba share to. I created the directory /data with the command:
sudo mkdir /data
Once that directory is created you can then mount it with the command:
mount -t smbfs -o username=USERNAME //IP_TO_SAMBA_SERVER/SAMBA_SHARE /data
Where:
  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
Now if you check the /data directory you should see a listing of the contents of the Samba share.

Automount
Let’s make that share automount at boot. This will require editing your /etc/fstab file, adding an entry for this Samba share. In this file (again you will have to have either root or sudo access) you will add a line like this:
//IP_TO_SAMBA_SERVER/SAMBA_SHARE� /data smbfs username=USERNAME,password=PASSWORD, 0 0
Where:
  • IP_TO_SAMBA_SERVER is the IP address of your Samba server.
  • SHARE_NAME is the share you want to connect to.
  • USERNAME is the user name you connect to the share with.
  • PASSWORD is the password for the Samba user
Once that entry is saved unmount the /data directory with the command:
umount /data
so you can test your automount entry.
Now, enter the command:
mount -a
If there are no errors you should see the contents of the Samba share in the /data directory.
That’s it. Congratulations, you now have an automounted Samba share on your Linux machine.

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well, we were wrong and linuxconf has pretty much died off. Why did linuxconf die? Because new tools, such as Webmin? came along.
Webmin arrived on the scene in 1997 and pretty much blew away the competition. Webmin is truly a one-stop shop for Linux configuration. It’s modular so you can add and remove modules as they are needed. Webmin can configure your system, servers, networking, hardware, clusters, you name it!
Even though Webmin is a web-based utility, it does not require a server to be installed or running. Webmin contains its own built-in server so you will not need Apache running. Webmin does have to be running in order to log in.
The easiest way to install Webmin is to open up your Add/Remove Software utility, do a search for webmin, and install it. Or you can go to the Webmin Site, download the the appropriate binary and let your package manager do the work for you. If you are wanting to install Webmin on a headless server you can do the following:

  • Secure shell to your server
  • Download the correct installation file using the wget command.
  • Issue the command to install Webmin (such as rpm -ivh webmind-XXX.rpm (where XXX is the release number)
After the installation is complete you may have to start Webmin manually (the rpm installation starts the server for you). To start Webmin you will issue the command:
/etc/rc.d/init.d/webmin start
or
/etc/init.d/webmin start
Once you have started Webmin you log into it with with your browser by pointing it to:
http://IP_OR_DOMAIN:10000
Where IP_OR_DOMAIN is the IP address or the domain Webmin is installed on. If you are using it for local configuration you can point your browser to http://localhost:10000.
Webmin Main Page
Webmin Main Page

As you can see, in the image to the left, the default Webmin page is very easy to navigate.Upon installation one of the first links you should click on this page is the Webmin link in the left navigation. When that menu expands you will see a number of entries, of which one is called Webmin Configuration.
The Webmin Configuration Page
The Webmin Configuration Page

Click on the Webmin Configuration option to reveal a number of possible choices. This section is very important because you will configure access, logging, certificates, categories, and a number of other critical features.
Make sure, however, when you make any changes to Webmin that restart the Webmin server. You can restart Webmin by clicking the Restart Webmin button that is at the bottom of the Webmin Configuration page.
Controlling Webmin
Controlling Webmin

In the same area of the restart button there are a few other important options. If you know you are going to be using Webmin for all of your configuration needs you will want to make sure Webmin starts at boot.
Another important screen to visit, before you jump into various modules, is the Webmin Users screen. In this screen you can define groups and users and their various permissions for the Webmin system. Here you can define what modules a user or group has access to which can be very handy.
Once you get beyond Webmin basic configuration it is time to poke around the various modules. In later articles I will discuss some of the best of the Webmin modules.

Final Thoughts
Webmin is one of the most powerful administration tools available. If you haven’t experienced the power that is Webmin, install it now and see how much power you can have at your fingertips.

hex dump (with hd ) of boot0 MBR loader of Fre...Image via Wikipedia
In the Linux operating system the $PATH is a listing of all directories where the system will look for commands. What this means is that all of the commands located in the directories included in your path will be globally executable. For example: The /usr/bin directory contains quite a lot of commands that can be excuted from within any directory on your system. Because of this you can issue the ls command from within any directory and get the listing of the contents of that directory. If the ls command wasn’t in a directory in your path you would have to include the explicite path to that command (i.e. /usr/bin/ls).
As a Linux user you can add directories to your $PATH. This is helpful when you don’t want to add a command to a directory in your $PATH but you want that command to be globally executable. Doing this is actually quite easy.

What is currently in your $PATH?
NOTE: This article applies only when you are using the Bash shell. To find out what directories are included in your current $PATH issue the command:
echo $PATH
You should see something like:
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jlwallen/bin
Notice the /opt directory is missing. Often the /opt directory is a great place to “install” other applications for global use. But if this directory is not in your $PATH, you will always have to use the explicit path to call a command. With that in mind let’s add /opt.

.bash_profile
In order to add a directory you have to edit a file in your ~/ (home) directory. The .bash_profile file determines user specific environment and start up programs. This file also  checks for a .bashrc file for aliases and functions, but that has nothing to do with your $PATH.
There is one particular line you need to examine in your .bash_profile:
PATH=$PATH:$HOME/bin
This is the line that determines anything extra in your $PATH. As you can see, in the example above, the extra directory added to the users’ $PATH is the ~/bin directory. Of course in most distributions this isn’t used (or even created during installation). Why ~/bin is still included I do not know. In order to add another directory to your $PATH in this line you would seperate the directories with a “:”. To add the /opt directory that line would now look like:
PATH=$PATH:$HOME/bin:/opt
As you can see the /opt directory has been added proceeding a “:”. Complete this addition and save the file. You’re not done yet.
If you issue the command echo $PATH you will still not see /opt in the users’ $PATH. Why? You have to log out and log back in before this change will take effect. So log out, log back in, and issue the command again. Issuing the command echo $PATH will not issue:
/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jlwallen/bin:/opt
Any command found in the /opt directory is now global.

Final thoughts
The $PATH is a very powerful tool to take advantage of in Linux. By using it you can install applications in directories outside of the norm and still make them global. I often install applications in the /opt directory or will create a /data directory for a more temporary application installation.

Howto Recover Grub2 After Windows Installation.

Posted by ahmedhamdy_27 Thursday, February 18, 2010 View Comments



You will need a LIVE cd if you are going to recover an Ubuntu Box.Download Ubuntu Jaunty, Karmic whatever you want.Open the system with Live CD (I assume you are using Ubuntu Live CD).Press Alt+F2 and enter gnome-terminal command.And continue by entering :


$sudo fdisk -l

This will show your partition table.Here is my table to understand it better :

/dev/sda1 29 8369 66999082+ 83 Linux
/dev/sda2 * 8370 13995 45190845 7 HPFS/NTFS
/dev/sda3 13996 14593 4803435 5 Extended
/dev/sda5 13996 14593 4803403+ 82 Linux swap / Solaris

Now i will mount Linux (sda1 here), i have no external boot partition as you can see.(IF YOU HAVE external one, do not forget to mount it! )

$sudo mount /dev/sda1 /mnt
$sudo mount --bind /dev /mnt/dev
$sudo mount --bind /proc /mnt/proc

The following command is optional (it copies resolv.conf)

$sudo cp /etc/resolv.conf /mnt/etc/resolv.conf

Now chroot into the enviroment we made :

sudo chroot /mnt

After chrooting, you do not need to add sudo before your commands because from now, you will run commands as root.

You may want to edit /etc/default/grub file to fit your system (timeout options etc)

#nano -w /etc/default/grub

Play with the options if you want.(But do not forget to give grub-update command if you saved it ;) )

Now install/recover Grub2 via :

#grub-install /dev/sda

command.However you may get errors with that code like me.If so please use this command :

#grub-install --recheck /dev/sda

Now you can exit the chroot, umount the system and reboot your box :

#exit
$sudo umount /mnt/dev
$sudo umount /mnt/proc
$sudo umount /mnt
$sudo reboot

Dear Windows, It's over

Posted by ahmedhamdy_27 Wednesday, February 17, 2010 View Comments

Dear Windows Professional Service Pack 2:

I didn't want to tell you this in person, because I thought it might be too complicated, and might take too long. After all, we've been together for a long time, almost five years and running now. I know, i know. I know you so well; your control panel, your installation procedures, even when you get mad and go all blue screen on me; what can I say, you kinda grew on me.

But to be honest, things have been going downhill for a long time now. What happened to that lean, fast OS that i first installed? You know, the one that ran Civ 4, Vice City, and even True Crimes without a problem? The one that burned DVD's, CD's, the one that shared music with my xbox without a problem? I don't know. It seems like you've let go of yourself, to be honest. You take over 20 minutes to boot up, you run Civ4 slowly, heck, you even freeze up on me now when i try to watch video. What happened windows? Did you get so confortable that you thought I'd just deal with it?

Well, i've been cheating. See, back in tenth grade, i messed around a bit with this chick, her name was Red Hat Linux. We met in school in my networking 5 class, and i got to know her pretty well. I was all up in her terminal, if you know what i mean . Well, I took her home, and we had a really rough one night stand. I decided she wsn't for me, and i went back to you, because i knew what i was missing. Well, Red Hat has a south african cousin, and her name's Ubuntu...she's kinda hot, too. SHe's got three cousins, Xubuntu, Edubuntu, and Kubuntu, too, and their all sexy.

Well, I guess this letter is to let you know that it's over. I'm not going back, either. You can tempt me with your games, and all the software, but it's alright. I can get to know ubuntu, i can learn to work her terminals. Her freeware. Her internet support. After all, what can i say...she's sexy, fast, and free. ANd you're expensive, bloated, and well, always sick with viruses. I'm done.

I know, i know. I freaked out and formatted you off my hard drive, and then i called you begging and pleading to take me back, and we had angry make up sex. But what was i thinking? I remembered all the bad times we had, and i called Ubuntu up and she understood me just fine. Before I knew it, we were hitting it off again. She installed really quickly, and didn't even need any drivers or anything. Worked beautifully. And did i remind you she's free?

So Windows Professional Service Pack 2, i'm leaving you for Ubuntu know. It's over, we had a good run, but all expensive, virus laden, bloated software relationships must come to an end, right? I guess that's just how it has to be.

Thanks for all the good times though! NOthing like a BSOD when i'm trying to watch a live debate on MSN or CNN, or crashign on me int he middle of civ4.


But i have to go now. It's time to get down and dirty with ubuntu, and if i ever really miss you again, i'll just drink it away with some WINE.

Sincerely,

Bruno


Thanks for Ubuntuforums .

Maintaining MySQL Databases

Posted by ahmedhamdy_27 Tuesday, February 16, 2010 View Comments


Posted on December 04th, 2009 in BeginLinux
                                           MySQL GUI Tools

As a MySQL administrator, you’ll probably end up doing some preventive and corrective database maintenance.  You can use mysqlcheck for both.
First, consider the “virtual” database.  It has  one table called ‘accounts”.  You can check the whole database with the following command:

mysqlcheck -p -u root virtual
Enter password:
virtual.accounts                              OK
Now, what if we just want to check one table of the database?
mysqlcheck -p -u root virtual trivia
Enter password:
virtual.accounts                              OK
As you can see, all you have to do to check just one table is to specify the table name after you specify the database name.  Now, what if you have a database with more than two tables, and you want to check more than one, but not all of the tables?  That’s easy.  Just specify all of the tables that you want to check after you specify the database.
mysqlcheck -p -u root mysql db host proc
Enter password:
mysql.db                                           OK
mysql.host                                         OK
mysql.proc                                         OK
You can also check more than one database at a time.  Let’s say that you want to check the “payroll” and the “contact” databases.
mysqlcheck -p -u root –databases payroll contact
Enter password:
payroll.last_name                                   OK
payroll.first_name                                  OK
payroll.SSN                                         OK
payroll.pay_rate                                    OK
contact.last_name                                   OK
contact.first_name                                  OK
contact.phone_number                                OK
This time, by adding the “–databases” switch, all names that you enter on the command-line will be treated as database names.
It’s also a simple matter to check all databases at once, just by using the “–all-databases” switch:
mysqlcheck -p -u root –all-databases
Enter password:
contacts.names                                     OK
contacts.phone_numbers                             OK
contacts.trivia                                    OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.func                                         OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
You can also use mysqlcheck to perform corrective maintenance.  There’s only one catch, though.  MySQL databases can use two different types of tables–either MyISAM tables or InnoDB tables.  While mysqlcheck can perform checks on either type of table, it can only repair MyISAM tables.
mysqlcheck -p -u root –repair virtual
Enter password:
virtual.accounts                              OK
You can do more extensive repairs by adding another switch:
mysqlcheck -p -u root –repair –extended virtual
Enter password:
virtual.accounts                              OK
Or, you can also do a quick repair:
mysqlcheck -p -u root –repair –quick virtual
Enter password:
virtual.accounts                              OK

How To Back Up MySQL Databases With mylvmbackup

Posted by Linux4all Monday, February 15, 2010 View Comments

How To Back Up MySQL Databases With mylvmbackup On Debian Lenny


mylvmbackup is a Perl script for quickly creating MySQL backups. It uses LVM's snapshot feature to do so.

To perform a backup, mylvmbackup obtains a read lock on all tables and flushes all server caches to disk, creates a snapshot of the volume containing the MySQL data directory, and unlocks the tables again.

This article shows how to use it on a Debian Lenny server.

I do not issue any guarantee that this will work for you!


1 Preliminary Note
I'm assuming that MySQL is already set up and running on your system. The system must use LVM, and the MySQL data directory (/var/lib/mysql) should have an LVM partition of its own (althouth that is optional).

If you have read Back Up (And Restore) LVM Partitions With LVM Snapshots you know that LVM snapshots require some unused LVM partition for the snapshot.

My test system has a second, currently unused hard drive /dev/sdb that will be used by mylvmbackup to create a temporary logical volume for the backup.

This is my current situation:

root@server1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/server1-root
20G 808M 18G 5% /
tmpfs 252M 0 252M 0% /lib/init/rw
varrun 252M 56K 251M 1% /var/run
varlock 252M 0 252M 0% /var/lock
udev 252M 2.6M 249M 2% /dev
tmpfs 252M 0 252M 0% /dev/shm
/dev/sda1 471M 23M 425M 6% /boot
/dev/mapper/server1-mysql
8.9G 170M 8.3G 2% /var/lib/mysql
root@server1:~#

As you see, I have two LVM partitions, / and /var/lib/mysql (plus an LVM swap partition not shown here).

The volume group is named server1, and the volumes are named swap, root, and mysql:

root@server1:~# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name server1
PV Size 29.52 GB / not usable 3.66 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 7557
Free PE 0
Allocated PE 7557
PV UUID 0gCmpE-FGel-9ayg-E2yg-kkEu-B72X-kFvaye

root@server1:~#

root@server1:~# vgdisplay
--- Volume group ---
VG Name server1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.52 GB
PE Size 4.00 MB
Total PE 7557
Alloc PE / Size 7557 / 29.52 GB
Free PE / Size 0 / 0
VG UUID PH5Hpc-jqeP-BFYs-wWlA-hu03-qwuQ-0cNIu3

root@server1:~#

root@server1:~# lvdisplay
--- Logical volume ---
LV Name /dev/server1/swap
VG Name server1
LV UUID RCeLCK-MO5p-xoMq-SwTT-n2NV-GaP6-GaemDp
LV Write Access read/write
LV Status available
# open 2
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0

--- Logical volume ---
LV Name /dev/server1/root
VG Name server1
LV UUID 5Wen7n-xYmh-MQz1-fKH5-0XXa-1y2t-V3PYbb
LV Write Access read/write
LV Status available
# open 1
LV Size 19.53 GB
Current LE 5000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1

--- Logical volume ---
LV Name /dev/server1/mysql
VG Name server1
LV UUID wk8yb6-fDl8-4tg3-tneT-1dDe-wWdy-AfGZ5I
LV Write Access read/write
LV Status available
# open 1
LV Size 8.99 GB
Current LE 2301
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:2

root@server1:~#

Here's an overview of my two hard drives:
root@server1:~# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009353f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 62 497983+ 83 Linux
/dev/sda2 63 3916 30957255 5 Extended
/dev/sda5 63 3916 30957223+ 8e Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table
root@server1:~#

2 Preparing /dev/sdb
Before we can create snapshots on /dev/sdb, we must partition it (Linux LVM) and add it to our volume group (server1).

I will now create the partition /dev/sdb1 and add it to the server1 volume group:

# fdisk /dev/sdb
server1:~# fdisk /dev/sdb


Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel.


Changes will remain in memory only, until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 1305.

There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): <-- n
Command action
e extended
p primary partition (1-4)
<-- p
Partition number (1-4): <-- 1
First cylinder (1-1305, default 1): <-- [ENTER]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): <-- [ENTER]
Using default value 1305

Command (m for help): <-- t
Selected partition 1
Hex code (type L to list codes): <-- 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): <-- w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
pvcreate /dev/sdb1
vgextend server1 /dev/sdb1

That's it - we don't need to create any volumes on it - this will be done by mylvmbackup automatically.


3 Installing And Using mylvmbackup
Debian Lenny provides a package for mylvmbackup, therefore we can simply install it as follows:

# aptitude install mylvmbackup

Take a look at

# man mylvmbackup

to learn how to use it (read the part about InnoDB tables carefully if you're using InnoDB).

The mylvmbackup configuration file is /etc/mylvmbackup.conf, so you can either specify your options on the command line or in that file (command line options will override the options in /etc/mylvmbackup.conf).

The default backup directory is /var/cache/mylvmbackup/backup (unless you specify another location).

A sample command for backing up MyISAM tables would be:

# mylvmbackup --user=root --password=yourrootsqlpassword --mycnf=/etc/mysql/my.cnf --vgname=server1 --lvname=mysql --backuptype=tar

And for InnoDB:
# mylvmbackup --user=root --password=yourrootsqlpassword --innodb_recover --skip_flush_tables --mycnf=/etc/mysql/my.cnf --vgname=server1 --lvname=mysql --backuptype=tar

Make sure you fill in the right password, volume group name (server1 here) and the volume name of the volume that contains the MySQL data (the volume is /dev/server1/mysql, therefore the name is mysql).

I everything goes well, you should see lots of output:

root@server1:~# mylvmbackup --user=root --password=yourrootsqlpassword --mycnf=/etc/mysql/my.cnf --vgname=server1 --lvname=mysql --backuptype=tar
20100127 19:16:58 Info: Connecting to database...
20100127 19:16:58 Info: Flushing tables with read lock...
20100127 19:16:58 Info: Taking position record...
20100127 19:16:58 Info: Taking snapshot...
File descriptor 3 left open
Logical volume "mysql_snapshot" created
20100127 19:16:58 Info: Unlocking tables...
20100127 19:16:58 Info: Disconnecting from database...
20100127 19:16:58 Info: Mounting snapshot...
20100127 19:16:59 Info: Copying my.cnf...
20100127 19:16:59 Info: Taking actual backup...
20100127 19:16:59 Info: Creating tar archive /var/cache/mylvmbackup/backup/backup-20100127_191658_mysql.tar.gz
backup/
backup/mydb/
backup/mydb/sys_modules.MYI
backup/mydb/dns_a.frm
backup/mydb/isp_dienste.MYD
backup/mydb/isp_server_ip.frm
backup/mydb/dns_spf.frm
backup/mydb/dns_a.MYI
backup/mydb/isp_fakt_dep.frm
backup/mydb/multidoc_dep.frm
backup/mydb/isp_isp_web_template.MYI
backup/mydb/sys_nodes.MYD
backup/mydb/listtype.MYD
backup/mydb/help_documents.MYD
backup/mydb/help_tickets.MYI
backup/mydb/doctype.frm
backup/mydb/login.MYI
backup/mydb/isp_com.frm
backup/mydb/help_documents.MYI
backup/mydb/isp_dep.MYD
backup/mydb/help_documents.frm
backup/mydb/isp_server.MYD
backup/mydb/isp_fakt_nodes.MYD
backup/mydb/sys_config.MYD
backup/mydb/dns_nodes.MYI
backup/mydb/sys_config.MYI
backup/mydb/isp_monitor.frm
backup/mydb/isp_server_ip.MYI
backup/mydb/isp_isp_datenbank.frm
backup/mydb/dns_secondary.frm
backup/mydb/isp_nodes.MYI
backup/mydb/dns_isp_dns.MYI
backup/mydb/help_nodes.frm
backup/mydb/isp_fakt_nodes.frm
backup/mydb/isp_server.MYI
backup/mydb/isp_isp_domain.frm
backup/mydb/dns_dep.frm
backup/mydb/session.frm
backup/mydb/isp_isp_cron.MYD
backup/mydb/isp_fakt_record.MYI
backup/mydb/isp_monitor.MYI
backup/mydb/isp_fakt_rechnung.MYI
backup/mydb/listtype.MYI
backup/mydb/isp_fakt_rechnung.MYD
backup/mydb/isp_traffic.frm
backup/mydb/isp_fakt_dep.MYI
backup/mydb/user_groups.frm
backup/mydb/isp_fakt_record.frm
backup/mydb/isp_fakt_artikel.MYD
backup/mydb/isp_htaccess.MYD
backup/mydb/sys_nodes.frm
backup/mydb/groups.frm
backup/mydb/login.MYD
backup/mydb/isp_firewall.MYD
backup/mydb/isp_server.frm
backup/mydb/help_tickets.frm
backup/mydb/multidoc_dep.MYD
backup/mydb/dns_nodes.frm
backup/mydb/dns_a.MYD
backup/mydb/sys_config.frm
backup/mydb/dns_isp_dns.frm
backup/mydb/dns_mx.MYI
backup/mydb/isp_isp_web.MYD
backup/mydb/isp_serverstatus.MYI
backup/mydb/isp_serverstatus.MYD
backup/mydb/sys_dep.MYD
backup/mydb/isp_isp_cron.MYI
backup/mydb/session.MYD
backup/mydb/isp_isp_admin.MYD
backup/mydb/dns_ptr.frm
backup/mydb/dns_mx.frm
backup/mydb/isp_isp_domain.MYD
backup/mydb/sys_dep.MYI
backup/mydb/dns_spf.MYD
backup/mydb/user_groups.MYD
backup/mydb/sys_news.frm
backup/mydb/isp_isp_actions.MYI
backup/mydb/doctype.MYD
backup/mydb/multidoc_nodes.frm
backup/mydb/isp_fakt_artikel.frm
backup/mydb/sys_news.MYD
backup/mydb/isp_traffic.MYD
backup/mydb/user_groups.MYI
backup/mydb/sys_news.MYI
backup/mydb/listtype.frm
backup/mydb/del_status.frm
backup/mydb/isp_fakt_nodes.MYI
backup/mydb/isp_isp_kunde.MYD
backup/mydb/isp_dienste.frm
backup/mydb/dns_mx.MYD
backup/mydb/doctype.MYI
backup/mydb/help_tickets.MYD
backup/mydb/dns_secondary.MYI
backup/mydb/dns_ptr.MYD
backup/mydb/isp_isp_reseller.frm
backup/mydb/isp_dienste.MYI
backup/mydb/isp_isp_datenbank.MYD
backup/mydb/isp_isp_actions.MYD
backup/mydb/isp_isp_web.frm
backup/mydb/db.opt
backup/mydb/isp_server_ip.MYD
backup/mydb/multidoc_nodes.MYI
backup/mydb/dns_nodes.MYD
backup/mydb/isp_fakt_rechnung.frm
backup/mydb/isp_isp_reseller.MYI
backup/mydb/isp_nodes.MYD
backup/mydb/isp_htaccess.MYI
backup/mydb/isp_isp_web_template.frm
backup/mydb/isp_isp_domain.MYI
backup/mydb/dns_secondary.MYD
backup/mydb/dns_dep.MYD
backup/mydb/isp_firewall.MYI
backup/mydb/help_nodes.MYI
backup/mydb/isp_isp_admin.frm
backup/mydb/isp_isp_cron.frm
backup/mydb/isp_isp_datenbank.MYI
backup/mydb/isp_traffic_ip.frm
backup/mydb/isp_fakt_dep.MYD
backup/mydb/isp_dep.MYI
backup/mydb/dns_dep.MYI
backup/mydb/isp_isp_reseller.MYD
backup/mydb/dns_isp_dns.MYD
backup/mydb/isp_fakt_artikel.MYI
backup/mydb/multidoc_dep.MYI
backup/mydb/multidoc_nodes.MYD
backup/mydb/del_status.MYD
backup/mydb/groups.MYD
backup/mydb/isp_isp_web_template.MYD
backup/mydb/isp_htaccess.frm
backup/mydb/isp_dep.frm
backup/mydb/isp_isp_web.MYI
backup/mydb/isp_isp_user.frm
backup/mydb/session.MYI
backup/mydb/isp_isp_admin.MYI
backup/mydb/isp_isp_kunde.MYI
backup/mydb/isp_isp_user.MYI
backup/mydb/isp_fakt_record.MYD
backup/mydb/isp_nodes.frm
backup/mydb/groups.MYI
backup/mydb/del_status.MYI
backup/mydb/dns_spf.MYI
backup/mydb/isp_com.MYD
backup/mydb/isp_isp_user.MYD
backup/mydb/dns_cname.frm
backup/mydb/isp_com.MYI
backup/mydb/dns_cname.MYD
backup/mydb/sys_modules.MYD
backup/mydb/isp_traffic_ip.MYI
backup/mydb/help_nodes.MYD
backup/mydb/sys_user.frm
backup/mydb/isp_traffic_ip.MYD
backup/mydb/sys_user.MYD
backup/mydb/sys_modules.frm
backup/mydb/isp_serverstatus.frm
backup/mydb/sys_dep.frm
backup/mydb/isp_firewall.frm
backup/mydb/isp_monitor.MYD
backup/mydb/isp_isp_kunde.frm
backup/mydb/dns_cname.MYI
backup/mydb/isp_isp_actions.frm
backup/mydb/sys_user.MYI
backup/mydb/sys_nodes.MYI
backup/mydb/dns_ptr.MYI
backup/mydb/isp_traffic.MYI
backup/mydb/login.frm
backup/ib_logfile0
backup/mysql_upgrade_info
backup/debian-5.0.flag
backup/mysql/
backup/mysql/host.MYD
backup/mysql/procs_priv.MYD
backup/mysql/time_zone_transition.MYD
backup/mysql/proc.MYI
backup/mysql/time_zone_name.frm
backup/mysql/time_zone_name.MYD
backup/mysql/help_relation.MYI
backup/mysql/user.MYD
backup/mysql/help_category.MYI
backup/mysql/time_zone.frm
backup/mysql/func.MYD
backup/mysql/help_category.MYD
backup/mysql/time_zone_transition.frm
backup/mysql/time_zone_name.MYI
backup/mysql/help_category.frm
backup/mysql/time_zone_leap_second.frm
backup/mysql/time_zone_transition.MYI
backup/mysql/help_relation.MYD
backup/mysql/host.frm
backup/mysql/db.frm
backup/mysql/db.MYI
backup/mysql/columns_priv.frm
backup/mysql/time_zone.MYI
backup/mysql/time_zone_leap_second.MYD
backup/mysql/func.frm
backup/mysql/columns_priv.MYI
backup/mysql/help_topic.MYD
backup/mysql/host.MYI
backup/mysql/proc.frm
backup/mysql/user.MYI
backup/mysql/help_topic.MYI
backup/mysql/help_relation.frm
backup/mysql/tables_priv.frm
backup/mysql/help_keyword.frm
backup/mysql/user.frm
backup/mysql/time_zone_transition_type.MYI
backup/mysql/procs_priv.frm
backup/mysql/help_topic.frm
backup/mysql/procs_priv.MYI
backup/mysql/time_zone_transition_type.MYD
backup/mysql/func.MYI
backup/mysql/proc.MYD
backup/mysql/tables_priv.MYD
backup/mysql/help_keyword.MYI
backup/mysql/help_keyword.MYD
backup/mysql/time_zone_leap_second.MYI
backup/mysql/tables_priv.MYI
backup/mysql/db.MYD
backup/mysql/time_zone_transition_type.frm
backup/mysql/time_zone.MYD
backup/mysql/columns_priv.MYD
backup/lost+found/
backup/ibdata1
backup/ib_logfile1
backup-pos/backup-20100127_191658_mysql.pos
backup-pos/backup-20100127_191658_my.cnf
20100127 19:17:00 Info: DONE
20100127 19:17:00 Info: Cleaning up...
20100127 19:17:00 Info: LVM Usage stats:
20100127 19:17:00 Info: LV VG Attr LSize Origin Snap% Move Log Copy% Convert
20100127 19:17:00 Info: mysql_snapshot server1 swi-a- 5.00G mysql 0.00
Logical volume "mysql_snapshot" successfully removed
root@server1:~#

Afterwards you can find the backup in the /var/cache/mylvmbackup/backup directory (unless you have specified another location):

# ls -l /var/cache/mylvmbackup/backup
root@server1:~# ls -l /var/cache/mylvmbackup/backup
total 248
-rw-r--r-- 1 root root 246847 2010-01-27 19:17 backup-20100127_191658_mysql.tar.gz
root@server1:~#

The tar.gz file contains two directories, backup (with the databases and tables from /var/lib/mysql which you can simply copy back after a database crash - the database should be stopped when you do this) and backup-pos which contains your my.cnf file (a backup of /etc/mysql/my.cnf):

# cd /var/cache/mylvmbackup/backup
tar xvfz backup-20100127_191658_mysql.tar.gz
ls -l
root@server1:/var/cache/mylvmbackup/backup# ls -l
total 256
drwxr-xr-x 5 mysql mysql 4096 2010-01-27 19:10 backup
-rw-r--r-- 1 root root 246847 2010-01-27 19:17 backup-20100127_191658_mysql.tar.gz
drwxr-xr-x 2 root root 4096 2010-01-27 19:24 backup-pos
root@server1:/var/cache/mylvmbackup/backup#

4 Links
mylvmbackup: http://lenz.homelinux.org/mylvmbackup
MySQL: http://www.mysql.com
Debian: http://www.debian.org

How to make Your Ubuntu Linux Enegy Efficient using PowerTop







Since version 2.6.21, the Linux kernel has introduced a feature called tickless. the kernel no longer has a fixed 1000Hz timer tick.

This will give a dramatic power savings because the CPU stays in low power mode for longer periods of time during system idle.

A Nice handy tool, PowerTop has been created for reducing the Power Usage of Linux.

This application will help to find the software components that are preventing optimal usage of your hardware and give proper suggestions for both hardware and software configurations to reduce power consumption of your system.

So Now Your Ubuntu is energy Efficient.It is very useful for Laptop Users.


How To Install PowerTop in Ubuntu

Open a terminal and type the following

$ sudo apt-get install powertop

Or You can use Synaptic Package manager and select package powertop.

Loading...

BEST WAY TO SAY THANKS

Labels

ubuntu apache mysql backup gnome audio players compile kernel grub restore security themes web hosting 3d games Clonezilla centos cpanel database fun games gmail gzip kernel linux games mod_deflate monitoring tools music making open ssh recovery redhat reinstall grub rsync ssh * Apt-Get * Howto 3d acceleration AMANDA Ardour Bacula Duplicity E-Books Extract files from ISO FlyBack Graphics Card IP Failover and Web Cluste IP Failover and Web Cluster IPv6 Jokosher K9Copy KDE Karmic Linux Linux Set Date and Time Linux Tools Linux backup tools Linux commands Networking Nginx Open VPN Operating system PATH ReZound Remote Desktop Solutions for Linux Reverse Proxy Load Balancer SLAMPP Samba Sweep Time Vault Traverso DAW Ubuntu Tweak Webmin Windows vs Linux antivirus audi studio auto mount bash block ip block users blog editor boot caching check mail dangerous .caution dd deadly commands debian directory listing dns docks dvd easyapache error 18 fedora find fixing partitions table fork() bomb glxinfo hacking handbrake help image initrd install linux iptables jack jaunty lamp ldap lfs linus linux live linux vs windows log mac osx man mod_rewrite mount network boot ntfs open courseware open source books opengl openshot own distro packup php print in linux print over wireless ptr recompile redirect restore disk restore mbr reverse dns rip dvd screen server share desktop speed up linux spf ssmtp stream desktop swatch syslog syslog-ng top toutorials useful applications vi video editor vim vlc vmlinuz wallpapers whm xsplash

Recent Posts

archive

BEST WAY TO SAY THANKS