何謂 core?
在使用半導體作爲內存的材料前,人類是利用線圈當作內存的材料(發明 者爲王安),線圈就叫作 core ,用線圈做的內存就叫作 core
memory。如今 ,半導體工業澎勃發展,已經沒有人用 core memory 了,不過,在許多情況下, 人們還是把記憶體叫作core 。
何謂 core dump?
我們在開發(或使用)一個程序時,最怕的就是程序莫明其妙地當掉。雖然系 統沒事,但我們下次仍可能遇到相同的問題。於是這時操作系統就會把程序當掉
時的內存內容dump 出來(現在通常是寫在一個叫 core 的 file 裏面),讓 我們或是 debugger 做爲參考。這個動作就叫作
core dump。
執行路由核心複製
core dump包含一份當前系統內存中信息的精確拷貝。捕捉包含在內存中信息的方法有:
1) 配置路由器在崩潰時執行Core Dump,存儲到TFTP、FTP、RCP服務器:
對TFTP協議,只需指定TFTP服務器IP,不需要任何附加的配置:
Router(config)#exception dump 192.168.1.1 ;TFTP服務器的IP地址
對FTP協議的配置:
Router(config)#exception dump 192.168.1.1 ;FTP服務器的IP地址 Router(config)#ip ftp username Kevin Router(config)#ip ftp password aloha Router(config)#ip ftp source-interface e0 Router(config)#exception protocol ftp
|
對RCP協議的配置:
Router(config)#exception protocol rcp Router(config)#exception dump 192.168.1.1 ;RCP服務器的IP地址 Router(config)#ip rcmd remote-username Kevin Router(config)#ip rcmd rcp-enable Router(config)#ip rcmd rsh-enable Router(config)#ip rcmd remote-host Kevin 192.168.1.1 kevin ;
|
2) 在系統沒有崩潰的情況下,執行Core Dump命令。
Router#write core
Core Dump僅在Cisco工程師測試和解決路由器問題時有用。
Table Of Contents
Creating Core Dumps
When a router crashes, it is sometimes useful to obtain a full copy of the memory p_w_picpath (called a core dump)
to identify the cause of the crash. Core dumps are generally very
useful to your technical support representative. Not all crash types
will produce a core dump. The different crash types are discussed in
more details in Appendix B, "Memory Maps."
Caution Use
the commands discussed in this appendix only under the direction of a
technical support representative. Creating a core dump while the router
is functioning in a network can disrupt network operation.
Basic Setup
Four basic ways exist for setting up the router to generate a core dump:
•
Using Trivial File Transfer Protocol (TFTP)
•
Using File Transfer Protocol (FTP)
•
Using remote copy protocol (rcp)
•
Using a Flash disk
Using TFTP
If TFTP is used to dump
the core file to the TFTP server, the router will dump only the first
16 MB of the core file. This is a limitation of most TFTP applications.
Therefore, if your router's main memory is more than 16 MB, do not use
TFTP.
The following is the router configuration needed for getting a core dump using TFTP:
exception dump a.b.c.d
Here, a.b.c.d is the IP address of the TFTP server.
The core dump is written to a file named hostname-core on the TFTP server, where hostname is the name of the router. You can change the name of the core file by adding the exception core-file filename configuration command.
Depending on the TFTP
server application used, it may be necessary to create on the TFTP
server the empty target file to which the router can write the core.
Also make sure that you have enough memory on your TFTP server to hold
the complete core dump.
Using FTP
To configure the router for core dump using FTP, use the following configuration commands:
ip ftp usename username
ip ftp password password
exception protocol ftp
exception dump a.b.c.d
Here, a.b.c.d is the IP address of the FTP server. If the username and password are not configured, the router will attempt anonymous FTP.
Using rcp
Remote copy protocol (rcp)
can also be used to capture a core dump. Enabling rcp on a router will
not be covered in this appendix. Refer to the Cisco IOS Software
Configuration document for configuring rcp.
After rcp is enabled on the router, the following commands must be added to capture the core dump using rcp:
exception protocol rcp
exception dump a.b.c.d
Here, a.b.c.d is the IP address of the host enabled for rcp.
Using a Flash Disk
Some router platforms
support the Flash disk as an alternative to the linear Flash memory or
PCMCIA Flash card. The large storage capacity of these Flash disks
makes them good candidates for another means of capturing core dump.
For information on the router platforms and IOS versions that support
the Flash disk, refer to the Cisco IOS Release Notes.
The following is the router configuration command needed to set up a core dump using a Flash disk:
exception flash <procmem|iomem|all> <device_name[:partition_number]> <erase | no_erase>
The show flash all command will give you a list of devices that you can use for the exception flash command.
Advanced Setup
The configuration commands in this section may be used in addition to those described in the "Basic Setup" section.
Exception Memory
During the debugging
process, you can cause the router to create a core dump and reboot when
certain memory size parameters are violated. The following exception memory commands are used to trigger a core dump:
exception memory minimum size
The previous code is used to define the minimum free memory pool size.
exception memory fragment size
The previous code is used to define the minimum size of contiguous block of memory in the free pool.
The value of size is in bytes and is checked every 60 seconds. If you enter a size that is greater than the free memory, and if the exception dump command has been configured, a core dump and router reload is generated after 60 seconds. If the exception dump command is not configured, the router reloads without generating a core dump.
Debug Sanity
In some cases, the technical support representative will request that debug sanity
be enabled when setting up the core dump. This is a hidden command in
most IOS releases, but it sometimes is necessary to debug memory
corruption. With debug sanity, every buffer that is used in the system is sanity-checked when it is allocated and when it is freed.
The debug sanity
command must be issued in privileged exec mode (enable mode) and
involves some CPU utilization. However, it will not significantly
affect the router's functionality.
Not all types of crash require debug sanity to be enabled. Use this command only when your technical support representative requires it.
To disable debug sanity, use the privileged exec command undebug sanity.
Testing the Core Dump Setup
When the router is configured for core dump, it may be useful to test whether the setup works.
The IOS provides a special command to test or trigger a core dump:
write core
Use this command in
privileged exec mode (enable mode). This command will cause a crash,
and the content of the memory will be dumped accordingly. If it no core
dump is generated, the whole setup and config must be reviewed.
Caution The
write core
command will have an impact on a production network. It will cause the
router to crash and will prevent it from coming up before dumping the
content of its memory. This might take some time, depending on the
amount of DRAM present on the router. Use the command with utmost
caution.