Juniper SRX CLI命令範例 回滾配置(rollback)與補救配置(rescue configuration)



Juniper SRX CLI命令範例 回滾配置(rollback)與補救配置(rescue configuration)



每當您將候選配置作為新的當前配置提交時,JUNOS 軟體就會自動保存被替換的使用中的檔案的副本。您每存儲一個新替換的配置,在配置存檔中所有先前的設定檔的版本號都會依次後推。每個設備最多可保存 49 個最新的活動版本,以及當前配置(也稱為 rollback 0
預設為5,您可以在設定檔中改變其數字,您可以從WebUI去設定:
Configure > CLI Tools > CLI Editor
    max-configurations-on-flash 5;          ##設定檔儲存在srx設備上的最大容許數
    max-configuration-rollbacks 5;          ##設定檔允許執行回滾配置的最大容許數
或是從CLI命令列去設定:
root@srx100# set system max-configurations-on-flash 15
root@srx100# set system max-configuration-rollbacks 15
root@srx100#

當前(運行中)配置是設備的工作檔。 檔案位置 /config/juniper.conf.gz
候選配置是存儲配置更新的工作副本。 檔案位置 /config/juniper.conf+.gz
Rollback 1rollback 3 檔案位置 /config/juniper.conf.1.gz through juniper.conf.3.gz
Rollback 4rollback 49 檔案位置 /var/db/config/juniper.conf.4.gz through juniper.conf.49.gz
補救設定檔檔案位置/config/rescue.conf.gz

您可以使用 rollback 命令訪問此配置存檔,包括要回退的版本數。
使用 rollback 1 命令可恢復到最新的前一個設定檔:
root@srx100# rollback 1
load complete
rollback 命令可將請求的存檔作為候選檔載入。如果要立即使用它,先用 show 命令確認它是您需要的檔,然後用 commit 命令啟動它:
root@srx100# show
<. . .>
[edit]
root@srx100# commit          ##提交候選配置,讓更新的設定變成運行中配置
commit complete
這種自動備份機制使您可以迅速回退到先前的配置以便立即使用或快速更新。

如果您不能確定當前(正在運行的)配置與回滾檔之間的差異,請用 show | compare 命令調查:
[edit interfaces]
root@srx100# show | compare rollback 2
[edit interfaces]
- fe-3/0/1 {
-     vlan-tagging;
-     unit 240 {
-         vlan-id 240;
-         family inet {
-             address 10.14.250.1/28;
-             address 10.14.250.17/28 {
-                 preferred;
-             }
-             address 10.14.250.33/28;
-             address 10.14.250.49/28;
-             address 10.14.250.65/28;
-         }
-     }
- }
   
提示 使用問號加 rollback 命令可列出全部存檔:
[edit]
root@srx100# rollback ?
Possible completions:
<[Enter]> Execute this command
0 2009-01-31 04:34:56 UTC by mike via cli
1 2009-01-31 04:30:03 UTC by mike via cli
2 2009-01-30 06:23:44 UTC by mike via cli
<. . .>
48 2008-11-03 08:00:03 UTC by mike via cli
49 2008-11-03 07:45:21 UTC by mike via cli
| Pipe through a command

提示 要將候選配置重置為當前(運行中)配置,使用 rollback(或 rollback 0)命令

回滾配置設定範例:
root@srx100# show system max-configurations-on-flash          ##查看回滾配置訊息
max-configurations-on-flash 5;
root@srx100# show system max-configuration-rollbacks
max-configuration-rollbacks 5;
root@srx100# set system max-configurations-on-flash 15         ##設定回滾配置參數
root@srx100# set system max-configuration-rollbacks 15
root@srx100# show | compare rollback 0         ##比較當前配置與候選配置的差異
[edit system]
-  max-configurations-on-flash 5;
+  max-configurations-on-flash 15;       ##更改設定檔儲存在srx設備上的最大容許數為15
-  max-configuration-rollbacks 5;
+  max-configuration-rollbacks 15;       ##更改設定檔允許執行回滾配置的最大容許數為15
命令列介面以加 (+) 號表示候選配置中新增的語句,以減 (-) 號表示刪除的語句。

root@srx100# commit      ##提交候選配置
commit complete
root@srx100# show system max-configurations-on-flash     ##查看更改後回滾配置訊息
max-configurations-on-flash 15;
root@srx100# show system max-configuration-rollbacks
max-configuration-rollbacks 15;
root@srx100# show | compare rollback 0     ##比較當前配置與rollback 0的差異
                 ##空白表示沒有差異,沒有更改時當前配置與候選配置相同
root@srx100# show | compare rollback 1     ##比較當前配置與rollback 1的差異
[edit system]
-  max-configurations-on-flash 5;
+  max-configurations-on-flash 15;    ## 原來的rollback 0變成了rollback 1
-  max-configuration-rollbacks 5;
+  max-configuration-rollbacks 15;
root@srx100# rollback 1       ##執行rollback 1命令
load complete
root@srx100# show | compare rollback 0             ##比較當前配置與候選配置的差異
[edit system]
-  max-configurations-on-flash 15;
+  max-configurations-on-flash 5;
-  max-configuration-rollbacks 15;
+  max-configuration-rollbacks 5;
root@srx100# commit     ##提交候選配置
commit complete
root@srx100# show system max-configurations-on-flash
max-configurations-on-flash 5;
root@srx100# show system max-configuration-rollbacks
max-configuration-rollbacks 5;
root@srx100#





Juniper SRX補救設定檔rescue configuration

To save the most recently committed configuration as the rescue configuration so that you can return to it at any time, issue the request system configuration rescue save command:
要將最近提交的配置保存為救援配置, 以便您可以隨時拯救返回, 請發出request system configuration rescue save命令:
user@host> request system configuration rescue save
To return to the rescue configuration, use the rollback rescue configuration mode command:
[edit]
user@host# rollback rescue
load complete

 Note: If the rescue configuration does not exist, or if the rescue configuration is not a complete, viable configuration, then the rollback command fails, an error message appears, and the current configuration remains active. 注意: 如果救援配置不存在, 或者救援配置不是完整的、可行的配置, 則回滾命令將失敗, 出現錯誤訊息, 當前配置仍處於活動狀態。

To activate the rescue configuration that you have loaded, use the commit command:
要啟動已載入的救援配置, 請使用 "提交commit " 命令:
[edit]
user@host# rollback rescue
load complete
[edit]
user@host# commit
To delete an existing rescue configuration, issue the request system configuration rescue delete command:
要刪除現有的救援配置, 請發出request system configuration rescue delete命令:
user@host> request system configuration rescue delete
user@host>

Copy the rescue configuration to a remote server:
user@host1% cd /config/
user@host1% ls -lrt rescue.conf.gz

user@host1%ftp host2
Name: username
Password: password
User user logged in.
ftp> cd /var/tmp
ftp> lcd /config
ftp> bin
ftp> put rescue.conf.gz
local: rescue.conf.gz remote: rescue.conf.gz

Transfer complete.
ftp> bye
Goodbye.


如果運行中的配置(/config/Juniper.conf.gz)被破壞,則設備會自動將名為 /config/rescue.conf.gz 的檔作為活動配置載入到/config 目錄中。

在將該設定檔複製到新的位置後,務必重命名該檔,以免稍後複制該檔的更新版本時不經意將其覆蓋。
通過下列命令,您還可以將設定檔移回到設備的主目錄下:
user@SRX > file copy /config/Juniper.conf.gz /var/home/user/Juniper.conf.gz-20180123


這個網誌中的熱門文章

如何測試網路連線--網路斷線了怎麼辦?

筆記電腦刷BIOS失敗無法開機—用CH341A編程器重刷BIOS教學!

INTEL XTU使用教學以及對筆電應具備的XTU設定概念