Linux之centos安装clinkhouse以及python如何连接

简介: Linux之centos安装clinkhouse以及python如何连接

1.安装

clinkhouse之安装以及python操作

1.Clickhouse 仅支持Linux 且必须支持SSE4.2 指令集
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
显示
SSE 4.2 supported


2.首先去根目录创建文件
mkdir /myclinkhouse
cd /myclinkhouse
3.直接复制下载
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-20.3.12.112-1.el7.x86_64.rpm/download.rpm

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-20.3.12.112-1.el7.x86_64.rpm/download.rpm

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-20.3.12.112-1.el7.x86_64.rpm/download.rpm

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-20.3.12.112-1.el7.x86_64.rpm/download.rpm

4.解压安装
rpm -ivh ./*.rpm

5.卸载(当你装错了)
# 卸载及删除安装文件(需root权限)
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

6.创建用户名密码
password=$(base64 < /dev/urandom | head -c8); echo "$password"; 
echo -n "$password" | sha256sum | tr -d '-'
输出:明文  密文
RaSQ8uTe
1bf9e7c1e8692697f360a40aabfeaa8ae386b304482cdd81e597a36f426d432c


7.修改配置文件
vim /etc/clickhouse-server/config.xml
修改下面这个
<listen_host>0.0.0.0</listen_host>

vim /etc/clickhouse-server/users.xml
#找到 users --> default --> 标签下的password修改成password_sha256_hex,并把密文填进去
<password_sha256_hex>1bf9e7c1e8692697f360a40aabfeaa8ae386b304482cdd81e597a36f426d432c</password_sha256_hex>

8.启动以及重启
service clickhouse-server start
service clickhouse-server restart


9.连接
9.1直接连接
clickhouse-client
9.2用命令连接
clickhouse-client -h wusen0601.xyz -d default -m -u default --password 明文

View Code

2.python使用

# pip install clickhouse-driver
from clickhouse_driver import Client
import random

host = "wusen0601.xyz"
port = "9000"
user = "default"
password = "RaSQ8uTe1"
database = "default"
client = Client(host=host, port=port, user=user, password=password, database=database)
# client = Client(host=host, port=port, database=database)
sql = f"""
select enterprise_name,bike_type,count(*) as nums
from t_bike_location_real
GROUP BY (enterprise_name,bike_type)
"""

enterprise_name_list = [
    {"enterprise_name": "哈罗", "enterprise_id": "10001", "bike_type": random.randrange(0, 2),"bike_id":random.randrange(100000,1000000)},
    {"enterprise_name": "美团", "enterprise_id": "10002", "bike_type": random.randrange(0, 2),"bike_id":random.randrange(100000,1000000)},
    {"enterprise_name": "骑电", "enterprise_id": "10003", "bike_type": random.randrange(0, 2),"bike_id":random.randrange(100000,1000000)}
]
index_random = random.randrange(0,len(enterprise_name_list))
insert_data = enterprise_name_list[index_random]
insert_sql = f"""
insert into t_bike_location_real
(enterprise_name,enterprise_id,bike_type,bike_id)

values('{insert_data['enterprise_name']}','{insert_data['enterprise_id']}','{insert_data['bike_type']}','{insert_data['bike_id']}')
"""
print(insert_sql)
for i in range(100):
    ans = client.execute(insert_sql)

    print(ans)
相关文章
|
3月前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
1489 2
|
2月前
|
安全 Linux iOS开发
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
209 6
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
|
3月前
|
人工智能 数据安全/隐私保护 异构计算
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
490 8
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
|
3月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
706 16
|
2月前
|
消息中间件 Kafka Linux
Linux下安装Kafka 3.9.1
本文介绍Kafka 3.9.1版本的安装与配置,包括通过ZooKeeper或KRaft模式启动Kafka。涵盖环境变量设置、日志路径修改、集群UUID生成、存储格式化及服务启停操作,适用于Linux环境下的部署实践。
346 0
|
4月前
|
存储 关系型数据库 MySQL
在CentOS 8.x上安装Percona Xtrabackup工具备份MySQL数据步骤。
以上就是在CentOS8.x上通过Perconaxtabbackup工具对Mysql进行高效率、高可靠性、无锁定影响地实现在线快速全量及增加式数据库资料保存与恢复流程。通过以上流程可以有效地将Mysql相关资料按需求完成定期或不定期地保存与灾难恢复需求。
415 10
|
4月前
|
网络协议 关系型数据库 Linux
【App Service Linux】在Linux App Service中安装 tcpdump 并抓取网络包
在App Service for Linux环境中,无法像Windows一样直接使用网络排查工具抓包。本文介绍了如何通过TCPDUMP在Linux环境下抓取网络包,包括SSH进入容器、安装tcpdump、执行抓包命令及下载分析文件的完整操作步骤。
239 5
|
4月前
|
弹性计算 安全 Linux
阿里云服务器ECS安装宝塔Linux面板、安装网站(新手图文教程)
本教程详解如何在阿里云服务器上安装宝塔Linux面板,涵盖ECS服务器手动安装步骤,包括系统准备、远程连接、安装命令执行、端口开放及LNMP环境部署,手把手引导用户快速搭建网站环境。
|
分布式计算 资源调度 Hadoop