$ sudo apt-get install clustershell #输入你的管理员密码 $ cd /etc/clustershell $ sudo gedit groups #在文件中添加如下内容: all: clickhouse-node-[01-14] replica1:clickhouse-node-[07,10,13] replica2:clickhouse-node-[08,11,14] distributed:clickhouse-node-[06,09,12] chproxy:clickhouse-node-[06,09,12]
第一步,打开Ubuntu18.04中的terminal
接下来要验证一下你的机器里的ssh是否为免密登录
$ ssh localhost
如果要求输入密码,则说明你的机器并没有设置免密登录
首先退出刚才的 ssh,就回到了我们原先的终端窗口,然后利用 ssh-keygen 生成密钥,并将密钥加入到授权中:
1 $ exit # 退出刚才的 ssh localhost 2 3 $ cd ~/.ssh/ # 若没有该目录,请先执行一次ssh localhost 4 5 $ ssh-keygen -t rsa # 会有提示,都按回车就可以 6 7 $ cat ./id_rsa.pub >> ./authorized_keys # 加入授权
注:若你的机器没有ssh,请输入命令sudo apt-get install openssh-server
如果是centOS的话,就用下图的方式来免密登录
exit # 退出刚才的 ssh localhost cd ~/.ssh/ # 若没有该目录,请先执行一次ssh localhost ssh-keygen -t rsa # 会有提示,都按回车就可以 cat id_rsa.pub >> authorized_keys # 加入授权 chmod 600 ./authorized_keys # 修改文件权限
安装Java环境
$ sudo yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
$ vim ~/.bashrc
export JAVA_HOME=JDK安装路径
一般openjdk默认安装路径为 /usr/lib/jvm/ 下,在文件里最前面添加单独一行(注意=前后不能有空格):
别忘了保存后要source一下:source ~/.bashrc
接下来开始下载rpm包
首先新建RPM包所在位置
$ mkdir -p /opt/software/clickhouse/
$ cd /opt/software/clickhouse/
然后开始下载RPM包:
下载地址:https://packagecloud.io/Altinity/clickhouse/
安装rpm包顺序
$ sudo wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-19.3.6-1.el7.x86_64.rpm/download.rpm $ sudo wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-19.3.6-1.el7.x86_64.rpm/download.rpm $ sudo wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-19.3.6-1.el7.x86_64.rpm/download.rpm $ sudo wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-test-19.3.6-1.el7.x86_64.rpm/download.rpm $ sudo wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-19.3.6-1.el7.x86_64.rpm/download.rpm $ sudo rpm -ivh clickhouse-server-common-19.3.6-1.el7.x86_64.rpm $ sudo rpm -ivh clickhouse-common-static-19.3.6-1.el7.x86_64.rpm $ sudo rpm -ivh clickhouse-server-19.3.6-1.el7.x86_64.rpm $ sudo rpm -ivh clickhouse-test-19.3.6-1.el7.x86_64.rpm $ sudo rpm -ivh clickhouse-client-19.3.6-1.el7.x86_64.rpm
关闭防火墙
$ systemctl stop firewalld.service #停止firewall
$ systemctl disable firewalld.service #禁止firewall开机启动
启动clickhouse服务端
$ service clickhouse-server start
通过客户端连接
$ clickhouse-client –m
放开远程访问
$ vi /etc/clickhouse-server/config.xml
修改第七十行
内存限制
$ vi /etc/clickhouse-server/users.xml
设置数据目录
$ vi /etc/clickhouse-server/config.xml
修改启动脚本
$ sudo gedit /etc/init.d/clickhouse-server
<?xml version="1.0"?> <yandex> <logger> <level>trace</level> <log>/data/clickhouse/logs/server.log</log> <errorlog>/data/clickhouse/logs/error.log</errorlog> <size>1000M</size> <count>10</count> </logger> <http_port>8123</http_port> <tcp_port>9000</tcp_port> <interserver_http_port>9009</interserver_http_port> <listen_host>0.0.0.0</listen_host> <path>/data/clickhouse/</path> <tmp_path>/data/clickhouse/tmp/</tmp_path> <users_config>users.xml</users_config> <default_profile>default</default_profile> <default_database>default</default_database> <remote_servers incl="clickhouse_remote_servers" /> <zookeeper incl="zookeeper-servers" optional="true" /> <macros incl="macros" optional="true" /> <include_from>/etc/clickhouse-server/metrika.xml</include_from> </yandex>
修改集群配置
<?xml version="1.0"?> <yandex> <logger> <level>trace</level> <log>/data/clickhouse/logs/server.log</log> <errorlog>/data/clickhouse/logs/error.log</errorlog> <size>1000M</size> <count>10</count> </logger> <http_port>8123</http_port> <tcp_port>9000</tcp_port> <interserver_http_port>9009</interserver_http_port> <listen_host>0.0.0.0</listen_host> <path>/data/clickhouse/</path> <tmp_path>/data/clickhouse/tmp/</tmp_path> <users_config>users.xml</users_config> <default_profile>default</default_profile> <default_database>default</default_database> <remote_servers incl="clickhouse_remote_servers" /> <zookeeper incl="zookeeper-servers" optional="true" /> <macros incl="macros" optional="true" /> <include_from>/etc/clickhouse-server/metrika.xml</include_from> </yandex>
文末送福利:
https://pan.baidu.com/s/12hE68LF59eaen69Z3O71nA
原文地址:https://www.cnblogs.com/cherish-cxh/p/10482470.html