Hadoop生态圈-CentOs7.5单机部署ClickHouse
Hadoop生态圈-CentOs7.5单机部署ClickHouse
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
到了新的公司,认识了新的同事,生产环境也得你去适应新的集群环境,我新入职的公司的大数据开发同时并不看好hbase,而是对clickhouse青睐有加,听他们口头把ClickHouse吹的那么的出神入化,听的我是有种迫不及待想要对它一探究竟。
最新的一手资料请参考官网:https://clickhouse.yandex/
[root@yinzhengjie ~]# ip a | grep global | awk '{print $2}' | awk -F '/' '{print $1}' 10.1.2.105 [root@yinzhengjie ~]# [root@yinzhengjie ~]# hostname yinzhengjie [root@yinzhengjie ~]# [root@yinzhengjie ~]# cat /proc/cpuinfo| grep "processor"| wc -l 14 [root@yinzhengjie ~]# [root@yinzhengjie ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq cpu cores : 7 [root@yinzhengjie ~]# [root@yinzhengjie ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l 2 [root@yinzhengjie ~]# [root@yinzhengjie ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 14 Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz [root@yinzhengjie ~]# [root@yinzhengjie ~]# free -m total used free shared buff/cache available Mem: 11852 1406 8309 103 2136 9954 Swap: 6015 0 6015 [root@yinzhengjie ~]# [root@yinzhengjie ~]# free -g total used free shared buff/cache available Mem: 11 1 8 0 2 9 Swap: 5 0 5 [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# uname -r 3.10.0-862.el7.x86_64 [root@yinzhengjie ~]# [root@yinzhengjie ~]# uname -m x86_64 [root@yinzhengjie ~]# [root@yinzhengjie ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) You have new mail in /var/spool/mail/root [root@yinzhengjie ~]#
[root@yinzhengjie ~]# grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported" SSE 4.2 supported [root@yinzhengjie ~]#
我已经将上面的rpm包下载好了,以及需要的依赖包都下载好啦~大家可以直接下载来用即可。百度云链接:https://pan.baidu.com/s/16gPGxOnHKfRZj2ytOil7qQ 密码:rs4u
[root@yinzhengjie download]# ll total 42916 -rw-r--r-- 1 root root 43945614 Oct 10 20:10 yinzhengjie-clickhouse.tar.gz [root@yinzhengjie download]# [root@yinzhengjie download]# [root@yinzhengjie download]# tar zxf yinzhengjie-clickhouse.tar.gz -C ./ [root@yinzhengjie download]# [root@yinzhengjie download]# ll total 42920 drwxr-xr-x 2 root root 4096 Oct 10 20:03 clickhouse -rw-r--r-- 1 root root 43945614 Oct 10 20:10 yinzhengjie-clickhouse.tar.gz [root@yinzhengjie download]# [root@yinzhengjie download]# cd clickhouse/ [root@yinzhengjie clickhouse]# [root@yinzhengjie clickhouse]# ll total 43080 -rw-r--r-- 1 root root 3048 Oct 10 17:16 clickhouse-client-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 901472 Oct 10 17:16 clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 9043256 Oct 10 17:16 clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 33680608 Oct 10 17:18 clickhouse-server-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 8164 Oct 10 17:16 clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 49036 Oct 10 18:35 libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm -rw-r--r-- 1 root root 421792 Oct 10 18:20 unixODBC-2.3.1-11.el7.x86_64.rpm [root@yinzhengjie clickhouse]#
[root@yinzhengjie clickhouse]# ll total 43080 -rw-r--r-- 1 root root 3048 Oct 10 17:16 clickhouse-client-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 901472 Oct 10 17:16 clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 9043256 Oct 10 17:16 clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 33680608 Oct 10 17:18 clickhouse-server-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 8164 Oct 10 17:16 clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm -rw-r--r-- 1 root root 49036 Oct 10 18:35 libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm -rw-r--r-- 1 root root 421792 Oct 10 18:20 unixODBC-2.3.1-11.el7.x86_64.rpm [root@yinzhengjie clickhouse]# [root@yinzhengjie clickhouse]# You have new mail in /var/spool/mail/root [root@yinzhengjie clickhouse]# [root@yinzhengjie clickhouse]# yum -y localinstall *.rpm Loaded plugins: fastestmirror Examining clickhouse-client-1.1.54236-4.el7.x86_64.rpm: clickhouse-client-1.1.54236-4.el7.x86_64 Marking clickhouse-client-1.1.54236-4.el7.x86_64.rpm to be installed Examining clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm: clickhouse-compressor-1.1.54236-4.el7.x86_64 Marking clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm to be installed Examining clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm: clickhouse-debuginfo-1.1.54236-4.el7.x86_64 Marking clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm to be installed Examining clickhouse-server-1.1.54236-4.el7.x86_64.rpm: clickhouse-server-1.1.54236-4.el7.x86_64 Marking clickhouse-server-1.1.54236-4.el7.x86_64.rpm to be installed Examining clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm: clickhouse-server-common-1.1.54236-4.el7.x86_64 Marking clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm to be installed Examining libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm: libtool-ltdl-2.4.2-21.el7_2.x86_64 Marking libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm to be installed Examining unixODBC-2.3.1-11.el7.x86_64.rpm: unixODBC-2.3.1-11.el7.x86_64 Marking unixODBC-2.3.1-11.el7.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package clickhouse-client.x86_64 0:1.1.54236-4.el7 will be installed ---> Package clickhouse-compressor.x86_64 0:1.1.54236-4.el7 will be installed --> Processing Dependency: libicudata.so.50()(64bit) for package: clickhouse-compressor-1.1.54236-4.el7.x86_64 Determining fastest mirrors 10gen | 2.5 kB 00:00:00 base | 3.6 kB 00:00:00 centosplus | 3.4 kB 00:00:00 epel | 3.2 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): epel/x86_64/updateinfo | 948 kB 00:00:00 (2/3): epel/x86_64/primary | 3.6 MB 00:00:01 (3/3): updates/7/x86_64/primary_db | 6.0 MB 00:00:01 epel 12723/12723 --> Processing Dependency: libicui18n.so.50()(64bit) for package: clickhouse-compressor-1.1.54236-4.el7.x86_64 --> Processing Dependency: libicuuc.so.50()(64bit) for package: clickhouse-compressor-1.1.54236-4.el7.x86_64 ---> Package clickhouse-debuginfo.x86_64 0:1.1.54236-4.el7 will be installed ---> Package clickhouse-server.x86_64 0:1.1.54236-4.el7 will be installed ---> Package clickhouse-server-common.x86_64 0:1.1.54236-4.el7 will be installed ---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed ---> Package unixODBC.x86_64 0:2.3.1-11.el7 will be installed --> Running transaction check ---> Package libicu.x86_64 0:50.1.2-15.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================================================================================== Installing: clickhouse-client x86_64 1.1.54236-4.el7 /clickhouse-client-1.1.54236-4.el7.x86_64 110 clickhouse-compressor x86_64 1.1.54236-4.el7 /clickhouse-compressor-1.1.54236-4.el7.x86_64 2.9 M clickhouse-debuginfo x86_64 1.1.54236-4.el7 /clickhouse-debuginfo-1.1.54236-4.el7.x86_64 48 M clickhouse-server x86_64 1.1.54236-4.el7 /clickhouse-server-1.1.54236-4.el7.x86_64 133 M clickhouse-server-common x86_64 1.1.54236-4.el7 /clickhouse-server-common-1.1.54236-4.el7.x86_64 16 k libtool-ltdl x86_64 2.4.2-21.el7_2 /libtool-ltdl-2.4.2-21.el7_2.x86_64 66 k unixODBC x86_64 2.3.1-11.el7 /unixODBC-2.3.1-11.el7.x86_64 1.2 M Installing for dependencies: libicu x86_64 50.1.2-15.el7 base 6.9 M Transaction Summary =================================================================================================================================================================================================================== Install 7 Packages (+1 Dependent package) Total size: 192 M Total download size: 6.9 M Installed size: 209 M Downloading packages: libicu-50.1.2-15.el7.x86_64.rpm | 6.9 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libtool-ltdl-2.4.2-21.el7_2.x86_64 1/8 Installing : unixODBC-2.3.1-11.el7.x86_64 2/8 Installing : clickhouse-server-common-1.1.54236-4.el7.x86_64 3/8 Installing : libicu-50.1.2-15.el7.x86_64 4/8 Installing : clickhouse-server-1.1.54236-4.el7.x86_64 5/8 Installing : clickhouse-client-1.1.54236-4.el7.x86_64 6/8 Installing : clickhouse-compressor-1.1.54236-4.el7.x86_64 7/8 Installing : clickhouse-debuginfo-1.1.54236-4.el7.x86_64 8/8 Verifying : clickhouse-debuginfo-1.1.54236-4.el7.x86_64 1/8 Verifying : libtool-ltdl-2.4.2-21.el7_2.x86_64 2/8 Verifying : unixODBC-2.3.1-11.el7.x86_64 3/8 Verifying : libicu-50.1.2-15.el7.x86_64 4/8 Verifying : clickhouse-server-1.1.54236-4.el7.x86_64 5/8 Verifying : clickhouse-client-1.1.54236-4.el7.x86_64 6/8 Verifying : clickhouse-compressor-1.1.54236-4.el7.x86_64 7/8 Verifying : clickhouse-server-common-1.1.54236-4.el7.x86_64 8/8 Installed: clickhouse-client.x86_64 0:1.1.54236-4.el7 clickhouse-compressor.x86_64 0:1.1.54236-4.el7 clickhouse-debuginfo.x86_64 0:1.1.54236-4.el7 clickhouse-server.x86_64 0:1.1.54236-4.el7 clickhouse-server-common.x86_64 0:1.1.54236-4.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2 unixODBC.x86_64 0:2.3.1-11.el7 Dependency Installed: libicu.x86_64 0:50.1.2-15.el7 Complete! [root@yinzhengjie clickhouse]#
三.配置clickhouse
[root@yinzhengjie ~]# cp /etc/clickhouse-server/config.xml /etc/clickhouse-server/config.xml.`date +%F` [root@yinzhengjie ~]#
[root@yinzhengjie ~]# sed -i 's#<listen_host>127.0.0.1</listen_host>#<listen_host>10.1.2.105</listen_host>#' /etc/clickhouse-server/config.xml [root@yinzhengjie ~]#
3>.修改clickhouse-server配置文件config.xml(修改默认的9000端口,我们自定义该服务的端口为9999)
[root@yinzhengjie ~]# sed -i 's#<tcp_port>9000</tcp_port>#<tcp_port>9999</tcp_port>#' /etc/clickhouse-server/config.xml [root@yinzhengjie ~]#
4>.备份clickhouse-server配置文件users.xml
[root@yinzhengjie ~]# cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users.xml.`date +%F` [root@yinzhengjie ~]#
四.clickhouse管理方式
[root@yinzhengjie ~]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml Include not found: clickhouse_remote_servers Include not found: clickhouse_compression 2018.10.10 20:37:20.997594 [ 1 ] <Warning> Application: Logging to console 2018.10.10 20:37:21.000228 [ 1 ] <Information> : Starting daemon with revision 54236 2018.10.10 20:37:21.000337 [ 1 ] <Information> Application: starting up 2018.10.10 20:37:21.001299 [ 1 ] <Debug> Application: Set max number of file descriptors to 4096 (was 1024). 2018.10.10 20:37:21.001317 [ 1 ] <Debug> Application: Initializing DateLUT. 2018.10.10 20:37:21.001326 [ 1 ] <Trace> Application: Initialized DateLUT with time zone `Asia/Shanghai'. 2018.10.10 20:37:21.048483 [ 1 ] <Debug> Application: Configuration parameter 'interserver_http_host' doesn't exist or exists and empty. Will use 'yinzhengjie' as replica host. 2018.10.10 20:37:21.048676 [ 1 ] <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/users.xml' 2018.10.10 20:37:21.053081 [ 1 ] <Warning> ConfigProcessor: Include not found: networks 2018.10.10 20:37:21.053114 [ 1 ] <Warning> ConfigProcessor: Include not found: networks 2018.10.10 20:37:21.054194 [ 1 ] <Information> Application: Loading metadata. 2018.10.10 20:37:21.055243 [ 1 ] <Information> DatabaseOrdinary (default): Total 0 tables. 2018.10.10 20:37:21.055919 [ 1 ] <Debug> Application: Loaded metadata. 2018.10.10 20:37:21.056089 [ 1 ] <Information> DatabaseOrdinary (system): Total 0 tables. 2018.10.10 20:37:21.057059 [ 1 ] <Information> Application: Listening http://[::1]:8123 2018.10.10 20:37:21.057138 [ 1 ] <Information> Application: Listening tcp: [::1]:9999 2018.10.10 20:37:21.057198 [ 1 ] <Information> Application: Listening interserver: [::1]:9009 2018.10.10 20:37:21.057289 [ 1 ] <Information> Application: Listening http://10.1.2.105:8123 2018.10.10 20:37:21.057420 [ 1 ] <Information> Application: Listening tcp: 10.1.2.105:9999 2018.10.10 20:37:21.057486 [ 1 ] <Information> Application: Listening interserver: 10.1.2.105:9009 2018.10.10 20:37:21.057937 [ 1 ] <Information> Application: Ready for connections. 2018.10.10 20:37:23.048780 [ 2 ] <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/config.xml' 2018.10.10 20:37:23.053196 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_remote_servers 2018.10.10 20:37:23.053332 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_compression
2>.查看clickhouse服务是否启动
[root@yinzhengjie ~]# netstat -untalp | grep 9999 tcp 0 0 10.1.2.105:9999 0.0.0.0:* LISTEN 23259/clickhouse-se tcp6 0 0 ::1:9999 :::* LISTEN 23259/clickhouse-se [root@yinzhengjie ~]#
[root@yinzhengjie ~]# clickhouse-client --host=10.1.2.105 --port=9999 ClickHouse client version 1.1.54236. Connecting to 10.1.2.105:9999. Connected to ClickHouse server version 1.1.54236. :) :) select now(); SELECT now() ┌───────────────now()─┐ │ 2018-10-10 20:44:14 │ └─────────────────────┘ 1 rows in set. Elapsed: 0.067 sec. :) :) show tables; SHOW TABLES Ok. 0 rows in set. Elapsed: 0.003 sec. :) :)
4>.关闭clickhouse服务
[root@yinzhengjie ~]# ps -aux|grep clickhouse-server | grep -v grep root 24998 0.1 0.3 319708 43372 pts/1 Sl+ 20:48 0:00 clickhouse-server --config-file=/etc/clickhouse-server/config.xml [root@yinzhengjie ~]# [root@yinzhengjie ~]# kill -9 `ps -aux|grep clickhouse-server | grep -v grep | awk '{print $2}'` [root@yinzhengjie ~]# You have new mail in /var/spool/mail/root [root@yinzhengjie ~]# [root@yinzhengjie ~]# ps -aux|grep clickhouse-server | grep -v grep [root@yinzhengjie ~]# [root@yinzhengjie ~]#
5>.为clickhouse-server添加守护进程
[root@yinzhengjie ~]# nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml >/var/log/yinzhengjie-clickhouse.log 2>&1 & #会在"/var/log"目录下生成一个名称为“yinzhengjie-clickhouse.log”的日志文件 [1] 26619 [root@yinzhengjie ~]# [root@yinzhengjie ~]# tail -10f /var/log/yinzhengjie-clickhouse.log 2018.10.10 20:58:53.981429 [ 1 ] <Information> Application: Listening http://[::1]:8123 2018.10.10 20:58:53.981479 [ 1 ] <Information> Application: Listening tcp: [::1]:9999 2018.10.10 20:58:53.981516 [ 1 ] <Information> Application: Listening interserver: [::1]:9009 2018.10.10 20:58:53.981554 [ 1 ] <Information> Application: Listening http://10.1.2.105:8123 2018.10.10 20:58:53.981590 [ 1 ] <Information> Application: Listening tcp: 10.1.2.105:9999 2018.10.10 20:58:53.981624 [ 1 ] <Information> Application: Listening interserver: 10.1.2.105:9009 2018.10.10 20:58:53.981796 [ 1 ] <Information> Application: Ready for connections. 2018.10.10 20:58:55.973241 [ 2 ] <Debug> ConfigReloader: Loading config `/etc/clickhouse-server/config.xml' 2018.10.10 20:58:55.977391 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_remote_servers 2018.10.10 20:58:55.977455 [ 2 ] <Warning> ConfigProcessor: Include not found: clickhouse_compression 2018.10.10 20:59:09.185410 [ 3 ] <Trace> TCPConnectionFactory: TCP Request. Address: 10.1.2.105:41874 2018.10.10 20:59:09.185660 [ 3 ] <Debug> TCPHandler: Connected ClickHouse client version 1.1.54236, user: default. 2018.10.10 20:59:18.439436 [ 3 ] <Debug> executeQuery: (from 10.1.2.105:41874) select now() 2018.10.10 20:59:18.440437 [ 3 ] <Trace> InterpreterSelectQuery: FetchColumns -> Complete 2018.10.10 20:59:18.440867 [ 3 ] <Debug> executeQuery: Query pipeline: Expression Expression One 2018.10.10 20:59:18.441657 [ 3 ] <Information> executeQuery: Read 1 rows, 1.00 B in 0.002 sec., 510 rows/sec., 510.97 B/sec. 2018.10.10 20:59:18.441764 [ 3 ] <Debug> MemoryTracker: Peak memory usage (for query): 1.00 MiB. 2018.10.10 20:59:18.441804 [ 3 ] <Debug> MemoryTracker: Peak memory usage (for user): 1.00 MiB. 2018.10.10 20:59:18.441849 [ 3 ] <Debug> MemoryTracker: Peak memory usage (total): 1.00 MiB. 2018.10.10 20:59:18.441882 [ 3 ] <Information> TCPHandler: Processed in 0.003 sec.
好啦~分享就到这里了,时间过的咋就这么快呢?一不小心就晚上九点多了,关于ClickHouse集群的部署等我后期研究好了也会分享给大家的,我得赶紧走了,不然赶不上地铁啦!晚安,兄弟们!
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/9768575.html,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。