1. 下载clickhouse镜像
clickhouse-server docker hub镜像地址clickhouse/clickhouse-server - Docker Image | Docker Hub
docker pull clickhouse/clickhouse-server
直接下载镜像非常慢,换用docker hub国内镜像源
[root@localhost yum.repos.d]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
2. 创建并启动clickhouse容器
docker run -d --privileged -p 18123:8123 -p19000:9000 --name clickhouse --ulimit nofile=262144:262144 clickhouse/clickhouse-server
3. 测试
[root@cdh1 ~]# echo 'SELECT version()' | curl 'http://localhost:18123/' --data-binary @-
23.5.3.24
启动成功
4. 安装遇到的问题
一开始安装使用的docker run命令没有加--privileged,容器启动会报如下错误,加上--privileged后正常启动
[root@cdh1 ~]# docker logs clickhouse
stat: cannot statx '/var/lib/clickhouse/': Operation not permitted
stat: cannot statx '/var/log/clickhouse-server': Operation not permitted
stat: cannot statx '/var/log/clickhouse-server': Operation not permitted
stat: cannot statx '/var/lib/clickhouse/tmp/': Operation not permitted
stat: cannot statx '/var/lib/clickhouse/user_files/': Operation not permitted
stat: cannot statx '/var/lib/clickhouse/format_schemas/': Operation not permitted
ls: cannot access '/docker-entrypoint-initdb.d/': Operation not permitted
Processing configuration file '/etc/clickhouse-server/config.xml'.
Merging configuration file '/etc/clickhouse-server/config.d/docker_related_config.xml'.
Logging trace to /var/log/clickhouse-server/clickhouse-server.log
Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log
Cannot add message to the log: Sending crash reports is disabled
Poco::Exception. Code: 1000, e.code() = 0, Exception: Could not determine time zone from TZ variable value: 'Asia/Shanghai': filesystem error: in canonical: Operation not permitted ["/usr/share/zoneinfo/"] [""], Stack trace (when copying this message, always include the lines below):
0. DateLUT::DateLUT() @ 0x000000000e333ab8 in /usr/bin/clickhouse
1. OwnPatternFormatter::formatExtended(DB::ExtendedLogMessage const&, String&) const @ 0x000000000e5d35f2 in /usr/bin/clickhouse
2. DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage const&) @ 0x000000000e5cf573 in /usr/bin/clickhouse
3. DB::OwnSplitChannel::logSplit(Poco::Message const&) @ 0x000000000e5d4259 in /usr/bin/clickhouse
4. DB::OwnSplitChannel::tryLogSplit(Poco::Message const&) @ 0x000000000e5d40a4 in /usr/bin/clickhouse
5. DB::OwnSplitChannel::log(Poco::Message const&) @ 0x000000000e5d3dd5 in /usr/bin/clickhouse
6. SentryWriter::initialize(Poco::Util::LayeredConfiguration&) @ 0x000000000e5c695e in /usr/bin/clickhouse
7. BaseDaemon::initializeTerminationAndSignalProcessing() @ 0x000000000e5bc71b in /usr/bin/clickhouse
8. BaseDaemon::initialize(Poco::Util::Application&) @ 0x000000000e5b94d4 in /usr/bin/clickhouse
9. DB::Server::initialize(Poco::Util::Application&) @ 0x000000000e3cf723 in /usr/bin/clickhouse
10. Poco::Util::Application::run() @ 0x0000000017c4557a in /usr/bin/clickhouse
11. DB::Server::run() @ 0x000000000e3cf57e in /usr/bin/clickhouse
12. Poco::Util::ServerApplication::run(int, char**) @ 0x0000000017c58cb9 in /usr/bin/clickhouse
13. mainEntryClickHouseServer(int, char**) @ 0x000000000e3cc546 in /usr/bin/clickhouse
14. main @ 0x00000000087fb92f in /usr/bin/clickhouse
15. ? @ 0x00007f21a6483d90 in ?
16. __libc_start_main @ 0x00007f21a6483e40 in ?
17. _start @ 0x0000000007f281ee in /usr/bin/clickhouse
(version 23.5.3.24 (official build))
Cannot add message to the log: Pipe capacity is 1.00 MiB
Poco::Exception. Code: 1000, e.code() = 0, Exception: Could not determine time zone from TZ variable value: 'Asia/Shanghai': filesystem error: in canonical: Operation not permitted ["/usr/share/zoneinfo/"] [""], Stack trace (when copying this message, always include the lines below):
0. DateLUT::DateLUT() @ 0x000000000e333ab8 in /usr/bin/clickhouse
1. OwnPatternFormatter::formatExtended(DB::ExtendedLogMessage const&, String&) const @ 0x000000000e5d35f2 in /usr/bin/clickhouse
2. DB::OwnFormattingChannel::logExtended(DB::ExtendedLogMessage const&) @ 0x000000000e5cf573 in /usr/bin/clickhouse
3. DB::OwnSplitChannel::logSplit(Poco::Message const&) @ 0x000000000e5d4259 in /usr/bin/clickhouse
4. DB::OwnSplitChannel::tryLogSplit(Poco::Message const&) @ 0x000000000e5d40a4 in /usr/bin/clickhouse
5. DB::OwnSplitChannel::log(Poco::Message const&) @ 0x000000000e5d3dd5 in /usr/bin/clickhouse
6. DB::LazyPipeFDs::tryIncreaseSize(int) @ 0x000000000e38707f in /usr/bin/clickhouse
7. BaseDaemon::initializeTerminationAndSignalProcessing() @ 0x000000000e5bc8b4 in /usr/bin/clickhouse
8. BaseDaemon::initialize(Poco::Util::Application&) @ 0x000000000e5b94d4 in /usr/bin/clickhouse
9. DB::Server::initialize(Poco::Util::Application&) @ 0x000000000e3cf723 in /usr/bin/clickhouse
10. Poco::Util::Application::run() @ 0x0000000017c4557a in /usr/bin/clickhouse
11. DB::Server::run() @ 0x000000000e3cf57e in /usr/bin/clickhouse
12. Poco::Util::ServerApplication::run(int, char**) @ 0x0000000017c58cb9 in /usr/bin/clickhouse
13. mainEntryClickHouseServer(int, char**) @ 0x000000000e3cc546 in /usr/bin/clickhouse
14. main @ 0x00000000087fb92f in /usr/bin/clickhouse
15. ? @ 0x00007f21a6483d90 in ?
16. __libc_start_main @ 0x00007f21a6483e40 in ?
17. _start @ 0x0000000007f281ee in /usr/bin/clickhouse
(version 23.5.3.24 (official build))
Poco::Exception. Code: 1000, e.code() = 0, System exception: cannot start thread, Stack trace (when copying this message, always include the lines below):
0. Poco::ThreadImpl::startImpl(Poco::SharedPtr>) @ 0x0000000017dab56e in /usr/bin/clickhouse
1. Poco::Thread::start(Poco::Runnable&) @ 0x0000000017dac4cb in /usr/bin/clickhouse
2. BaseDaemon::initializeTerminationAndSignalProcessing() @ 0x000000000e5bc964 in /usr/bin/clickhouse
3. BaseDaemon::initialize(Poco::Util::Application&) @ 0x000000000e5b94d4 in /usr/bin/clickhouse
4. DB::Server::initialize(Poco::Util::Application&) @ 0x000000000e3cf723 in /usr/bin/clickhouse
5. Poco::Util::Application::run() @ 0x0000000017c4557a in /usr/bin/clickhouse
6. DB::Server::run() @ 0x000000000e3cf57e in /usr/bin/clickhouse
7. Poco::Util::ServerApplication::run(int, char**) @ 0x0000000017c58cb9 in /usr/bin/clickhouse
8. mainEntryClickHouseServer(int, char**) @ 0x000000000e3cc546 in /usr/bin/clickhouse
9. main @ 0x00000000087fb92f in /usr/bin/clickhouse
10. ? @ 0x00007f21a6483d90 in ?
11. __libc_start_main @ 0x00007f21a6483e40 in ?
12. _start @ 0x0000000007f281ee in /usr/bin/clickhouse
(version 23.5.3.24 (official build))