网络运维分享

网络设备自动备份

2019-10-21  本文已影响0人  飛_c98d

参考链接:https://github.com/ytti/oxidized

测试环境:CentOS Linux release 7.3.1611 (Core)

主要组件:oxidized oxidized-script oxidized-web

注意:oxidized-web需要ruby2.3以上支持,如不安装oxidized-web,配置文件里rest 修改为false

1、安装依赖组件

yum 源修改:本测试环境为办公网测试机,需要修改yum源,通常建议修改为公司线上或测试环境yum源(可找业务运维帮忙倒出上传到/etc/yum.repos.d)

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

2、安装ruby

centos7默认ruby为2.0版本,需要单独安装。

yum install centos-release-scl

yum-config-manager --enable rhel-server-rhscl-7-rpms

yum install -y rh-ruby25-ruby-devel

yum install rh-ruby25

scl enable rh-ruby25 bash

ruby -v

ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

cp /opt/rh/rh-ruby25/root/usr/lib64/libruby.so.2.5 /usr/lib/

设置登录时自动启动ruby2.5:

vim /etc/profile.d/rh-ruby25.sh

#!/bin/bash

source /opt/rh/rh-ruby25/enable

export X_SCLS="scl enable rh-ruby25 'echo $X_SCLS'"

export PATH=$PATH:/opt/rh/rh-ruby25/root/usr/local/bin

3、安装oxidized

gem install oxidized

gem install oxidized-script oxidized-web

useradd -m -d /home/oxidized oxidized

cp /opt/rh/rh-ruby25/root/usr/local/share/gems/gems/oxidized-0.24.0/extra/oxidized.service /lib/systemd/system

mkdir -p /home/oxidized/.config/oxidized

mkdir /home/oxidized/.config/oxidized/logs/

mkdir /home/oxidized/.config/oxidized/configs

chown oxidized:oxidized /home/oxidized/.config/oxidized

config 文件

username: username

password: password

model: junos

interval: 3600

log: /home/oxidized/.config/oxidized/logs/oxidized.log

debug: false

threads: 30

timeout: 20

retries: 3

prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/

rest: 127.0.0.1:8888

next_adds_job: false

vars: {}

groups: {}

models: {}

pid: "/home/oxidized/.config/oxidized/pid"

input:

default: ssh, telnet

debug: false

ssh:

secure: false

output:

default: file

file:

directory: "/home/oxidized/.config/oxidized/configs"

source:

default: csv

csv:

file: "/home/oxidized/.config/oxidized/router.db"

delimiter: !ruby/regexp /:/

map:

name: 0

model: 1

username: 2

password: 3

gpg: false

model_map:

cisco: ios

juniper: junos

router.db 文件

vim home/oxidized/.config/oxidized/router.db

172.18.31.11:comware:user:passwd

启动服务

systemctl restart oxidized.service

systemctl status oxidized.service

至此,自动备份基础功能已完成,可在目录里查看备份的配置文件,接下来配置可用web页面查看比较直观。

4、安装nginx

yum install nginx

vim /etc/nginx/conf.d/oxidized.conf

cat /etc/nginx/conf.d/oxidized.conf

server {

listen 80;

server_name 172.18.34.45;

location / {

proxy_pass http://127.0.0.1:8888/;

}

access_log /var/log/nginx/access_oxidized.log;

error_log /var/log/nginx/error_oxidized.log;

}

systemctl restart nginx.service

浏览器打开:http://172.18.34.45/nodes

Actions 下有3个图标,第一个点开可看到配置文件。

第二个versions可查看每个版本的配置差异。(需要git支持,安装步骤见下文)

第三个为强制备份。

默认显示时间不对,需要修改以下配置文件。

vim /opt/rh/rh-ruby25/root/usr/local/share/gems/gems/oxidized-web-0.11.1/lib/oxidized/web/public/scripts/oxidized.js

5、git 安装

yum -y install git

yum install libgit2

git config user.name Oxidized

git config user.email “o@example.com”

修改配置文件为git输出

systemctl restart oxidized.service

systemctl status oxidized.service

通过区域按钮可查看每个版本配置差异。

上一篇下一篇

猜你喜欢

热点阅读