企业级网络设备自动备份系统 -- Oxidize

1. 卸载原来的Ruby

yum remove ruby ruby-devel

 

2. 安装依赖包

yum install make cmake which sqlite-devel openssl-devel libssh2-devel gcc libicu-devel gcc-c++ -y

 

3. 用winscp提前上传下载好的Ruby,并解压

tar -zxvf ruby-3.1.0.tar.gz

 

4. 进入ruby目录编译安装。

cd ruby-3.1.0
./configure
make
make install
which ruby    
 ruby -v
 yum install rubygems -y
 gem -v

 

5. 添加源

gem sources -l
gem sources -a http://rubygems.org/

企业级网络设备自动备份系统 -- Oxidize_第1张图片

找到.gemrc文件 

find /* -name '*gemrc*'  

添加源

vi /root/.config/gem/gemrc

gem sources

6. 升级cmake版本

同步时间
date -s  "2024-01-25 17:28:30"
#移除老版本
yum remove cmake -y
#下载依赖包
yum install -y gcc gcc-c++ make automake openssl openssl-devel
#下载安装包并解压
wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz ; tar -zxf cmake*.tar.gz
#编译安装
cd cmake* ; ./bootstrap ; gmake -j `grep 'processor' /proc/cpuinfo | wc -l` ; gmake install
#创建链接
ln -s /usr/local/bin/cmake /usr/bin/
#查看版本
cmake --version

 

7. 安装oxidized

gem install oxidized

8. 安装web端(这里等的比较久,可以打三把王者)

gem install  oxidized-script oxidized-web

9. 创建备份文件目录

mkdir /root/.config/oxidized/configs

10. 修改配置文件

---
username: username
password: password
model: junos
resolve_dns: true
interval: 3600
use_syslog: false
debug: false
threads: 30
use_max_threads: false
timeout: 20
retries: 3
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 192.168.70.225:8888
next_adds_job: false
vars: {}
groups: {}
group_map: {}
models: {}
pid: "/root/.config/oxidized/pid"
crash:
  directory: "/root/.config/oxidized/crashes"
  hostnames: false
stats:
  history_size: 10
input:
  default: ssh, telnet
  debug: false
  ssh:
    secure: false
  ftp:
    passive: true
  utf8_encoded: true
output:
  default: file
  file:
    directory: "/root/.config/oxidized/configs"
source:
  default: csv
  csv:
    file: "/root/.config/oxidized/router.db"
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      model: 1
      username: 2
      password: 3
      group: 4
    gpg: false
model_map:
  juniper: junos
  cisco: ios

11. 创建 router.db 文件,并配置备份主机

[root@localhost oxidized]# cat router.db
192.168.20.9:vrp:admin:S********$

11. 把启动用户改成root,并设置开启自启动

find / -name oxidized.service
cp /usr/local/lib/ruby/gems/3.1.0/gems/oxidized-0.29.1/extra/oxidized.service /etc/systemd/system
vi /etc/systemd/system/oxidized.service 
####
# Put this file in /etc/systemd/system.
#
# To set OXIDIZED_HOME instead of the default,
# ~oxidized/.config/oxidized, uncomment (and modify as required) the
# "Environment" variable below so systemd sets the correct
# environment.

[Unit]
Description=Oxidized - Network Device Configuration Backup Tool
After=network-online.target multi-user.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/oxidized
User=root
KillSignal=SIGKILL
#Environment="OXIDIZED_HOME=/etc/oxidized"
Restart=on-failure
RestartSec=300s

[Install]
WantedBy=multi-user.target
####

systemctl daemon-reload
systemctl enable oxidized 

12. 启动oxidized

企业级网络设备自动备份系统 -- Oxidize_第2张图片

13. 打开网页http//192.168.70.225:8888

企业级网络设备自动备份系统 -- Oxidize_第3张图片

14. 查看配置文件备份

你可能感兴趣的:(linux,运维,服务器)