检查
需要确保是否x86_64处理器构架、Linux并且支持SSE 4.2指令集
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
官网给的是Ubuntu/Debian的安装方式:如下
sudo apt-get install dirmngrsudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.listsudo apt-get updatesudo apt-get install -y clickhouse-server clickhouse-clientsudo service clickhouse-server startclickhouse-client
centos的安装
参考:
#step 1 #先下载安装脚本 curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash #可以指定系统版本 curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo os=centos dist=7 bash #这里注意,我当时指定错了系统版本,导致找不到libstdc++的依赖包,汗颜!! #step 2 #查看库里clickhouse相关的包 sudo yum list 'clickhouse*'
#step 3 #安装核心的服务和客户端 sudo yum install -y clickhouse-server clickhouse-client
#step 4 #启动服务 service clickhouse-server start #step 5 #启动客户端 clickhouse-client
通过java JDBC链接Clickhouse
maven 依赖
ru.yandex.clickhouse clickhouse-jdbc 0.1.54
java代码
JDBC Driver Class: ru.yandex.clickhouse.ClickHouseDriver
和mysql不同,不需要先Class.forName();加载drive;
应为我没有配置账号密码,所以直接给个url就可以创建链接,代码如下:
public static Connection getClickHouseConnection() throws SQLException { String url="jdbc:clickhouse://ip:8123/dataBaseName"; ClickHouseDataSource dataSou=new ClickHouseDataSource(url); return dataSou.getConnection(); }
附:Clickhouse官方文档