使用Docker Compose快速部署

采用Docker Compose做编排,用于单机快速启动环境做测试,包含了MySQL、Redis、Prometheus、Ibex、Nightingale、Telegraf

Github下载夜莺的源码,进入docker目录,执行docker-compose up -d即可,docker-compose会自动拉取镜像并启动,查看各个容器启动状态,使用命令docker-compose ps,都是Up状态则表示启动成功,如果ibex、nserver、nwebapi等模块一直在Restarting,可能是数据库容器启动太慢了没有准备好,可以执行docker-compose down停掉再重新尝试启动测试:

  1. ulric@mac.home:~/workspace/gopath/src/n9e/docker$ docker-compose up -d
  2. Creating network "docker_nightingale" with driver "bridge"
  3. Creating mysql ... done
  4. Creating redis ... done
  5. Creating prometheus ... done
  6. Creating ibex ... done
  7. Creating agentd ... done
  8. Creating nwebapi ... done
  9. Creating nserver ... done
  10. Creating telegraf ... done
  11. ulric@mac.home:~/workspace/gopath/src/n9e/docker$ docker-compose ps
  12. Name Command State Ports
  13. ----------------------------------------------------------------------------------------------------------------------------
  14. agentd /app/ibex agentd Up 10090/tcp, 20090/tcp
  15. ibex /app/ibex server Up 0.0.0.0:10090->10090/tcp, 0.0.0.0:20090->20090/tcp
  16. mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
  17. nserver /app/n9e server Up 18000/tcp, 0.0.0.0:19000->19000/tcp
  18. nwebapi /app/n9e webapi Up 0.0.0.0:18000->18000/tcp, 19000/tcp
  19. prometheus /bin/prometheus --config.f ... Up 0.0.0.0:9090->9090/tcp
  20. redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
  21. telegraf /entrypoint.sh telegraf Up 0.0.0.0:8092->8092/udp, 0.0.0.0:8094->8094/tcp, 0.0.0.0:8125->8125/udp

更多docker-compose相关知识请参考官网

Warning

启动成功之后,建议把initsql目录下的内容挪走,这样下次重启的时候,DB就不会重新初始化了。否则下次启动mysql还是会自动执行initsql下面的sql文件导致DB重新初始化,页面上创建的规则、用户等都会丢失

服务启动之后,浏览器访问nwebapi的端口,即18000,默认用户是root,密码是root.2020