基本上就是标题。我正在努力将我们现有的haproxy从1.5升级到最新版本。正因为如此,我正在设置一个测试用例,以确保我们的旧设置能够在其上工作。但是,当我尝试运行它时,我会得到以下错误:
[NOTICE] (28948) : haproxy version is 2.4.1-1ce7d49
[NOTICE] (28948) : path to executable is /home/user/test/usr/local/sbin/haproxy
[ALERT] (28948) : parsing [test.cfg:22]: Missing LF on last line, file might have been truncated at position 68.
[ALERT] (28948) : Error(s) found in configuration file : test.cfg
[ALERT] (28948) : Fatal errors found in configuration.
我试着查过了,但在错误上找不到任何东西。我已经检查了我的配置文件,它使用的是正确的Unix格式。此外,我的测试配置也适用于较早版本的HAProxy。
global
stats timeout 30s
user root
group root
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend http_front
bind *:9090
default_backend http_back
backend http_back
balance roundrobin
server test.server.com 127.0.0.1:8000
此外,我做了以下工作来安装haproxy:
tar xvf haproxy-2.4.1.tar.gz
cd haproxy-2.4.1
#vi to Makefile and set PREFIX to PREFIX = /home/user/test/usr/local
make TARGET=linux-glibc
make install
关于我的配置文件有什么特别之处吗?还是我在安装过程中错过了什么?
发布于 2021-07-13 16:54:49
很可能您以某种方式截断了配置文件。看上去没问题。
我没有在2.4上测试它,但是我找到了对它的引用:https://www.mail-archive.com/haproxy@formilux.org/msg37698.html,并且能够在2.2上复制它(它在2.2中发出警告,在2.3中变成错误,正如haproxy消息所描述的那样),使用这个简单的配置:
defaults
timeout connect 5000
timeout client 50000
timeout server 50000
frontend http_front
bind *:80
mode http
http-request deny
此配置是有效的:
# haproxy -c -f test.conf
Configuration file is valid
现在,我将截断它一个字节来再现它:
# wc -c test.conf
149 test.conf
# dd if=test.conf of=test2.conf bs=1 count=148
148+0 records in
148+0 records out
148 bytes copied, 0.00267937 s, 55.2 kB/s
# hexdump -C test.conf
00000000 64 65 66 61 75 6c 74 73 0a 20 20 20 74 69 6d 65 |defaults. time|
00000010 6f 75 74 20 63 6f 6e 6e 65 63 74 20 35 30 30 30 |out connect 5000|
00000020 0a 20 20 20 74 69 6d 65 6f 75 74 20 63 6c 69 65 |. timeout clie|
00000030 6e 74 20 35 30 30 30 30 0a 20 20 20 74 69 6d 65 |nt 50000. time|
00000040 6f 75 74 20 73 65 72 76 65 72 20 35 30 30 30 30 |out server 50000|
00000050 0a 0a 66 72 6f 6e 74 65 6e 64 20 68 74 74 70 5f |..frontend http_|
00000060 66 72 6f 6e 74 0a 20 20 20 62 69 6e 64 20 2a 3a |front. bind *:|
00000070 38 30 0a 20 20 20 6d 6f 64 65 20 68 74 74 70 0a |80. mode http.|
00000080 20 20 20 68 74 74 70 2d 72 65 71 75 65 73 74 20 | http-request |
00000090 64 65 6e 79 0a |deny.|
00000095
# hexdump -C test2.conf
00000000 64 65 66 61 75 6c 74 73 0a 20 20 20 74 69 6d 65 |defaults. time|
00000010 6f 75 74 20 63 6f 6e 6e 65 63 74 20 35 30 30 30 |out connect 5000|
00000020 0a 20 20 20 74 69 6d 65 6f 75 74 20 63 6c 69 65 |. timeout clie|
00000030 6e 74 20 35 30 30 30 30 0a 20 20 20 74 69 6d 65 |nt 50000. time|
00000040 6f 75 74 20 73 65 72 76 65 72 20 35 30 30 30 30 |out server 50000|
00000050 0a 0a 66 72 6f 6e 74 65 6e 64 20 68 74 74 70 5f |..frontend http_|
00000060 66 72 6f 6e 74 0a 20 20 20 62 69 6e 64 20 2a 3a |front. bind *:|
00000070 38 30 0a 20 20 20 6d 6f 64 65 20 68 74 74 70 0a |80. mode http.|
00000080 20 20 20 68 74 74 70 2d 72 65 71 75 65 73 74 20 | http-request |
00000090 64 65 6e 79 |deny|
00000094
# haproxy -c -f test2.conf
[WARNING] 193/184514 (10725) : parsing [test2.conf:9]: Missing LF on last line, file might have been truncated at position 21. This will become a hard error in HAProxy 2.3.
Warnings were found.
Configuration file is valid
请注意结尾处缺少的0a
。使用hexdump -C
检查配置
发布于 2021-11-14 05:38:58
我也有同样的问题,我试着用编辑器。但是,这不管用。我可以通过增加一个新的行来解决这个问题。我使用了回声命令,它起作用了。
echo "" >> /etc/hapee-2.2/hapee-lb.cfg
发布于 2022-09-19 16:45:42
在部署Bitnami HAproxy时,我使用Rancher也遇到了同样的问题。我很快发现构造函数是加载项- 块状咬合指示器,删除末尾的'0a‘。我必须以yaml格式编辑文件,以确保删除此指示符。
示例:
config: |-
defalts
timeout.....
https://stackoverflow.com/questions/68350378
复制相似问题