Ubuntu iTOps Tube

advertisement center

Tuesday, February 21, 2012

WOL Wakeonlan Guide: Turn On Servers Remotely Without Physical Access




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.

By mistake, when you shutdown a system instead of rebooting, you can use Wakeonlan to power on the server remotely. Also, If you have a server that don’t need to be up and running 24×7, you can turn off and turn on the server remotely anytime you want.

This article gives a brief overview of Wake-On-LAN and instructions to set up Wakeonlan feature.

Overview of Wake-On-LAN

§  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. wakeonlan package should be installed on the machine.

§  When the system crashes because of power failure, for the first time you cannot switch on your machine using this facility. But after the first first boot you can use wakeonlan to turn it on, if the server gets shutdown for some reason.

§  WakeonLan is also referred as wol.

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:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg  [ Note: check whether flag g is present ]
        Wake-on: g [ Note: g mean enabled. d means disabled ]
        Current message level: 0x00000001 (1)
        Link detected: yes

If  Supports Wake-on is g, then the support for wol feature is enabled on the NIC card.

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.

$ /sbin/ethtool eth0
Settings for eth0:
Cannot get device settings: Operation not permitted
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x000000ff (255)
Cannot get link status: Operation not permitted

Install wakeonlan package on a different machine

Install the wakeonlan package in the machine from where you need to send the magic packet to switch on your server.

