Mininet Installation

Advertisements

Setup HA-Proxy with Keepalived

Setup HA-Proxy with Keepalived

Two Ubuntu 14.04 servers [1GB RAM each]

hostnames and IP addresses:

    haproxy1 (192.168.1.30)
    haproxy2 (192.168.1.31)

We’ll also need to allocate a third IP address to use as the virtual IP address (VIP).  
We’ll use 192.168.1.32.

# vi /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind=1

Then we run the following command to make this take effect without rebooting:
# sysctl -p

# apt-get update && apt-get install keepalived haproxy -y

# vi /etc/keepalived/keepalived.conf

global_defs {
  router_id haproxy1
}
vrrp_script haproxy {
  script “killall -0 haproxy”
  interval 2
  weight 2
}
vrrp_instance 50 {
  virtual_router_id 50
  advert_int 1
  priority 101
  state MASTER
  interface eth0
  virtual_ipaddress {
192.168.1.32 dev eth0
  }
  track_script {
    haproxy
  }
}

=====================================================================

Note:
router_id to be the hostname, and
the VIP as 192.168.1.32

# vi /etc/haproxy/haproxy.cfg

global
    chroot /var/lib/haproxy
    user haproxy
    group haproxy
    daemon
    log 192.168.1.30 local0
 stats socket /var/lib/haproxy/stats
    maxconn 4000

defaults
    log    global
    mode    http
    option    httplog
    option    dontlognull
        contimeout 5000
        clitimeout 50000
        srvtimeout 50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
 errorfile 504 /etc/haproxy/errors/504.http

listen stats 192.168.1.30:80
        mode http
        stats enable
        stats uri /stats
        stats realm HAProxy\ Statistics
        stats auth admin:password

=====================================================================

Note:
Local IP addressis used in the file in two locations,
in the global section for the log location, and
in the stats listener.  

When you setup the second node, make sure to use its IP address.  
Also notice the username and password in the status auth line.  Set this to whatever you want.  
Then, you will be able to access the stats page via your browser.

Edit the file /etc/default/haproxy and change ENABLED from 0 to 1

Now we can restart the services:
service keepalived restart
service haproxy restart

Once you’ve completed all of these steps on both nodes,
you should now have a highly available load balancer pair.  
At this point, our VIP should be active on one node
(assuming that you built node 1 first, it should be active on that node).  

To confirm, we can use the ip command:

# ip a | grep eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 192.168.1.30/24 brd 192.168.1.255 scope global eth0
    inet 192.168.1.32/32 scope global eth0

Notice that both the local IP and the VIP are shown.
If we now shutdown node 1, node 2 will quickly pick up the VIP.

To further confirm,
# ping 192.168.1.32
from any machine within same network & bring down the node1.

Final Note: Don’t forget to repeat all the steps on second node as well.

 

.bashrc linux tip/hack

.bashrc linux tip/hack

Add the below lines of bash script code to your .bashrc file & then you can start using the command:
$ extract <ANY_ARCHIVE_FILE_NAME>

extract () {
   if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2)   tar xvjf $1    ;;
           *.tar.gz)    tar xvzf $1    ;;
           *.bz2)       bunzip2 $1    ;;
           *.rar)       unrar x $1      ;;
           *.gz)        gunzip $1       ;;
           *.tar)       tar xvf $1       ;;
           *.tbz2)      tar xvjf $1    ;;
           *.tgz)       tar xvzf $1    ;;
           *.zip)       unzip $1       ;;
           *.Z)         uncompress $1  ;;
           *.7z)        7z x $1        ;;
           *)           echo “don’t know how to extract ‘$1’…” ;;
       esac
   else
       echo “‘$1’ is not a valid file!”
   fi
 }

Simple steps to Reset Lost or Forgotten Password of Ubuntu/Linux

Simple steps to Reset Lost or Forgotten Password of Ubuntu/Linux

  1. Reboot your computer.
  2. Hold Shift during boot to start GRUB menu.
  3. Highlight your image and press E to edit.
  4. Find the line starting with “linux” and append rw init=/bin/bash at the end of that line. The end of the line should now look like this: rw init=/bin/bash
  5. Press Ctrl + X to boot.
  6. Type in passwd username.
  7. Set your password.

Test the network speed between two Ubuntu/Linux Machines

Test the network speed between two Ubuntu/Linux Machines

 

iperf: It’s a client server arrangement in that you run it in server mode at one end and connect to its from another computer on the other side of the network.

One both machines run:

$ sudo apt-get install iperf

We’ll start an iperf server on one of the machines:

$ iperf -s

And then on the other computer, tell iperf to connect as a client:

$ iperf -c <address of other computer>

On the client machine, you’ll see something like this:

zen@pwning:~$ iperf -c 192.168.0.5
————————————————————
Client connecting to 192.168.0.5, TCP port 5001
TCP window size: 16.0 KByte (default)
————————————————————
[  3] local 192.168.0.4 port 37248 connected with 192.168.0.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.04 GBytes    893 Mbits/sec