零起飞网站建设工作室,沧州网站制作,无限时间看片直播,深圳本地做网站一、安装环境
CentOS7
二、官网安装参考文档
官网安装参考文档
不同系统请参考如下建议
从RPM软件包安装#xff1a; 建议在CentOS、RedHat和所有其他基于rpm的Linux发行版上使用官方预编译的rpm软件包从DEB软件包安装#xff1a; 建议在Debian或Ubuntu上使用官方预编译…一、安装环境
CentOS7
二、官网安装参考文档
官网安装参考文档
不同系统请参考如下建议
从RPM软件包安装 建议在CentOS、RedHat和所有其他基于rpm的Linux发行版上使用官方预编译的rpm软件包从DEB软件包安装 建议在Debian或Ubuntu上使用官方预编译的deb软件包
三、安装步骤
1. 设置clickhouse仓库
执行如下命令设置clickhouse官方仓库
[root172 ~]# yum install -y yum-utils
[root172 ~]# yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo2. 安装clickhouse服务和客户端
[root172 ~]# yum install -y clickhouse-server clickhouse-client3. 启动clickhouse服务
如下为clickhouse相关命令
命令说明systemctl status clickhouse-server查看服务状态systemctl start clickhouse-server启动服务systemctl stop clickhouse-server停止服务systemctl enable clickhouse-server设置服务为自启动systemctl disable clickhouse-server禁用服务为自启动
未启动状态 启动之后的状态
4、通过clickhouse-client连接clickhouse数据库
clickhouse-client # or clickhouse-client --password if you set up a password.四 查看clickhouse配置文件以及设置密码
注意默认账号为default 密码为空
1. 查看配置文件
[root172 /]# cat /etc/clickhouse-server/config.xml内容较多只截取部分
!--display_nameproduction/display_name--!-- Port for HTTP API. See also https_port for secure connections.This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...)and by most of web interfaces (embedded UI, Grafana, Redash, ...).--http_port8123/http_port!-- Port for interaction by native protocol with:- clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier);- clickhouse-server with other clickhouse-servers for distributed query processing;- ClickHouse drivers and applications supporting native protocol(this protocol is also informally called as the TCP protocol);See also tcp_port_secure for secure connections.--tcp_port9000/tcp_port!-- Compatibility with MySQL protocol.ClickHouse will pretend to be MySQL for applications connecting to this port.--mysql_port9004/mysql_port!-- Compatibility with PostgreSQL protocol.ClickHouse will pretend to be PostgreSQL for applications connecting to this port.--postgresql_port9005/postgresql_port!-- HTTP API with TLS (HTTPS).You have to configure certificate to enable this interface.See the openSSL section below.--!-- https_port8443/https_port --!-- Native interface with TLS.You have to configure certificate to enable this interface.See the openSSL section below.--!-- tcp_port_secure9440/tcp_port_secure --!-- Native interface wrapped with PROXYv1 protocolPROXYv1 header sent for every connection.ClickHouse will extract information about proxy-forwarded client address from the header.--!-- tcp_with_proxy_port9011/tcp_with_proxy_port --!-- Port for communication between replicas. Used for data exchange.It provides low-level data access between servers.This port should not be accessible from untrusted networks.See also interserver_http_credentials.Data transferred over connections to this port should not go through untrusted networks.See also interserver_https_port.--interserver_http_port9009/interserver_http_port2. 设置密码
[root172 /]# vim /etc/clickhouse-server/users.xml如下为具体内容请注意password部分
?xml version1.0?
clickhouse!-- See also the files in users.d directory where the settings can be overridden. --!-- Profiles of settings. --profiles!-- Default settings. --default!-- Maximum memory usage for processing single query, in bytes. --max_memory_usage10000000000/max_memory_usage!-- How to choose between replicas during distributed query processing.random - choose random replica from set of replicas with minimum number of errorsnearest_hostname - from set of replicas with minimum number of errors, choose replicawith minimum number of different symbols between replicas hostname and local hostname(Hamming distance).in_order - first live replica is chosen in specified order.first_or_random - if first replica one has higher number of errors, pick a random one from replicas with minimum number of errors.--load_balancingrandom/load_balancing/default!-- Profile that allows only read queries. --readonlyreadonly1/readonly/readonly/profiles!-- Users and ACL. --users!-- If user name was not specified, default user is used. --default!-- See also the files in users.d directory where the password can be overridden.Password could be specified in plaintext or in SHA256 (in hex format).If you want to specify password in plaintext (not recommended), place it in password element.Example: passwordqwerty/password.Password could be empty.If you want to specify SHA256, place it in password_sha256_hex element.Example: password_sha256_hex65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5/password_sha256_hexRestrictions of SHA256: impossibility to connect to ClickHouse using MySQL JS client (as of July 2019).If you want to specify double SHA1, place it in password_double_sha1_hex element.Example: password_double_sha1_hexe395796d6546b1b65db9d665cd43f0e858dd4303/password_double_sha1_hexIf you want to specify a previously defined LDAP server (see ldap_servers in the main config) for authentication,place its name in server element inside ldap element.Example: ldapservermy_ldap_server/server/ldapIf you want to authenticate the user via Kerberos (assuming Kerberos is enabled, see kerberos in the main config),place kerberos element instead of password (and similar) elements.The name part of the canonical principal name of the initiator must match the user name for authentication to succeed.You can also place realm element inside kerberos element to further restrict authentication to only those requestswhose initiators realm matches it.Example: kerberos /Example: kerberosrealmEXAMPLE.COM/realm/kerberosHow to generate decent password:Execute: PASSWORD$(base64 /dev/urandom | head -c8); echo $PASSWORD; echo -n $PASSWORD | sha256sum | tr -d -In first line will be password and in second - corresponding SHA256.How to generate double SHA1:Execute: PASSWORD$(base64 /dev/urandom | head -c8); echo $PASSWORD; echo -n $PASSWORD | sha1sum | tr -d - | xxd -r -p | sha1sum | tr -d -In first line will be password and in second - corresponding double SHA1.--password设置自己的密码/password!-- List of networks with open access.To open access from everywhere, specify:ip::/0/ipTo open access only from localhost, specify:ip::1/ipip127.0.0.1/ipEach element of list has one of the following forms:ip IP-address or network mask. Examples: 213.180.204.3 or 10.0.0.1/8 or 10.0.0.1/255.255.255.02a02:6b8::3 or 2a02:6b8::3/64 or 2a02:6b8::3/ffff:ffff:ffff:ffff::.host Hostname. Example: server01.yandex.ru.To check access, DNS query is performed, and all received addresses compared to peer address.host_regexp Regular expression for host names. Example, ^server\d\d-\d\d-\d\.yandex\.ru$To check access, DNS PTR query is performed for peer address and then regexp is applied.Then, for result of PTR query, another DNS query is performed and all received addresses compared to peer address.Strongly recommended that regexp is ends with $All results of DNS requests are cached till server restart.--networksip::/0/ip/networks!-- Settings profile for user. --profiledefault/profile!-- Quota for user. --quotadefault/quota!-- User can create other users and grant rights to them. --!-- access_management1/access_management --/default/users!-- Quotas. --quotas!-- Name of quota. --default!-- Limits for time interval. You could specify many intervals with different limits. --interval!-- Length of interval. --duration3600/duration!-- No limits. Just calculate resource usage for time interval. --queries0/querieserrors0/errorsresult_rows0/result_rowsread_rows0/read_rowsexecution_time0/execution_time/interval/default/quotas
/clickhouse五、监听8123端口的服务 [root172 /]# netstat -tulpn | grep 8123 这将显示正在监听8123端口的服务以及它的进程IDPID
六、开放8123端口号
设置开放的端口号
[root172 /]# firewall-cmd --add-port8123/tcp --permanent重启防火墙
[root172 /]# firewall-cmd --reload查看当前已开放的端口号
[root172 /]# firewall-cmd --list-all七、通过数据库管理工具链接测试
1、连接测试报错如下
Connection refused: no further information
2、解决方案 出现如上问题的原因是因为配置文件中对于远程连接IP的设置的原因 通过如下命令查看配置文件
[root172 clickhouse-server]# cat config.xml如下为默认配置信息注意!-- listen_host::/listen_host -- !-- Listen specified address.Use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere.Notes:If you open connections from wildcard address, make sure that at least one of the following measures applied:- server is protected by firewall and not accessible from untrusted networks;- all users are restricted to subset of network addresses (see users.xml);- all users have strong passwords, only secure (TLS) interfaces are accessible, or connections are only made via TLS interfaces.- users without password have readonly access.See also: https://www.shodan.io/search?queryclickhouse--!-- listen_host::/listen_host --!-- Same for hosts without support for IPv6: --!-- listen_host0.0.0.0/listen_host --!-- Default values - try listen localhost on IPv4 and IPv6. --!--listen_host::1/listen_hostlisten_host127.0.0.1/listen_host--解决方案 把注释去掉修改完成后如下listen_host::/listen_host 通过如下命令修改配置文件目录为[root172 /]# cd /etc/clickhouse-server
[root172 clickhouse-server]# vim config.xml修改完成后保存并退出再次测试成功连接