# apt-get install wakeonlan

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 00:16:k5:64:A9:68  [ 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

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.

# wakeonlan 00:16:k5:64:A9:68

 

 

The Evolution and Future of Communication Technology




We’ve come a long way since the very first instances of verbal and written communication. From the early stages of speech, along with the primitive use of symbols and pictures to convey messages to one another, we’ve evolved into a communications powerhouse. Data has never been transferred faster and communication has thus never been more sophisticated than it is right now.

Communication: Past to Present

From ancient writing techniques and newspapers we’ve moved on to text messaging and email. From Morse code and telegraphs to telephones and radios, we now moved on to televisions, computers and cell phones.

TV’s that utilized tubes with vacuum seals and boasted analog signals and black and white color are now Flat Screen LCD’s or Plasma’s that boast all digital High Definition Signals, thousands of lines of resolution and millions of color pixels. Rotary phones and dial up communication has been transformed to portable phones. From there they moved on to satellite communication cellular phones. Hand written symbols, numbers and letters went from being carried to being digitally transferred. We no longer have to wait for days to receive information as most of our data messages can be transferred in a matter of seconds over high speed broadband internet connections with computers that boast Gigabytes of Ram and Gigahertz of processor speed.

What’s Next?

With all of the evolution that has taken place, with TV’s, phones, and computers, we wonder what is going to be the next best thing. Despite the popularity of all of these forms of communication individually, I can’t help but pick a technology that does all three. The technology that can host phone calls, transfer data, and hosts television broadcasts gets my vote.

The Inadequate Cell Phone

You may be thinking that your cell phone is where I’m headed with this. Granted, cell phones can transfer data (text messaging, email, web-browsing, etc), and they obviously allow you to make phone calls. Some of them do stream live video broadcasts. They are highly mobile too! I, however, want something that is better equipped for the challenge. Cell phones cannot process information as fast as a computer can send out emails or internet surf. They cannot produce the visual stimulation that a TV is capable of. So, although they can do all three, I’m not picking a super cell phone as the next best thing.

The Impractical Television

This leaves me with my TV and my computer. I am not sure how you feel about this, but I don’t think I want my LCD TV to serve as my phone. For practical purposes, my TV is on my wall, in my living room. Two problems with this are that I would not be able to pick my TV up and move to another room to make a phone call if I wanted privacy and if you have people over watching a game I doubt they would want you to interrupt the game to take a call. If you know how annoying that phone number that pops up on your TV when you have Digital Phone service can be, then you know what I’m talking about.

The Super Computer!

Process of elimination leaves the computer as the last tech standing. Computers are highly capable of data transfer. They can host live video broadcasts with exceptional quality. Now if we can just get them to host phone calls we’d be on to something. Oh wait, they already can! I know that making phone calls through your computer has been something you could do for a long time with a microphone and headphones/speakers. However, with the help of Voice over Internet Protocol (VoIP) phone technology it simply has not been easier. In addition, the development of ridiculously great laptops has pretty much made phone calling through your computer as mobile as your cell phone; sort of. An explanation is coming up soon.

The Integration of VoIP

VoIP allows you to make phone calls in three different ways. You’ll need a high-speed broadband internet connection for all three options. First, you can still make that phone call through your computer using a microphone and headphones/speakers, or a headset that does both. Second, you can actually still use an old phone you have lying around your house to make an internet phone call with the help of a VoIP adapter that hooks up to a broadband connection. A third option, (mainly for businesses that have multiple incoming/outgoing calls) is to buy a special VoIP phone that is just like many other businesses phones but it plugs directly into a broadband connection. It has all sorts of special features right on the user interface so that you can easily answer and transfer calls multiple phone calls. Picking the option that best suits you depends on what your intended use is.

The Need for Networks

The main component of all of these options, the backbone as so to speak, is the network. Without the network that connects all of us to one another, none of this is possible. Therefore, development of a network that is sophisticated enough to meet the demands of modern communication is a necessity. In addition, having all of the necessary networking products to stay connected to it is vital. After all that is said and done, I feel as though VoIP is a great leap in the communications technology field. Combined with the mobility of a laptop and you basically have the recipe for a mobile communications powerhouse.

Network Shortcomings

Right now wireless hotspots are limited. For this combination to really develop, wireless networking must develop. Until your laptop can get connected to the network and stay connected no matter where you go and what you do, you will not always have access to phone calls or your data transfer and television communication options. While you can usually wait to tune in to your favorite TV station or send out an email, you cannot always wait to make or receive an emergency phone call. Therefore, in most cases, VoIP and a laptop will always rank second to a cell phone for speech communication purposes.

Conclusion

When that wireless network expands and can guarantee connectivity in more places I feel VoIP makes a name for itself in our society. After all, if you have a laptop already capable of high speed data transfer that can now allow you to make phone calls and watch TV; you probably will spend a lot less paying for all three services individually. Let’s look forward to network development and VoIP to take us into the future of communications technology.

 

3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id


 

 

You can login to a remote Linux server without entering password in 3 simple steps using ssky-keygen and ssh-copy-id as explained in this article.

ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.

This article also explains 3 minor annoyances of using ssh-copy-id and how to use ssh-copy-id along with ssh-agent.

Step 1: Create public and private keys using ssh-key-gen on local-host

jsmith@local-host$ [Note: You are on local-host here]
 
jsmith@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host

Step 2: Copy the public key to remote-host using ssh-copy-id

jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
jsmith@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:
 
.ssh/authorized_keys
 
to make sure we haven't added extra keys that you weren't expecting.

Note: ssh-copy-id appends the keys to the remote-host’s .ssh/authorized_key.

Step 3: Login to remote-host without entering the password

jsmith@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[Note: SSH did not ask for password.]
 
jsmith@remote-host$ [Note: You are on remote-host here]


The above 3 simple steps should get the job done in most cases.

We also discussed earlier in detail about performing SSH and SCP from openSSH to openSSH without entering password.

If you are using SSH2, we discussed earlier about performing SSH and SCP without password from SSH2 to SSH2 , from OpenSSH to SSH2 and from SSH2 to OpenSSH.

Using ssh-copy-id along with the ssh-add/ssh-agent

When no value is passed for the option -i and If ~/.ssh/identity.pub is not available, ssh-copy-idwill display the following error message.

jsmith@local-host$ ssh-copy-id -i remote-host
/usr/bin/ssh-copy-id: ERROR: No identities found


If you have loaded keys to the ssh-agent using the ssh-add, then ssh-copy-id will get the keys from the ssh-agent to copy to the remote-host. i.e, it copies the keys provided by ssh-add -Lcommand to the remote-host, when you don’t pass option -i to the ssh-copy-id.

jsmith@local-host$ ssh-agent $SHELL
 
jsmith@local-host$ ssh-add -L
The agent has no identities.
 
jsmith@local-host$ ssh-add
Identity added: /home/jsmith/.ssh/id_rsa (/home/jsmith/.ssh/id_rsa)
 
jsmith@local-host$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsJIEILxftj8aSxMa3d8t6JvM79DyBV
aHrtPhTYpq7kIEMUNzApnyxsHpH1tQ/Ow== /home/jsmith/.ssh/id_rsa
 
jsmith@local-host$ ssh-copy-id -i remote-host
jsmith@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:
 
.ssh/authorized_keys
 
to make sure we haven't added extra keys that you weren't expecting.
[Note: This has added the key displayed by ssh-add -L]

Three Minor Annoyances of ssh-copy-id

Following are few minor annoyances of the ssh-copy-id.

1.    Default public key: ssh-copy-id uses ~/.ssh/identity.pub as the default public key file (i.e when no value is passed to option -i). Instead, I wish it uses id_dsa.pub, or id_rsa.pub, or identity.pub as default keys. i.e If any one of them exist, it should copy that to the remote-host. If two or three of them exist, it should copy identity.pub as default.

2.    The agent has no identities: When the ssh-agent is running and the ssh-add -L returns “The agent has no identities” (i.e no keys are added to the ssh-agent), the ssh-copy-id will still copy the message “The agent has no identities” to the remote-host’s authorized_keys entry.

3.    Duplicate entry in authorized_keys: I wish ssh-copy-id validates duplicate entry on the remote-host’s authorized_keys. If you execute ssh-copy-id multiple times on the local-host, it will keep appending the same key on the remote-host’s authorized_keys file without checking for duplicates. Even with duplicate entries everything works as expected. But, I would like to have my authorized_keys file clutter free.

 

 

How To Manage Dell Servers using OMSA ? OpenManage Server Administrator On Linux


 

 

OMSA is a web based application to manage DELL PowerEdge Servers. Using OMSA you can perform proactive system monitoring, system diagnosis, troubleshoot hardware issues and configure RAID etc., You can also view and manage hardware's embedded system management (ESM) log using OMSA.

This is an jumpstart guide that explains how to install Dell OMSA on Linux. I have also provided few screenshots of DELL OMSA web application.

1. Download DELL OMSA

Go to DELL support website -> click on "Drivers & Downloads" -> choose your server model (in my case, I selected PowerEdge 2850) -> choose the operating system -> scroll-down and expand 'Systems Management' -> Click on 'OpenManage Server Administrator Managed Node' -> Click on OM_5.5.0_ManNode_A00.tar.gz to download it. You can directly download it to your Linux server as shown below.

 

# mkdir -p /usr/local/omsa
# cd /usr/local/omsa
# wget http://ftp.us.dell.com/sysman/OM_5.5.0_ManNode_A00.tar.gz

2. Install DELL OMSA

Perform an express OMSA installation as shown below. After the installation, check /var/log/srvadmin.log for any installation errors.

# gzip -d OM_5.5.0_ManNode_A00.tar.gz
# tar xvf OM_5.5.0_ManNode_A00.tar
# sh linux/supportscripts/srvadmin-install.sh --express
Installing the selected packages.
 
Preparing...                ###################################### [100%]
   1:srvadmin-omilcore      ###################################### [  8%]
     To start all installed services without a reboot,
     enter the following command:  srvadmin-services.sh  start
   2:srvadmin-syscheck      ###################################### [ 15%]
   3:srvadmin-deng          ###################################### [ 23%]
   4:srvadmin-omauth        ###################################### [ 31%]
   5:srvadmin-omacore       ###################################### [ 38%]
   6:srvadmin-jre           ###################################### [ 46%]
   7:srvadmin-ipmi          ###################################### [ 54%]
   8:srvadmin-hapi          ###################################### [ 62%]
   9:srvadmin-isvc          ###################################### [ 69%]
  10:srvadmin-cm            ###################################### [ 77%]
  11:srvadmin-iws           ###################################### [ 85%]
  12:srvadmin-omhip         ###################################### [ 92%]
  13:srvadmin-storage       ###################################### [100%]

3. Start DELL OMSA Services

Invoke the srvadmin-services.sh script to start the OMSA services as shown below.

# sh linux/supportscripts/srvadmin-services.sh start
Starting Systems Management Device Drivers:
Starting dell_rbu:                                         [  OK  ]
Starting ipmi driver:                                      [  OK  ]
Starting Systems Management Data Engine:
Starting dsm_sa_datamgr32d:                                [  OK  ]
Starting dsm_sa_eventmgr32d:                               [  OK  ]
Starting DSM SA Shared Services:                           [  OK  ]
Starting DSM SA Connection Service:                        [  OK  ]

4. Access OMSA from web browser

By default, OMSA web application runs on Port 1311 . Login to OMSA from web using the URL: https://{omsa-server-ip-address}:1311 using root as shown below. Please note that you can login only using HTTPS.

Fig: DELL OMSA – Web Login Screen

5. Check overall system health of the server

To check the overall system health of various hardware components, expand system menu and click on 'Main System Chassis', which will display the health of Memory, CPU etc., as shown below.

Fig: DELL OMSA – Check System Health

6. Clear System Event Log on DELL PowerEdge Servers

Sometimes you will see hardware error messages on the front side of the server even after the problem is fixed.  To clear this false alarm,  you have to clear the hardware's Embedded System Management (ESM) Log. To clear hardware event logs, login to DELL OMSA -> Click on Logs TAB -> click on Clear Log.

7. Create RAID (Virtual Disk) group using OMSA

To create a new raid group, click on Storage -> select "Create Virtual Disk" from the drop-down menu next to "PERC 4e/Di", as shown below. -> Click on Execute -> and follow the on-screen instructions to create a new RAID group.

Fig: DELL OMSA – Create RAID


You can also create RAID using PERC/CERC Bios Configuration Utility as explained in 
Step-by-Step Guide to Configure Hardware RAID on DELL servers with Screenshots.

Once the RAID group is created, to view the RAID, click on Storage -> "PERC 4e/Di (Embedded)" -> Click on "Virtual Disks" -> Click on "Virtual Disks 0″ -> This will display the details of the physical disks of that particular RAID group as shown below.

Fig: DELL OMSA – View RAID

 

Overview of MySQL information_schema Database With Practical Examples


 

 

Starting from MySQL 5, when you execute show databases command, information_schema will be listed in the database list.information_schema is a virtual MySQL database that stores metadata information of all the MySQL databases.

Typically you will execute either DESCRIBE or SHOW commands to get the metadata information. However using the information_schema views, you can execute the standard select SQL command to get the metadata information. In this article, let us review few practical examples on how to use the information_schema database.

1. Get basic information about information_schema

show databases command will display the information_schema in the database list. information_schema is not a physical database.  When you perform select on the information_schema tables, it pulls the data from the real database and other system variables.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bugs               |
| mysql              |
| sugarcrm           |
+--------------------+
4 rows in set (0.00 sec)

Following are the tables (views) available in the information_schema database.

mysql> use information_schema;
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| KEY_COLUMN_USAGE                      |
| PROFILING                             |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+---------------------------------------+
17 rows in set (0.00 sec)

2. Query to display tables with more than 1000 rows

Using the above mentioned information_schema tables you can build your own query to get metadata information. This example displays the MySQL tables that have more than 1000 rows.

mysql> select concat(table_schema,'.',table_name) as table_name,table_rows
    -> from information_schema.tables where table_rows > 1000
    -> order by table_rows desc;
 
+----------------------------------+------------+
| table_name                       | table_rows |
+----------------------------------+------------+
| bugs.series_data                 |      52778 |
| bugs.bugs_activity               |      26436 |
| bugs.longdescs                   |      21473 |
| bugs.email_setting               |       5370 |
| bugs.attachments                 |       4714 |
| bugs.attach_data                 |       4651 |
| bugs.cc                          |       4031 |
| bugs.bugs                        |       2190 |
| bugs.namedqueries_link_in_footer |       1228 |
+----------------------------------+------------+
9 rows in set (0.04 sec)

3. Query to list all tables without primary key

This example gives a list of all the tables without primary key.

SELECT CONCAT(t.table_name,".",t.table_schema) as table_name
FROM information_schema.TABLES t
LEFT JOIN information_schema.TABLE_CONSTRAINTS tc
ON t.table_schema = tc.table_schema
AND t.table_name = tc.table_name
AND tc.constraint_type = 'PRIMARY KEY'
WHERE tc.constraint_name IS NULL
AND t.table_type = 'BASE TABLE';

4. Implement history data for tables using information_schema

Putting the MySQL information_schema to Use article implements a history database using the information schema. The first half of this article describes the requirements for the history database, and a generic design to implement it. The second half describes the stepwise construction of code-generator that creates the SQL to construct and load the history database. The code-generator is driven by the information schema and some features of the information schema are discussed in detail.

5. Query to list top 5 largest tables in the database

This examples gives the top 5 largest space occupying tables in the database along with it’s size in MB.

mysql> SELECT concat(table_schema,'.',table_name) table_name,
    -> concat(round(data_length/(1024*1024),2),'M') data_length
    -> FROM information_schema.TABLES
    -> ORDER BY data_length DESC LIMIT 5;
 
+--------------------+-------------+
| table_name         | data_length |
+--------------------+-------------+
| bugs.attach_data   | 706.89M     |
| bugs.longdescs     | 3.45M       |
| bugs.bugs_activity | 1.45M       |
| bugs.series_data   | 0.75M       |
| bugs.attachments   | 0.51M       |
+--------------------+-------------+
5 rows in set (0.05 sec)