[Solved] Clickhouse Error: DB::Exception: Cannot lock file /var/lib/clickhouse/status

1、 Problem description

After the Clickhouse is started, it can be accessed by itself. There is no problem, and it can also be accessed externally. However, check its error log and find that there are always errors

tail -f clickhouse-server/clickhouse-server.err.log
output:
2020.10.07 19:05:32.720350 [ 8150 ] {} <Error> Application: DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
2020.10.07 19:06:02.970577 [ 8217 ] {} <Error> Application: DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
2020.10.07 19:06:33.220827 [ 8632 ] {} <Error> Application: DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
2020.10.07 19:07:03.471225 [ 8706 ] {} <Error> Application: DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
2020.10.07 19:07:33.720339 [ 8880 ] {} <Error> Application: DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
...

It doesn’t stop, so it’s embarrassing.

2. Problem-solving

After probing, the Clickhouse server may have been started twice before. Therefore, check the status file directly according to the log directory

cat /var/lib/clickhouse/status
ps -ef | grep clickhouse-server
Delete the corresponding clickhouse-server
kill -9 $pid
systemctl start clickhouse-server

Then, check the error log again, and it’s OK

tail -f clickhouse-server/clickhouse-server.err.log

Read More: