偶然接触ClickHouse这种快速开源的OLAP列式数据库管理系统,就按照随手搜索的帖子操作,看ClickHouse官网上打了会酱油,看了看文档,貌似太深奥,就直奔installation,可是文档太专业,从环境检测到Deb安装、Rpm安装、Tgz安装,最后还有Docker安装,也不确定那种方式靠谱,就找了偏步骤比较详细的帖子操练了起来
稳定版有两套,就选择了较高的版本,打算试吃一下。
第一步:下载安装包
clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm
clickhouse-client-1.1.54236-4.el7.x86_64.rpm
clickhouse-server-1.1.54236-4.el7.x86_64.rpm
第二步:上传云主机
CPU&内存 1核2 GiB
操作系统 CentOS 7.9 64位
实例规格 ecs.n4.small
实例规格族 共享计算型
云盘 1
快照 0
镜像ID centos_7_9_x64_20G_alibase_20210420.vhd
当前使用带宽 1Mbps
sftp:/opt/software/clickhouse> ls
-rw-r--r-- 1 root root 8164 Jul 21 18:12 clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm
drwxr-xr-x 2 root root 4096 Jul 21 18:12 .
-rw-r--r-- 1 root root 3048 Jul 21 18:12 clickhouse-client-1.1.54236-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 33680608 Jul 21 18:12 clickhouse-server-1.1.54236-4.el7.x86_64.rpm
drwxr-xr-x 4 root root 4096 Jul 21 18:11 ..
第三步:开始安装(然而报错了)
[root@yaong clickhouse]# rpm -ivh ./clickhouse*.rpm
error: Failed dependencies:
libicudata.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libicui18n.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libicuuc.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libltdl.so.7()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libodbc.so.2()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
第四步:搜索相似案例,解决一下???yum -y install unixODBC
[root@yaong clickhouse]# yum -y install unixODBC
第五步:再尝试安装,还有依赖异常
[root@yaong clickhouse]# rpm -ivh ./clickhouse*.rpm
error: Failed dependencies:
libicudata.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libicui18n.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
libicuuc.so.50()(64bit) is needed by clickhouse-server-1.1.54236-4.el7.x86_64
第六步:搜索相似案例,再解决一下???yum install libicu.x86_64
[root@yaong clickhouse]# yum search libicu
[root@yaong clickhouse]# yum install libicu.x86_64
最终:安装成功
[root@yaong clickhouse]# rpm -ivh ./clickhouse*.rpm
Preparing... ################################# [100%]
Updating / installing...
1:clickhouse-server-common-1.1.5423################################# [ 33%]
2:clickhouse-server-1.1.54236-4.el7################################# [ 67%]
3:clickhouse-client-1.1.54236-4.el7################################# [100%]
附:简单连接测试
1.启动clickhouse-server服务? ?systemctl start clickhouse-server
[root@yaong clickhouse-server]# systemctl start clickhouse-server
[root@yaong clickhouse-server]# systemctl status clickhouse-server
● clickhouse-server.service - LSB: Yandex clickhouse-server daemon
Loaded: loaded (/etc/rc.d/init.d/clickhouse-server; bad; vendor preset: disabled)
Active: active (exited) since Wed 2021-07-21 23:33:07 CST; 17s ago
Docs: man:systemd-sysv-generator(8)
Process: 3951 ExecStop=/etc/rc.d/init.d/clickhouse-server stop (code=exited, status=0/SUCCESS)
Process: 4166 ExecStart=/etc/rc.d/init.d/clickhouse-server start (code=exited, status=0/SUCCESS)
Jul 21 23:33:07 yaong systemd[1]: Starting LSB: Yandex clickhouse-server daemon...
Jul 21 23:33:07 yaong su[4174]: (to clickhouse) root on none
Jul 21 23:33:07 yaong clickhouse-server[4166]: Start clickhouse-server service: Path to data directory in /etc/clickhouse-ser...house/
Jul 21 23:33:07 yaong su[4194]: (to clickhouse) root on none
Jul 21 23:33:07 yaong su[4196]: (to clickhouse) root on none
Jul 21 23:33:07 yaong su[4199]: (to clickhouse) root on none
Jul 21 23:33:07 yaong su[4204]: (to clickhouse) root on none
Jul 21 23:33:07 yaong clickhouse-server[4166]: DONE
Jul 21 23:33:07 yaong systemd[1]: Started LSB: Yandex clickhouse-server daemon.
Hint: Some lines were ellipsized, use -l to show in full.
备注:启动方式汇总
系统服务命令 | systemctl start clickhouse-server 系统服务器常用方式,简单通用 |
---|
前台启动 | sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml 指定用户(clickhouse)指定配置文件(config.xml)启动服务,更灵活更动态的启动服务 可以显示服务启动项的各种信息,缺点是会占据一个命令终端 [root@yaong ~]# sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
Include not found: clickhouse_remote_servers
Include not found: clickhouse_compression
2021.07.22 00:25:53.124820 [ 1 ] <Warning> Application: Logging to console
2021.07.22 00:25:53.126610 [ 1 ] <Information> : Starting daemon with revision 54236
2021.07.22 00:25:53.126681 [ 1 ] <Information> Application: starting up
2021.07.22 00:25:53.127218 [ 1 ] <Debug> Application: rlimit on number of file descriptors is 262144
2021.07.22 00:25:53.127228 [ 1 ] <Debug> Application: Initializing DateLUT.
2021.07.22 00:25:53.127233 [ 1 ] <Trace> Application: Initialized DateLUT with time zone `Asia/Shanghai'.
2021.07.22 00:25:53.127668 [ 1 ] <Debug> Application: Configuration parameter 'interserver_http_host' doesn't exist or exists and empty. Will use 'yaong' as replica host.
2021.07.22 00:25:53.127729 [ 1 ] <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/users.xml'
2021.07.22 00:25:53.131337 [ 1 ] <Warning> ConfigProcessor: Include not found: networks
2021.07.22 00:25:53.131351 [ 1 ] <Warning> ConfigProcessor: Include not found: networks
2021.07.22 00:25:53.131824 [ 1 ] <Information> Application: Loading metadata.
2021.07.22 00:25:53.132003 [ 1 ] <Information> DatabaseOrdinary (system): Total 0 tables.
2021.07.22 00:25:53.132058 [ 1 ] <Information> DatabaseOrdinary (default): Total 0 tables.
2021.07.22 00:25:53.132080 [ 1 ] <Debug> Application: Loaded metadata.
2021.07.22 00:25:53.132597 [ 1 ] <Information> Application: Listening http://[::1]:8123
2021.07.22 00:25:53.132625 [ 1 ] <Information> Application: Listening tcp: [::1]:9000
2021.07.22 00:25:53.132644 [ 1 ] <Information> Application: Listening interserver: [::1]:9009
2021.07.22 00:25:53.132664 [ 1 ] <Information> Application: Listening http://127.0.0.1:8123
2021.07.22 00:25:53.132681 [ 1 ] <Information> Application: Listening tcp: 127.0.0.1:9000
2021.07.22 00:25:53.132697 [ 1 ] <Information> Application: Listening interserver: 127.0.0.1:9009
2021.07.22 00:25:53.132822 [ 1 ] <Information> Application: Ready for connections.
2021.07.22 00:25:55.132514 [ 2 ] <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/config.xml'
2021.07.22 00:25:55.136229 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_remote_servers
2021.07.22 00:25:55.136269 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_compression | 后台启动 |
nohup sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml >null 2>&1 &
用法与前台启动一致,差别在于不打印启动项信息,不占据命令行,在后台启动服务
[root@yaong clickhouse-server]# nohup sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml >null 2>&1 &
[1] 4395
|
?2.启动clickhouse-client连接服务??clickhouse-client -m 连接成功,但是简单操作会失败
[root@yaong ~]# clickhouse-client -m
ClickHouse client version 1.1.54236.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54236.
:) select 1 + 1;
SELECT 1 + 1
Received exception from server:
Code: 49. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Logical error: zero number of streams requested.
0 rows in set. Elapsed: 0.042 sec.
:) show databases;
SHOW DATABASES
Received exception from server:
Code: 49. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Logical error: zero number of streams requested.
0 rows in set. Elapsed: 0.009 sec.
:)
3.简单设置,解决异常?
?:) set max_threads = 16;
:) set max_threads = 16;
SET max_threads = 16
Ok.
0 rows in set. Elapsed: 0.001 sec.
:) SELECT * FROM system.settings WHERE name = 'max_threads';
SELECT *
FROM system.settings
WHERE name = 'max_threads'
┌─name────────┬─value─┬─changed─┐
│ max_threads │ 16 │ 1 │
└─────────────┴───────┴─────────┘
1 rows in set. Elapsed: 0.002 sec.
:) select 1 + 1;
SELECT 1 + 1
┌─plus(1, 1)─┐
│ 2 │
└────────────┘
1 rows in set. Elapsed: 0.001 sec.
:) show databases;
SHOW DATABASES
┌─name────┐
│ default │
│ system │
└─────────┘
2 rows in set. Elapsed: 0.001 sec.
?前台启动服务的一个好处就是可以查看Client执行语句和状态
4.客户端断开连接
:) quit;
Bye.
[root@yaong ~]#
首次尝鲜到此为止,下次介绍ClickHouse的用户管理和配置管理,敬请期待。
|