Thursday, 5 May 2016

Enabling Wake on LAN in ASUS Tek Motherboard (BIOS)

Go to Advanced --> APM --> Power on by PCIE/PCI [Disabled]

enable Power on by PCIE/PCI

Power on by PCIE/PCI [Enabled]

hit F10 to save and exit.

WOL Wake-on-lan Guide: Turn On Servers Remotely Without Physical Access


A) Description :-

Wakeonlan (wol) enables you to switch ON remote servers without physically accessing it. Wakeonlan sends magic packets to wake-on-LAN enabled ethernet adapters and motherboards to switch on remote computers.

B) Requirements :-

  • You can use Wakeonlan when a machine is connected to LAN, and you know the MAC address of that machine.
  • Your NIC should support wakeonlan feature, and it should be enabled before the
    shut down. In most cases, by default wakeonlan is enabled on the NIC.
  • You need to send the magic packet from another machine which is connected to the same network ( LAN ). You need root access to send magic packet.
  • Required packages:
ethtool on the machine you want to turn on(remote machine).
net-tools on the local machine you want to use to wake the remote machine.
plus, your network card MUST support Wake-on-LAN(wol).

C) Steps to be performed on the REMOTE MACHINE {to wake up} :-
  1. Enable "Wake on LAN" in the BIOS :-
{Go to BIOS -> Power -> Wake-on-lan -> Enable}
  1. Install the required packages :-
*By default, package ethtool is already installed with OS. Run the command “ethtool” to check whether the package is available or not, otherwise install them with following command.
# yum -y install ethtool
  1. Check whether wol is supported on the NIC :-
Execute the following ethtool command in the server which you want to switch ON from a remote place.
# ethtool eth0
Settings for eth0:
Supports Wake-on: pumbg [ Note: check whether flag g is present ]
Wake-on: d [ Note: g mean enabled. d means disabled ]

The 'g' in Supports Wake-on: pumbg indicates that wake-on-lan by using a 'magic packet' is supported.In addition, you need to tell your network card to enable wake-on-lan: g
  1. Enabling wol option on the Ethernet Card :-
By default the Wake-on will be set to g in most of the machines. If not, use ethtool to set the g flag to the wol option of the NIC card as shown below.
# ethtool -s eth0 wol g
Note: You should execute ethtool as root, else you may get following error message.
{ Optional in some cases :-
vim /etc/sysconfig/network-scripts/ifcfg-eth0
# add at the last line
ETHTOOL_OPTS="wol g"
}
  1. Note down the MAC address of the remote server
Note down the MAC address of the server that you wish to switch on remotely.
# ifconfig
eth0     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX  [ Mac address ]
          inet addr:192.168.6.56  Bcast:192.168.6.255  Mask:255.255.255.0
          inet6 addr: fe80::216:17ff:fe6b:289/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3179855 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2170162 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3832534893 (3.5 GB)  TX bytes:390304845 (372.2 MB)
          Interrupt:17
C) Steps to be performed on the LOCAL MACHINE :-
  1. Install the required packages :-
*By default, package net-tools is already installed with OS. Run the command “ether-wake” to check whether the package is available or not, otherwise install them with following command.
# yum -y install net-tools
  1. Finally, Switch ON the machine remotely without physical access
When the server is not up, execute the following command from another machine which is connected to the same LAN. Once the magic packet is sent, the remote system will start to boot.
# ether-wake -i eth0 XX:XX:XX:XX:XX:XX [ Mac address ]
 Note :- ether-wake is a command to power on the system, -i is an interface option, eth0 is an interface of your local machine in which you are running ether-wake command and which will be used to power on the remote system having MAC as specified.



Tuesday, 3 May 2016

Configure PostgreSQL With Django Application

# su - postgres
$psql
# CREATE DATABASE projectdata;
#CREATE USER projectdatauser WITH PASSWORD ‘password’;
#ALTER ROLE projectdatauser SET client_encoding TO ‘utf8’;
#GRANT ALL PRIVILEGES ON DATABASE projectdata TO projectdatauser;
#\q
$exit
#django-admin.py startproject djangoproject
#vim djangoproject/djangoproject/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'projectdata',                     
        'USER': 'projectdatauser',                     
        'PASSWORD': 'password',                 
        'HOST': 'localhost',                     
        'PORT': '5433',                     
    }
}


save and exit
#cd  djangoproject
#./manage.py syncdb
#python manage.py runserver