首页 / NGINX / 无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or
无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1753字,纯文字阅读大概需要3分钟。
内容图文
![无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or](/upload/InfoBanner/zyjiaocheng/926/02c232de1c104abf80ddb0adc2364e6b.jpg)
①故障现象
场景:
- 基于 nginx 与 consul 构建自动发现即高可用的 Docker 服务架构
- 在 consul 群集添加 compose-template 以实现容器自动加入时,无法正常启动template(指定template模板文件及生成路径)
[root@docker consul]# consul-template -consul-addr 192.168.126.16:8500 -template "/root/consul/nginx.ctmpl:/usr/local/nginx/conf/vhost/xcf.conf:/usr/local/nginx/sbin/nginx -s reload" --log-level=info
2021/03/27 14:15:37.803675 [INFO] consul-template v0.19.3 (ebf2d3d)
2021/03/27 14:15:37.803712 [INFO] (runner) creating new runner (dry: false, once: false)
2021/03/27 14:15:37.804468 [INFO] (runner) creating watcher
2021/03/27 14:15:37.804577 [ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or directory '//报错'
②解决思路
- 前面的部署过程都没有问题,再检查下配置文件是否有手误,报错提示读取模板失败,没有这个文件或目录
- template nginx 模板文件在 VIM 进去时因没有进入编辑模式“i”就直接copy,导致首部开头少了几个字母,不过修改回来后仍旧不能正常启动,pass!
- netstat 检查 nginx 已正常开启,这里我杀掉进程再次开启 nginx,仍旧不行,pass!
- 最后检查下模板文件 nginx.ctmpl,最后发现是指定绝对路径的问题,应该改为“/consul,而不是/root/consul”,唉!
[root@docker consul]# consul-template -consul-addr 192.168.126.16:8500 -template "/consul/nginx.ctmpl:/usr/local/nginx/conf/vhost/xcf.conf:/usr/local/nginx/sbin/nginx -s reload" --log-level=info
2021/03/27 14:15:50.574341 [INFO] consul-template v0.19.3 (ebf2d3d)
2021/03/27 14:15:50.574366 [INFO] (runner) creating new runner (dry: false, once: false)
2021/03/27 14:15:50.574773 [INFO] (runner) creating watcher
2021/03/27 14:15:50.574932 [INFO] (runner) starting
2021/03/27 14:15:50.574953 [INFO] (runner) initiating run
2021/03/27 14:15:50.577802 [INFO] (runner) initiating run
'竟无语凝噎'
内容总结
以上是互联网集市为您收集整理的无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or全部内容,希望文章能够帮你解决无法正常启动 template:[ERR] (cli) failed to read template: open /root/consul/nginx.ctmpl: no such file or所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。