场景:
在实现postgreql数据迁移到clickhouse中,想使用MaterializedPostgreSQL的功能实现,但是中途clickhouse突然挂了,就再启动不了了。
现象:
systemctl start clcikhouse-server启动报错
[root@localhost clickhouse-server]# systemctl status clickhouse-server
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since 二 2024-03-19 10:46:43 CST; 5s ago
Process: 22672 ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid (code=exited, status=232/ADDRESS_FAMILIES)
Main PID: 22672 (code=exited, status=232/ADDRESS_FAMILIES)
启动日志分析
journalctl -xe
[root@localhost clickhouse-server]# journalctl -xe
3月 19 10:47:13 localhost.localdomain clickhouse-server[22714]: Processing configuration file '/etc/clickhouse-server/config.xml'.
3月 19 10:47:13 localhost.localdomain clickhouse-server[22714]: Logging trace to /var/log/clickhouse-server/clickhouse-server.log
3月 19 10:47:13 localhost.localdomain clickhouse-server[22714]: Poco::Exception. Code: 1000, e.code() = 13, Access to file denied: /var/log/clickhouse-server/clickhouse-server.log, Stack trace (when co
3月 19 10:47:13 localhost.localdomain clickhouse-server[22714]: 0.
Access to file denied:/var/log/clickhouse-server/clickhouse-server.log
关键报错提示访问这个日志文件被拒绝了。
原因
原因是项目挂了后,我把var/log/clickhouse-server下的日志全部删除了,然后手动创建的如下文件
/var/log/clickhouse-server/clickhouse-server.log
var/log/clickhouse-server/clickhouse-server.err.log
复盘
我当时是这么赋予权属的
chown root:root /var/log/clickhouse-server/clickhouse-server.log
chown root:root var/log/clickhouse-server/clickhouse-server.err.log
错就错在这里了!!!
配置文件clickhouse.xml的权属都是clickhouse,且在config.xml中有日志的具体配置路径
然后改成
chown clickhouse:clickhouse var/log/clickhouse-server/clickhouse-server.err.log
chown clickhouse:clickhouse var/log/clickhouse-server/clickhouse-server.log
重启服务OK了
systemctl start clickhouse-server
systemctl status clickhouse-server