clickhouse学习(1)-clickhouse安装卸载

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


88             1
重启
/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     
212     0.0.0.0

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

你可能感兴趣的:(clickhouse)