华为交换机配置导入和导出
华为交换机配置导入和导出
一、场景介绍
网络设备提供服务是根据加载配置文件而提供的,所以对设备的配置文件备份和恢复很重要,在设备正常运行的情况下要对配置文件进行备份,同样在设备出现配置问题的时候就需要恢复正常运行的配置文件。
配置文件的导入和导出方式:
1、配置文件的备份和恢复可以在设备上启用ftp服务,将配置文件导出到本地pc,需要的时候可以将此备份文件通过ftp服务再导入到设备的flash目录中,以便重启设备后恢复正常状态。
2、也可以通过其他的ftp服务器来备份和恢复设备的配置文件,通过ftp命令连接远程的ftp服务器来下载或上传配置文件。
二、实践操作
1、开启网络设备的ftp服务
`#开启ftp服务``[``4F``-``NEWORKD``-``SOUTH01]ftp server enable``#创建ftp用户,指定ftp的目录为flash:``[``4F``-``NEWORKD``-``SOUTH01``-``aaa]local``-``user goser password cipher ``123456``[``4F``-``NEWORKD``-``SOUTH01``-``aaa]local``-``user goser service``-``type` `ftp``[``4F``-``NEWORKD``-``SOUTH01``-``aaa]local``-``user goser privilege level ``3``[``4F``-``NEWORKD``-``SOUTH01``-``aaa]local``-``user goser ftp``-``directory flash:``#保存配置``<``4F``-``NEWORKD``-``SOUTH01>save`
2、通过ftp 查看交换机设备中的文件
C:\Documents and Settings\goser>ftp 192.168.10.18
Connected to 192.168.10.18.
220 FTP service ready.
User (192.168.10.18:(none)): goser
331 Password required for goser.
Password:
230 User logged in.
ftp> dir
200 Port command okay.
150 Opening ASCII mode data connection for directory list.
-rwxrwxrwx 1 noone nogroup 23240540 Aug 24 2015 s5700s-li-v200r007c00spc5
00.cc
-rwxrwxrwx 1 noone nogroup 231021 Aug 24 2015 s5700s-li-v200r007sph001.
pat
-rwxrwxrwx 1 noone nogroup 836 Apr 17 06:18 rr.dat
drwxrwxrwx 1 noone nogroup 0 Jan 29 2016 user
-rwxrwxrwx 1 noone nogroup 986 Apr 17 06:18 private-data.txt
-rwxrwxrwx 1 noone nogroup 836 Apr 17 06:18 rr.bak
drwxrwxrwx 1 noone nogroup 0 May 31 11:44 localuser
drwxrwxrwx 1 noone nogroup 0 Jan 29 2016 dhcp
drwxrwxrwx 1 noone nogroup 0 May 10 06:17 logfile
-rwxrwxrwx 1 noone nogroup 1360236 Apr 17 06:18 help.web
-rwxrwxrwx 1 noone nogroup 36 Jan 29 2016 $_patchstate_reboot
-rwxrwxrwx 1 noone nogroup 3684 Jan 29 2016 $_patch_history
-rwxrwxrwx 1 noone nogroup 4 Aug 03 2016 snmpnotilog.txt
drwxrwxrwx 1 noone nogroup 0 May 31 00:00 resetinfo
-rwxrwxrwx 1 noone nogroup 3141 May 31 11:35 backup.cfg
-rwxrwxrwx 1 noone nogroup 968 May 31 11:44 vrpcfg.zip
3、导出配置到PC本地
#将设备的配置文件vrpcfg.zip下载到本地指定的目录中,这里切换下载目录为e盘,可以将配置文件下载后重命名
ftp> lcd e:\
ftp> get vrpcfg.zip config.zip
4、导入本地备份配置文件到网络设备
#切换到备份的配置文件目录
ftp> lcd e:\
Local directory now E
#上传配置文件到设备中
ftp> put config.zip
设置恢复的配置文件为下次启动配置文件并重启设备,这里在重启设备的时候注意提示:将修改的配置写入下次启动的配置文件中,一定要输入N,不然下次重启导入的配置文件不生效
<4F-NEWORKD-SOUTH01>startup saved-configuration config.zip
<4F-NEWORKD-SOUTH01>dis startup
MainBoard:
Configured startup system software: flash:/s5700s-li-v200r007c00spc500.cc
Startup system software: flash:/s5700s-li-v200r007c00spc500.cc
Next startup system software: flash:/s5700s-li-v200r007c00spc500.cc
Startup saved-configuration file: flash:/vrpcfg.zip
Next startup saved-configuration file: flash:/config.zip
<4F-NEWORKD-SOUTH01> reboot //重启设备。
Info: The system is now comparing the configuration, please wait.
Warning: The configuration has been modified, and it will be saved to the next startup saved-configuration file cfcard:/config.cfg. Continue? [Y/N]:N //注意:这里要选择N
//输入N防止设备当前的配置保存到备份的配置文件中。
Now saving the current configuration to the slot 13.
Save the configuration successfully.
Info: If want to reboot with saving diagnostic information, input 'N' and then execute 'reboot save diagnostic-information'.
System will reboot! Continue?[Y/N]:Y //输入Y重启设备。