ClickHouse 重启时一直提示Waiting for server to start, 无法启动生成。

修改clickhouse配置重启时,一直重启不成功。

1
2
3
4
$ sudo /etc/init.d/clickhouse-server restart
Waiting for server to start
Cannot start server. You can execute sudo -u 'clickhouse' /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon without --daemon option to run manually.
Look for logs at /var/log/clickhouse-server/ and for /var/log/clickhouse-server/stderr.log.

查看启动失败日志:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ sudo -u clickhouse /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml
Processing configuration file '/etc/clickhouse-server/config.xml'.
std::exception. Code: 1001, type: std::__1::__fs::filesystem::filesystem_error, e.what() = filesystem error: in posix_stat: failed to determine attributes for the specified path: Permission denied ["/etc/clickhouse-server/config.xml"], Stack trace (when copying this message, always include the lines below):

1. std::__1::system_error::system_error(std::__1::error_code, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) @ 0x1a352f32 in /usr/bin/clickhouse
2. ? @ 0xddf0c63 in /usr/bin/clickhouse
3. ? @ 0x1a2f7e1a in /usr/bin/clickhouse
4. ? @ 0x1a302ad2 in /usr/bin/clickhouse
5. ? @ 0x1a3028d4 in /usr/bin/clickhouse
6. std::__1::__fs::filesystem::__status(std::__1::__fs::filesystem::path const&, std::__1::error_code*) @ 0x1a2ff129 in /usr/bin/clickhouse
7. DB::ConfigProcessor::processConfig(bool*, zkutil::ZooKeeperNodeCache*, std::__1::shared_ptr<Poco::Event> const&) @ 0x14c2157b in /usr/bin/clickhouse
8. DB::ConfigProcessor::loadConfig(bool) @ 0x14c24874 in /usr/bin/clickhouse
9. BaseDaemon::reloadConfiguration() @ 0xdfff54f in /usr/bin/clickhouse
10. BaseDaemon::initialize(Poco::Util::Application&) @ 0xe000c01 in /usr/bin/clickhouse
11. DB::Server::initialize(Poco::Util::Application&) @ 0xde33303 in /usr/bin/clickhouse
12. Poco::Util::Application::run() @ 0x17554a17 in /usr/bin/clickhouse
13. DB::Server::run() @ 0xde3315c in /usr/bin/clickhouse
14. Poco::Util::ServerApplication::run(int, char**) @ 0x17568d7a in /usr/bin/clickhouse
15. mainEntryClickHouseServer(int, char**) @ 0xde2fb86 in /usr/bin/clickhouse
16. main @ 0x8837833 in /usr/bin/clickhouse
17. __libc_start_main @ 0x237b3 in /usr/lib64/libc-2.28.so
18. _start @ 0x7ea07ee in /usr/bin/clickhouse

Cannot print extra info for Poco::Exception (version 23.1.3.5 (official build))

日志提示配置文件权限不足,可是没有修改过配置文件的权限。

查看配置文件权限:

1
2
3
4
5
6
7
$ ll -ht
total 80K
-rw------- 1 clickhouse clickhouse  70K Jun 14 10:15 config.xml
-r-------- 1 clickhouse clickhouse 5.4K Dec 29 07:19 users.xml
dr-x------ 2 clickhouse clickhouse    6 Dec 29 07:14 config.d
dr-x------ 2 clickhouse clickhouse    6 Dec 29 07:14 users.d

然而在本地测试环境这个权限可以启动成功,但是在生产环境会失败。

尝试修改配置文件权限755:

1
2
3
4
5
6
7
8
$ chmod 755 /etc/clickhouse-server/*

$ ll -ht
total 80K
-rwxr-xr-x 1 clickhouse clickhouse  71K Jun 14 16:19 config.xml
-rwxr-xr-x 1 clickhouse clickhouse 5.3K Feb  8 14:02 users.xml
drwxr-xr-x 2 clickhouse clickhouse    6 Feb  8 13:57 config.d
drwxr-xr-x 2 clickhouse clickhouse    6 Feb  8 13:57 users.d

修改权限后启动成功。

参考