Open main menu

OpenVZ Virtuozzo Containers Wiki β

Editing Remote console setup

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
 +
<translate>
 +
<!--T:1-->
 
In case you are experiencing a kernel crash ([[oops]]) and have already [[Hardware testing|tested your hardware]], you should report what kernel says to the console (i.e. an [[oops]] text) to [https://bugs.openvz.org/ bug tracker]. Sometimes kernel crashes so badly that <tt>syslogd</tt> is not working and what kernel says is never written to a file. If this is the case, you have to catch what kernel says. There are several ways possible.
 
In case you are experiencing a kernel crash ([[oops]]) and have already [[Hardware testing|tested your hardware]], you should report what kernel says to the console (i.e. an [[oops]] text) to [https://bugs.openvz.org/ bug tracker]. Sometimes kernel crashes so badly that <tt>syslogd</tt> is not working and what kernel says is never written to a file. If this is the case, you have to catch what kernel says. There are several ways possible.
  
== KDump ==
+
== KDump == <!--T:2-->
  
 +
<!--T:3-->
 
With RHEL6-based servers, kdump is pre-configured. See http://kb.odin.com/en/10044 to check the configuration. Dumps can be found under <code>/var/crash/</code> directory.
 
With RHEL6-based servers, kdump is pre-configured. See http://kb.odin.com/en/10044 to check the configuration. Dumps can be found under <code>/var/crash/</code> directory.
  
== Manual/Photo ==
+
== Manual/Photo == <!--T:4-->
 
If kernel backtrace is not long enough there are chances that it can fit into a single screen. In that case, you can just make a photo of the kernel crash screen and attach it to the bug report. If you do not have a camera, you still can carefully write down (using a piece of paper and a pen, that is) what you see on the screen, and later type it into the bug report.
 
If kernel backtrace is not long enough there are chances that it can fit into a single screen. In that case, you can just make a photo of the kernel crash screen and attach it to the bug report. If you do not have a camera, you still can carefully write down (using a piece of paper and a pen, that is) what you see on the screen, and later type it into the bug report.
  
== Serial console ==
+
== Serial console == <!--T:5-->
 
Here is a description of a common routine that is necessary to set up a serial console.
 
Here is a description of a common routine that is necessary to set up a serial console.
  
=== Hardware setup ===
+
=== Hardware setup === <!--T:6-->
 
First of all you should make sure that your node has a [[w:Serial port|serial port]]. If there is no such port then
 
First of all you should make sure that your node has a [[w:Serial port|serial port]]. If there is no such port then
 
unfortunately this way is not for you.
 
unfortunately this way is not for you.
  
 +
<!--T:7-->
 
Then you need to find a second machine with a serial port on it.
 
Then you need to find a second machine with a serial port on it.
 
This machine will be used to collect logs from your primary machine. Further you need to acquire
 
This machine will be used to collect logs from your primary machine. Further you need to acquire
 
so-called [[w:Serial cable|null modem cable (a.k.a. serial cable)]] and it must be long enough to connect these two machines.
 
so-called [[w:Serial cable|null modem cable (a.k.a. serial cable)]] and it must be long enough to connect these two machines.
  
=== Software setup ===
+
=== Software setup === <!--T:8-->
  
==== Sending side ====
+
==== Sending side ==== <!--T:9-->
 
In your boot loader add the following kernel parameters:  
 
In your boot loader add the following kernel parameters:  
 
<pre>
 
<pre>
Line 39: Line 43:
 
</pre>
 
</pre>
  
 +
<!--T:12-->
 
Kernel loaded with such parameters will send all kernel messages to /dev/ttyS0 (first serial port, a.k.a. COM1). If you have several ports, make sure that your null modem cable is connected to the appropriate port.
 
Kernel loaded with such parameters will send all kernel messages to /dev/ttyS0 (first serial port, a.k.a. COM1). If you have several ports, make sure that your null modem cable is connected to the appropriate port.
  
Line 51: Line 56:
 
or something more sophisticated: syslogd, watchtty etc.
 
or something more sophisticated: syslogd, watchtty etc.
  
==== Port setup ====
+
==== Port setup ==== <!--T:15-->
 
One more important thing. 115200 in the example above is the rate of emitting port. Receiving port must also work at the same rate. For example, to tune ttyS0 rate use stty program like this:
 
One more important thing. 115200 in the example above is the rate of emitting port. Receiving port must also work at the same rate. For example, to tune ttyS0 rate use stty program like this:
 
<pre>
 
<pre>
Line 57: Line 62:
 
</pre>
 
</pre>
  
 +
<!--T:16-->
 
Some other serial port parameters, like parity, number of stop bits etc. should also be the same on both sides.
 
Some other serial port parameters, like parity, number of stop bits etc. should also be the same on both sides.
  
== Netconsole ==
+
== Netconsole == <!--T:17-->
  
=== Kernel recompilation ===
+
=== Kernel recompilation === <!--T:18-->
 
If you use binary kernel from openvz.org, it already has netconsole module compiled in, so just skip to next section.
 
If you use binary kernel from openvz.org, it already has netconsole module compiled in, so just skip to next section.
  
 +
<!--T:19-->
 
If you build the kernel yourself, you might need to check if netconsole is compiled. To that effect, change to your kernel source directory and grep your kernel <tt>.config</tt> for NETCONSOLE:
 
If you build the kernel yourself, you might need to check if netconsole is compiled. To that effect, change to your kernel source directory and grep your kernel <tt>.config</tt> for NETCONSOLE:
 
<pre>
 
<pre>
Line 70: Line 77:
 
</pre>
 
</pre>
  
 +
<!--T:20-->
 
If you see nothing or "# CONFIG_NETCONSOLE is not set" you need to recompile the kernel.
 
If you see nothing or "# CONFIG_NETCONSOLE is not set" you need to recompile the kernel.
  
 +
<!--T:21-->
 
Edit your kernel configuration file <tt>.config</tt> with a text editor (<tt>nano .config</tt> or <tt>vi .config</tt>). Set netconsole to Y or M (depending on whether you want it as a module or built into the kernel; I have compiled it as a module):
 
Edit your kernel configuration file <tt>.config</tt> with a text editor (<tt>nano .config</tt> or <tt>vi .config</tt>). Set netconsole to Y or M (depending on whether you want it as a module or built into the kernel; I have compiled it as a module):
  
 +
<!--T:22-->
 
<pre>CONFIG_NETCONSOLE=m</pre>
 
<pre>CONFIG_NETCONSOLE=m</pre>
  
 +
<!--T:23-->
 
Save the file, then recompile the kernel:
 
Save the file, then recompile the kernel:
  
# make bzImage && make modules && make modules_install
+
<!--T:24-->
 
+
<pre>
 +
# make bzImage && make modules && make modules_install
 +
</pre>
 
Update your bootloader for the new updated kernel. In my case I use LILO so I just type lilo at the prompt.
 
Update your bootloader for the new updated kernel. In my case I use LILO so I just type lilo at the prompt.
  
 +
<!--T:25-->
 
Reboot into new kernel.
 
Reboot into new kernel.
  
=== Setting up OpenVZ side ===
+
=== Setting up OpenVZ side === <!--T:26-->
  
 +
<!--T:27-->
 
Next you want your netconsole to send the request to somewhere. Load netconsole module, specifying the remote server parameters:
 
Next you want your netconsole to send the request to somewhere. Load netconsole module, specifying the remote server parameters:
  
# modprobe netconsole netconsole=4444@10.0.2.1/eth0,6666@10.0.2.2/00:05:5D:34:11:AF
+
<!--T:28-->
 +
<pre># modprobe netconsole netconsole=4444@10.0.2.1/eth0,6666@10.0.2.2/00:05:5D:34:11:AF</pre>
  
 +
<!--T:29-->
 
This will load the module with your settings. Replace your local IP address with where <tt>10.0.2.1</tt> is, <tt>eth0</tt> with your network interface card device, <tt>6666</tt> with the remote netconsole port (UDP), and <tt>10.0.2.2</tt> with your remote netconsole server IP. Also add in the mac address of your remote netconsole server, which in my case was 00:05:5D:34:11:AF. You can get the MAC address using arp utility:
 
This will load the module with your settings. Replace your local IP address with where <tt>10.0.2.1</tt> is, <tt>eth0</tt> with your network interface card device, <tt>6666</tt> with the remote netconsole port (UDP), and <tt>10.0.2.2</tt> with your remote netconsole server IP. Also add in the mac address of your remote netconsole server, which in my case was 00:05:5D:34:11:AF. You can get the MAC address using arp utility:
  
 +
<!--T:30-->
 
<pre>
 
<pre>
 
# ping -c 1 10.0.2.2
 
# ping -c 1 10.0.2.2
Line 99: Line 117:
 
</pre>
 
</pre>
  
 +
<!--T:31-->
 
If the remote netconsole server is outside of local network area, use mac address of default gateway or router on local network area and IP address of remote netconsole server (loging via WAN). Mac address of default gateway or router you can get the same way (ping to gateway/router and see mac address via arp command).
 
If the remote netconsole server is outside of local network area, use mac address of default gateway or router on local network area and IP address of remote netconsole server (loging via WAN). Mac address of default gateway or router you can get the same way (ping to gateway/router and see mac address via arp command).
  
 +
<!--T:32-->
 
Netconsole documentation is available from <tt>Documentation/networking/netconsole.txt</tt> file under your kernel source directory.
 
Netconsole documentation is available from <tt>Documentation/networking/netconsole.txt</tt> file under your kernel source directory.
  
=== Setting from initrd ===
+
=== Setting from initrd === <!--T:33-->
 
 
To log the boot process before root filesystem is mounted, network device driver and netconsole modules must be loaded from initd.
 
  
 +
<!--T:34-->
 +
To durable logging boot process before root filesystem mounting network device driver and netconsole module must be loaded from initd.
  
 +
<!--T:35-->
 
RedHat 5/CentOS 5:
 
RedHat 5/CentOS 5:
 
  echo 'MODULES+="<network-driver-module> netconsole "' > /etc/sysconfig/mkinitrd/netconsole
 
  echo 'MODULES+="<network-driver-module> netconsole "' > /etc/sysconfig/mkinitrd/netconsole
 
  chmod +x /etc/sysconfig/mkinitrd/netconsole
 
  chmod +x /etc/sysconfig/mkinitrd/netconsole
 
  echo 'options netconsole netconsole=<sport>@<saddr>/<dev>,<dport>@<daddr>/<dmac>' >> /etc/modprobe.conf
 
  echo 'options netconsole netconsole=<sport>@<saddr>/<dev>,<dport>@<daddr>/<dmac>' >> /etc/modprobe.conf
 
 
Debian/Ubuntu:
 
Debian/Ubuntu:
 
  echo '<network-driver-module>' >> /etc/initramfs-tools/modules
 
  echo '<network-driver-module>' >> /etc/initramfs-tools/modules
 
  echo 'netconsole netconsole=<sport>@<saddr>/<dev>,<dport>@<daddr>/<dmac>' >> /etc/initramfs-tools/modules
 
  echo 'netconsole netconsole=<sport>@<saddr>/<dev>,<dport>@<daddr>/<dmac>' >> /etc/initramfs-tools/modules
  
and rebuild initrd.
+
<!--T:36-->
 
+
and rebuild initrd
=== Setting up rsyslogd ===
 
  
 +
=== Setting up rsyslogd === <!--T:37-->
  
/etc/rsyslog.d/netconsole.conf
+
<!--T:38-->
 +
/etc/rsyslog.d/netconsole.conf
  
  $template NetconsoleFile,"/var/log/netconsole/%FROMHOST%-%$NOW%.log"
+
  <!--T:39-->
 +
$template NetconsoleFile,"/var/log/netconsole/%FROMHOST%-%$NOW%.log"
 
  $template NetconsoleFormat,"%rawmsg%"
 
  $template NetconsoleFormat,"%rawmsg%"
 
   
 
   
Line 139: Line 161:
 
  $UDPServerRun 6666
 
  $UDPServerRun 6666
  
=== Setting up remote side ===
+
=== Setting up remote side === <!--T:40-->
 
 
Set up '''netcat''' ('''nc''' on some Linux distributions) on your console server to listen on port 6666 UDP:
 
 
 
netcat -u -l -p6666
 
  
 +
<!--T:41-->
 +
Setup '''netcat''' ('''nc''' on some Linux distributions) on your console server to listen on port 6666 UDP:
 +
<pre>netcat -u -l -p6666</pre>
 
or
 
or
 
+
<pre>nc -lu 6666</pre>
nc -lu 6666
 
 
 
 
or
 
or
 
+
<pre>socat  udp-listen:6666,reuseaddr -</pre>
socat  udp-listen:6666,reuseaddr -
 
 
 
 
When your kernel prints something on the console, the text will be also captured on this netconsole server.
 
When your kernel prints something on the console, the text will be also captured on this netconsole server.
  
==== Adding to inittab ====
+
==== Adding to inittab ==== <!--T:42-->
 
For automatic care about capturing on console server you can use init respawn feature in this way:
 
For automatic care about capturing on console server you can use init respawn feature in this way:
  
echo "n1:23:respawn:/bin/netcat -u -l -p 6666 >> /var/log/netconsole" >> /etc/inittab
+
<!--T:43-->
telinit q
+
<pre>
 +
echo "n1:23:respawn:/bin/netcat -u -l -p 6666 >> /var/log/netconsole" >> /etc/inittab
 +
telinit q
 +
</pre>
  
==== Adding date/time to messages ====
+
==== Adding date/time to messages ==== <!--T:44-->
  
 +
<!--T:45-->
 
If you want the log to contain date/time of each line, you can use '''awk''' like this:
 
If you want the log to contain date/time of each line, you can use '''awk''' like this:
  
  netcat -u -l -p6666 | awk '{print strftime("%d %b %Y %H:%M:%S"), $0; fflush(stdout);}' >> /var/log/netconsole
+
  <!--T:46-->
 +
netcat -u -l -p6666 | awk '{print strftime("%d %b %Y %H:%M:%S"), $0; fflush(stdout);}' >> /var/log/netconsole
  
 +
<!--T:47-->
 
See man strftime for info about how to tailor strftime() argument to your needs.
 
See man strftime for info about how to tailor strftime() argument to your needs.
  
 +
<!--T:48-->
 
Note that if you want to add this to /etc/inittab, it should be done like this:
 
Note that if you want to add this to /etc/inittab, it should be done like this:
  
  echo "netcat -u -l -p6666 | awk '{print \
+
  <!--T:49-->
 +
echo "netcat -u -l -p6666 | awk '{print \
 
   strftime("%d %b %Y %H:%M:%S"), \$0; fflush(stdout);}' \
 
   strftime("%d %b %Y %H:%M:%S"), \$0; fflush(stdout);}' \
 
   >> /var/log/netconsole" > /usr/local/sbin/netconsole
 
   >> /var/log/netconsole" > /usr/local/sbin/netconsole
