Managing Linux servers _unix Linux via COM ports

Source: Internet
Author: User
Tags comments extend system log

This paper briefly introduces how to extend the console of Linux server through the common COM port, which is practical and simple, not limited by the server network, and can easily manage the Linux server in the actual production environment.

When it comes to managing Linux servers, there are many different ways to do this: Keyboard + monitor, Web Landing, web-based tools, graphics tools under X system, and so on, which is not a problem on a regular server or on your own PC server, but to manage a server in 24x7 mode , it is not so easy to ensure that you can manage the server directly and quickly under any circumstances.

In contrast to the several ways mentioned above:


The graphics tool under X System. This is of course the interface is very friendly way, and the X system can be extended to the remote network, but the network is not so reliable after all, if the server network is paralyzed, you just need to solve the network problem, how to do?

Web-based tools. The interface is also very friendly, such as WebAdmin, but because of security problems, these tools are not installed on the really important server, and this approach is also limited by the network;

Landing through the web. This is a common approach, the general server will open SSH service to the trusted remote site, so that maintenance personnel can log on remotely for day-to-day maintenance, which is very safe, but unfortunately it is also based on the network, of course, limited by the network;

Keyboard + Monitor. This is the safest way, the author recommends the use of this most insurance method, but unfortunately this is also flawed, that is, there are many servers are not equipped with a monitor and keyboard, even if there is only the installation system to use, once put into production operation will no longer use the monitor and keyboard.

In fact, for the server of Unix/linux system, it can extend the console of the system through COM port, serial port, as another way to manage the server.

Console, that is, the console, is the system output management information of the character output device, these management information is generated by the kernel, such as System log, alarm information. The default console for Linux is the keyboard and monitor, while some old-fashioned sun, HP, IBM servers use serial port-connected text Terminal[1] (character terminals, such as the famous Dec VT100) as consoles, which is the way it will be introduced this time.

Character terminals are used more in the mainframe era, a mainframe usually joins many terminals, each terminal has no processing power, simply enters with the keyboard and outputs the results from the screen, and the processing is done by mainframes. The character terminal screen is more black-and-white character type, does not have the graphic display function. Here the text terminal and mainframe terminal is the same, but there is no new terminal equipment in the market, now all through the application simulation of a terminal, called virtual terminals, such as Windows HyperTerminal is commonly used in a virtual terminal program, Using the open HyperTerminal on the management station (using the correct rate) is the equivalent of a terminal.

This implementation of the console function through the serial port is widely used, such as Cisco's routers, are in this way to manage the device, a small console line is equivalent to a PC monitor plus keyboard, which undoubtedly saved the router a lot of unnecessary accessories, In fact, part of Cisco's equipment is a PC, such as Cisco PIX515 Firewall, as long as you plug in a PCI card to the PCI slot, connect the monitor, press the PIX switch, you can see an BX motherboard, Pentium II 350MHZ processor, 128M memory computer startup information, and a normal computer to start is no different. When the PIX completes the self-test, the console is transferred to the console port, and the console port of the RJ45 interface is actually a COM port, but the interface form is not a 9-pin D-shaped port.

It is now clear what we need to do: Use the virtual Terminal program of the management workstation to simulate a character terminal device, redirect the Linux console to the virtual terminal through the COM port to the COM port to realize the control of the Linux server from the virtual terminal. The steps are as follows:

  1. Make Cross Line

Two computers need a "null modem CABLE" to connect with COM ports, "Null modem CABLE" is roughly "crossed Modem line", and the crossover line means similar to the wire, which is used to "back-to-back" connection two DTE devices, Both ends are 9-pin D-type female connector, inserted into the management station and the server's COM mouth, in order to facilitate the identification of recommendations are the first COM port. This line can be made by itself, you can also go to the computer city to buy, the most convenient is the standard console line with Cisco and RJ45 to 9-pin D-Type adapter (part number 74-0495-01), you can use directly. You can make reference to the following line order:

Abbreviation Pin definition Direction Pin definition
Rxd Receive Data 2 <---- 3 TxD Transmit Data
TxD Transmit Data 3 ----> 2 Rxd Receive Data
+--> 6 DSR Data Set Ready
DTR Data Terminal Ready 4 --+--> 1 DCD Carrier Detect
GND Signal Ground 5 <----> 5 GND Signal Ground
DCD Carrier Detect 1 <--+
Dsr Data Set Ready 6 <--+-- 4 DTR Data Terminal Ready
Rts Request to Send 7 ----> 8 CTS Clear to Send
Cts Clear to Send 8 <---- 7 RTS Request to Send
RI Ring Indicator 9 (Not used)

The Txd and Rxd, CTS and RTS, GND and GND, DTR and DSR&DCD are required to be produced, and DSR&DCD indicate that the two pins are concatenated together as a pin signal. For more detailed information see serial-howto[3].

  2, test connectivity

After the management of the work station and the server are connected to the crossover line, you can simply test whether the line is working. Create a new join at the management station with HyperTerminal, rate 9600,8 data bits, 1 stop bit, no parity bit, no hardware "flow control", echo ' 1 ' >/dev/ttys0 on the server (requires root permission), In the management workstation HyperTerminal, see if you can receive the number 1, if you can receive it indicates that the join is no problem. If you do not receive the correct signal pins on the server, use the command "STATSERIAL/DEV/TTYS0" to view the status of the current serial port (the DSR state is 0 when the cable is not connected to the management station or when the line sequence is wrong), the join status is as follows:

Device:/DEV/TTYS0
Signal Name Pin (25) Pin (9) Direction (computer) Status Full Name
----- --- --- --------- ------ -----
FG 1 - - - Frame Ground
TxD 2 3 Out - Transmit Data
Rxd 3 2 In - Receive Data
Rts 4 7 Out 1 Request to Send
Cts 5 8 In 0 Clear to Send
Dsr 6 6 In 1 Data Set Ready
GND 7 5 - - Signal Ground
DCD 8 1 In 0 Data Carrier Detect
DTR 20 4 Out 1 Data Terminal Ready
RI 22 9 In 0 Ring Indicator

3. Starting from Post

This is a feature that many computers cannot achieve, depending on whether the motherboard BIOS is supported or not. Post (power on Self test), which is what we usually say, we can see the basic information of the system and the process of inspection, and of course, there may be the error message and the corresponding processing prompt, Some models of server boards (such as Intel original NL440BX) can redirect posts to COM ports, so that we can connect to a terminal to see the post process on the COM port, and of course it can be done through the terminal, without the need for a keyboard or monitor at all. Unfortunately, in general, our motherboard does not support this feature, but it does not matter, we can first set the BIOS parameters (Halt on set to none) ignore the insignificant error message, so that each system self-test smoothly through, so that the system can smoothly into the hard drive started.

4. REDIRECT Grub

Maybe you have several systems (such as FreeBSD), or a new kernel needs to be tested, and you may want to select the system via a COM port, and it is possible to redirect grub to the COM port. We can see its support seriral terminal on Grub's manual page [4], and add two lines to the front of the Grub config file title first:

Serial--unit=0--speed=38400
Terminal Serial Console


We will be able to receive from the terminal in the COM port to see Grub tips, through the upper and lower keys to select the light band can be correctly entered into each system. For a similar use of Lilo, see the Lilo man page.

5. REDIRECT Console

In order to be able to control the Linux server boot process, we need to pass some parameters to the Linux kernel, from serial-console[2] we can see that only need to pass the console=ttys0,9600 into the kernel can be implemented console redirect to the serial port. Of course, the speed of 9600 is too slow, we can use the rate of 38400, so that the display speed and the display at the start of the speed of the same. My server uses grub, so the kernel statements in my/boot/grub/menu.lst file are as follows:

kernel/vmlinuz-2.4.20-8 ro root=label=/console=tty0 console=ttys0,38400


Now reboot the Linux server and turn on HyperTerminal. No accident can see the usual on the display to see the start of the information, of course, you can also press "I" key into the interactive start mode, of course, after accidentally kicked off the power can also easily input "Y" File system detection, is not very easy to use? But how did you stop when you started the system? Like Linux is stupid, it doesn't know I want to log into the system from here? Do not blame Linux, we will immediately explain why this is the case and the solution.

6, open ttyS0 Landing

In fact, Linux startup information is displayed by kernel, by default, after the launch of the Init Mingetty to provide 6 virtual terminals to login system, which can be clearly seen in the/etc/inittab file. In fact, login and the kernel is not related, so if you just add parameters in the kernel so that it can interactively operate from the COM port does not represent the ability to log on from the HyperTerminal system, we need to run a separate program to provide access from the serial port, this program is Agetty, It is part of the Util-linux package, and you can refer to the man's man page for more information, which is also mentioned in other documents [1][3]. I added a line to the server's/etc/inittab file as follows:

S0:2345:respawn:/sbin/agetty-l 38400 ttyS0


So we can log into the system from the HyperTerminal, it is very easy to use it.

7. Some experience

There are some small tips and experiences with ttyS0 login, and here's my experience:

The transmission distance of the COM port is limited, the ordinary cable is only 15 meters of effective distance, it is recommended to use 5 types of twisted pair, can extend to 50 meters can still normal operation;

We generally want to use root login from ttyS0, but this is not the default, we need to add the terminal to the file/etc/securetty, that is, terminal ttyS0 is a safe terminal, you can use root login;

If the server is open for a long time, it is best to use exit every time to exit the terminal, because if not, the next time you log in may be input garbled lead to terminal unavailable, and so on, and at the login prompt input garbled is irrelevant;

If you manage an actual 24x7 server in this way, you may sometimes find that there is no response in the terminal to press ENTER, there is a possibility that the system after the power outage and then boot up the service, such as NFS and SendMail, so the card is locked in there, This is especially true in the case of power supply instability, so be sure to connect your Linux server to a UPS uninterruptible power supply, or in the system BIOS to set off the system, if it is not too important, in this case only by pressing the keyboard reboot or direct power to restart once again, Check the startup process exactly what happened, generally only need to check the hard drive is no problem;

If your ttyS0 appear garbled no way to use, you can try to log in from the network, the/etc/inittab ttyS0 that line of comments, use the "init Q" command to stop the Agetty started through the Inittab, and then cancel the/etc/ Inittab in the comments, again "init Q" command to start Agetty, no accident will be able to return to normal.

Conclusion

It is easy for us to manage Linux servers without monitors and keyboards, and a terminal server can be used instead of a management workstation to manage very many servers in real production. Simply put, the Terminal server has many COM ports that can simultaneously connect multiple servers (or network devices such as Cisco routers) console for centralized management. Linux can also be a good Terminal server, we will introduce another.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.