使用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
停掉再重新尝试启动测试:
ulric@mac.home:~/workspace/gopath/src/n9e/docker$ docker-compose up -d
Creating network "docker_nightingale" with driver "bridge"
Creating mysql ... done
Creating redis ... done
Creating prometheus ... done
Creating ibex ... done
Creating agentd ... done
Creating nwebapi ... done
Creating nserver ... done
Creating telegraf ... done
ulric@mac.home:~/workspace/gopath/src/n9e/docker$ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------
agentd /app/ibex agentd Up 10090/tcp, 20090/tcp
ibex /app/ibex server Up 0.0.0.0:10090->10090/tcp, 0.0.0.0:20090->20090/tcp
mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp
nserver /app/n9e server Up 18000/tcp, 0.0.0.0:19000->19000/tcp
nwebapi /app/n9e webapi Up 0.0.0.0:18000->18000/tcp, 19000/tcp
prometheus /bin/prometheus --config.f ... Up 0.0.0.0:9090->9090/tcp
redis docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp
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