clickhouse學習(1)-clickhouse安裝解除安裝

niewj發表於2023-01-18

1. centos7下解除安裝刪除:

yum list installed | grep clickhouse
yum remove -y clickhouse-common-static
yum remove -y clickhouse-server-common
rm -rf /var/lib/clickhouse
rm -rf /etc/clickhouse-*
rm -rf /var/log/clickhouse-server

2. centos7安裝clickhouse

2.1 安裝:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
sudo yum install -y clickhouse-server clickhouse-client

sudo /etc/init.d/clickhouse-server start
clickhouse-client # or "clickhouse-client --password" if you set up a password.

2.2 查詢當前版本:

SELECT version()

Query id: 8c3867fc-df94-456e-9b2c-863459a6d03b

┌─version()─┐
│ 22.12.3.5 │
└───────────┘

1 row in set. Elapsed: 0.002 sec.

3. 建立使用者

建立一個新使用者 niewj/246810 有所有許可權:

vim /etc/clickhouse-server/users.xml

3.1 配置修改access_management

<!-- User can create other users and grant rights to them. -->
88             <access_management>1</access_management>
重啟
/etc/init.d/clickhouse-server restart

如果不修改就建立, 會報錯如下:

CREATE USER niewj IDENTIFIED WITH plaintext_password BY '246810' HOST ANY DEFAULT ROLE ALL;
CREATE USER zhili IDENTIFIED WITH plaintext_password BY '246810' HOST ANY DEFAULT ROLE ALL

Query id: 3b1f8e98-5bc7-4be9-bc1f-70b05c9e1f25


0 rows in set. Elapsed: 0.003 sec. 

Received exception from server (version 22.12.3):
Code: 497. DB::Exception: Received from localhost:9000. DB::Exception: default: Not enough privileges. To execute this query it's necessary to have grant CREATE USER ON *.*. (ACCESS_DENIED)

修改配置後:

CREATE USER niewj IDENTIFIED WITH plaintext_password BY '246810' HOST ANY DEFAULT ROLE ALL

Query id: 065e8142-7e63-49d9-b69c-108a0d4ccfbd

Ok.

0 rows in set. Elapsed: 0.001 sec.

3.2 dbeaver連線clickhouse

修改配置: config.xml:放開此處註釋

vim /etc/clickhouse-server/config.xml
211     <!-- Same for hosts without support for IPv6: -->
212     <listen_host>0.0.0.0</listen_host>

4.埠開放

如果埠不開放當然訪問不了, 這裡例舉了開放80和443和8123, 只需要開8123就可以了!

4.1 開啟埠80和443

如果你的伺服器開啟了防火牆,你需要執行下面的命令,開啟80和443埠。

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

4.2 開啟埠8123

# 1. 查詢埠是否開啟
firewall-cmd --query-port=8123/tcp
# 2. 開啟埠8123
firewall-cmd --zone=public --add-port=8123/tcp --permanent
# 3. 使生效
firewall-cmd --reload

重啟服務

sudo -u clickhouse clickhouse-server stop
sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml

相關文章