Line 178: Line 203:
 
  telinit q
 
  telinit q
  
==== Configuring logrotate ====
+
==== Configuring logrotate ==== <!--T:50-->
  
 +
<!--T:51-->
 
For long term capturing you would like to do log rotating some way. With logrotate you can do it by creating config file /etc/logrotate.d/netconsole:
 
For long term capturing you would like to do log rotating some way. With logrotate you can do it by creating config file /etc/logrotate.d/netconsole:
  
 +
<!--T:52-->
 
<pre>
 
<pre>
 
/var/log/netconsole {
 
/var/log/netconsole {
Line 200: Line 227:
 
For more details, see man logrotate.
 
For more details, see man logrotate.
  
=== Testing netconsole ===
+
=== Testing netconsole === <!--T:54-->
First, check log level of console messages on OpenVZ side by:
+
 
 +
<!--T:55-->
 +
First check log level of console messages on OpenVZ side by:
  
cat /proc/sys/kernel/printk
+
<!--T:56-->
 +
<pre>cat /proc/sys/kernel/printk</pre>
  
 +
<!--T:57-->
 
First number should be 7 for testing. You can arrange it by:
 
First number should be 7 for testing. You can arrange it by:
  
sysctl -w kernel.printk="7 4 1 7"
+
<!--T:58-->
 +
<pre>sysctl -w kernel.printk="7 4 1 7"</pre>
  
 +
<!--T:59-->
 
After testing you can restore previous setting the same way.
 
After testing you can restore previous setting the same way.
  
 +
<!--T:60-->
 
Load '''netconsole''' module (see above) and on the console server run netcat (nc) command. On OpenVZ side provoke any console message, for example connect any USB hardware or try command:
 
Load '''netconsole''' module (see above) and on the console server run netcat (nc) command. On OpenVZ side provoke any console message, for example connect any USB hardware or try command:
  
  modprobe tun
+
  <!--T:61-->
 +
modprobe tun
  
 +
<!--T:62-->
 
If you see any console message on OpenVZ side, you should see message on console server too. If not, something is wrong. When debugging a problem, do not use tcpdump on OpenVZ side — it is not able to show netconsole packets. Instead, use tcpdump on console server. Quite a common source of problems with netconsole are firewalls.
 
If you see any console message on OpenVZ side, you should see message on console server too. If not, something is wrong. When debugging a problem, do not use tcpdump on OpenVZ side — it is not able to show netconsole packets. Instead, use tcpdump on console server. Quite a common source of problems with netconsole are firewalls.
  
== See also ==
+
== See also == <!--T:63-->
 
* [[SysRq debugger]]
 
* [[SysRq debugger]]
 
* [[Kernel debug options]]
 
* [[Kernel debug options]]
  
== External links ==
+
== External links == <!--T:64-->
 
* [http://kb.odin.com/en/10044 How to configure kdump (kernel crash dump)]
 
* [http://kb.odin.com/en/10044 How to configure kdump (kernel crash dump)]
 +
</translate>
  
 
[[Category:QA]]
 
[[Category:QA]]

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: