oxidized配置(docker版)

oxidized Docker部署与配置指南
本文介绍了如何在Debian系统上使用Docker部署oxidized,详细阐述了安装Docker的过程,以及氧化铁镜像的下载、启动和配置。特别强调了router.db文件在设备配置备份中的作用,以及修改config配置文件以暴露web界面的步骤。

         oxidized 是一个网络设备备份系统, 轻量级,可扩展,支持超过90多个操作系统。同时支持h3c,华为,思科,容器化版本部署比较简单,主要步骤如下:

系统:debian

首先安装Docker:

官方Debian存储库中提供的Docker安装包可能不是最新版本。为了确保我们获得最新版本,我们将从官方Docker存储库安装Docker。为此,我们将添加一个新的包源,从Docker添加GPG密钥以确保下载有效,然后安装该包。

首先,更新现有的包列表:

apt update

接下来,安装一些允许apt使用包通过HTTPS的必备软件包:

apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

然后将官方Docker存储库的GPG密钥添加到您的系统:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

将Docker存储库添加到APT源:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable

使用新添加的repo中的Docker包更新包数据库:

apt update

确保Docker repo而不是默认的Debian repo安装:

apt-cache policy docker-ce

最后,安装Docker:

apt install docker-ce

检查它是否正在运行:

systemctl status docker

安装oxidize镜像:

把官方的 oxidized/oxidized 镜像拉下来:

docker pull oxidized/oxidized:latest

下载完启动镜像:

docker run  --name='oxidized' -itd -v /data/oxidized:/root/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized

创建mkdir /etc/oxidized文件

说明一下:挂载本地/data/oxidized目录到容器内的/root/.config/oxidized目录下,将本地8888端口映射到容器的tcp8888端口。

检查是否启动完毕:

[root@node1 data]# docker logs oxidized 
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Jul 11 15:03:44 4bbb01b608e3 syslog-ng[13]: syslog-ng starting up; version='3.13.2'
*** Booting runit daemon...
*** Runit started as PID 21
Jul 11 15:03:45 4bbb01b608e3 cron[29]: (CRON) INFO (pidfile fd = 3)
Jul 11 15:03:45 4bbb01b608e3 cron[29]: (CRON) INFO (Running @reboot jobs)
edit ~/.config/oxidized/config
I, [2019-07-11T15:03:47.866728 #34]  INFO -- : Oxidized starting, running as pid 34
F, [2019-07-11T15:03:47.869750 #34] FATAL -- : Oxidized crashed, crashfile written in /root/.config/oxidized/crash
no source csv config, edit ~/.config/oxidized/config
I, [2019-07-11T15:03:49.179948 #36]  INFO -- : Oxidized starting, running as pid 36
I, [2019-07-11T15:03:49.180885 #36]  INFO -- : lib/oxidized/nodes.rb: Loading nodes
F, [2019-07-11T15:03:49.181047 #36] FATAL -- : Oxidized crashed, crashfile written in /root/.config/oxidized/crash
No such file or directory @ rb_sysopen - /root/.config/oxidized/router.db

 从以上日志看到缺失router.db这个文件,导致启动失败。解决方法在/data/oxidized目录下新建router.db文件,并在router.db随意添加一条记录。后重新启动容器

[root@node1 oxidized]# touch router.db<br>[root@node1 oxidized]# cat router.db <br>192.168.1.1:vrp:admin:admin
[root@node1 oxidized]# docker restart oxidized
oxidized

修改配置文件:

router.db是记录设备备份配置的本地信息文件

x.x.x.x:device type:username:password
10.10.24.241:ios:admin:password
10.10.28.235:comware:admin:password
10.10.0.107:vrp:admin:password

config配置文件(etc/oxidized/config):

---
username: username : 用户名 这个参数不用改,会从router.db读取.
password: password : 密码 这个参数也不用改,会从router.db读取.
model: junos    : 模型 这个参数也不用改,会从router.db读取.
interval: 3600    : 备份周期 单位是秒,也就是默认一个小时备份一次
log: /home/oxidized/.config/oxidized/logs/oxidized.log:日志
debug: false    :debug模式 
threads: 30    :线程
timeout: 20    : 超时
retries: 3    : 重试次数
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 127.0.0.1:8888    :web 用到
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:    这个地方和router.db里面的参数对应 从0开始
      name: 0
      model: 1
      username: 2
      password: 3
    gpg: false
model_map:
  cisco: ios
  juniper: junos

复制代码

把rest:127.0.0.1:888修改成0.0.0.0:8888。重启容器,就可以访问web页面了。

给定的参考引用中未提及oxidized dock配置反向代理的方法。一般而言,要为Oxidized Docker配置反向代理,以使用Nginx为例,可以按以下步骤操作: ### 1. 确保Nginx已安装 首先要保证Nginx在服务器上已经安装好。如果未安装,可通过包管理器进行安装,例如在Ubuntu系统上: ```bash sudo apt update sudo apt install nginx ``` ### 2. 创建Nginx配置文件 在`/etc/nginx/sites-available`目录下创建一个新的配置文件,例如`oxidized.conf`: ```bash sudo nano /etc/nginx/sites-available/oxidized.conf ``` ### 3. 编辑配置文件 在配置文件中添加如下内容: ```nginx server { listen 80; server_name your_domain_or_ip; location / { proxy_pass http://localhost:your_oxidized_port; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` 其中,`your_domain_or_ip`需替换为实际的域名或者服务器IP地址,`your_oxidized_port`要替换为Oxidized Docker容器实际监听的端口。 ### 4. 启用配置文件 创建从`sites-available`到`sites-enabled`目录的符号链接: ```bash sudo ln -s /etc/nginx/sites-available/oxidized.conf /etc/nginx/sites-enabled/ ``` ### 5. 检查配置并重启Nginx 检查Nginx配置文件是否存在语法错误: ```bash sudo nginx -t ``` 若没有错误,重启Nginx服务: ```bash sudo systemctl restart nginx ``` ### 6. 配置SSL(可选) 若要使用HTTPS,可使用Let's Encrypt为网站配置SSL证书: ```bash sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d your_domain_or_ip ``` ### 7. 测试反向代理 在浏览器中访问配置的域名或者IP地址,确认是否能正常访问Oxidized服务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值