当我们准备好了单台服务器环境配置之后,就可以正式安装hubble单机版本了
tar -zxvf hubble.tar.gz
/usr/local/bin
目录下
cp -r hubble /usr/local/bin/
mkdir /var/lib/hubble
mkdir /var/lib/hubble/certs
mkdir /var/lib/hubble/mysafedirectory
chown hubble:hubble -R /var/lib/hubble
chown -R hubble:hubble /usr/local/bin/hubble
chmod 711 /usr/local/bin/hubble
注意:
certs
生成CA证书以及所有节点和客户端证书
mysafedirectory
用于创建签名证书CA密钥,用于整个集群创建和验证证书
cd /var/lib/hubble
/usr/local/bin/hubble license machinecode --certs-dir=certs #执行后会生成/var/lib/hubble/certs/BDPMACHINE.txt文件机器码
/usr/local/bin/hubble license register --certs-dir=/var/lib/hubble/certs
注意:
有部分测试环境不带license,可以跳过 license注册激活
vi /etc/systemd/system/hubble1.service
[Unit]
Description=Hubble Database cluster
Requires=network.target
[Service]
Type=notify
WorkingDirectory=/var/lib/hubble
ExecStart=/usr/local/bin/hubble start --locality=country=cn,region=ch-beijin,datacenter=tianyun,rack=1,node=1 --certs-dir=certs --listen-addr=hubble01:15432 --advertise-host=hubble01 --join=hubble01:15432,hubble01:15433,hubble01:15434 --cache=30GiB --max-sql-memory=10GiB --store=path=/data1/hubbledir/hubble1,attrs=ssd,size=350GiB,rocksdb=write_buffer_size=134217728 --http-addr=0.0.0.0:48080 --sql-audit-dir=/data/hubbledir/auditdir1 --log-dir=/data/hubbledir/logs1 --log-dir-max-size=1GiB --external-io-dir=/data_shares
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hubble1
User=hubble
LimitNOFILE=1000000
[Install]
WantedBy=default.target
vi /etc/systemd/system/hubble2.service
[Unit]
Description=Hubble Database cluster
Requires=network.target
[Service]
Type=notify
WorkingDirectory=/var/lib/hubble
ExecStart=/usr/local/bin/hubble start --locality=country=cn,region=ch-beijin,datacenter=tianyun,rack=1,node=2 --certs-dir=certs --listen-addr=hubble01:15433 --advertise-host=hubble01 --join=hubble01:15432,hubble01:15433,hubble01:15434 --cache=30GiB --max-sql-memory=10GiB --store=path=/data1/hubbledir/hubble2,attrs=ssd,size=350GiB,rocksdb=write_buffer_size=134217728 --http-addr=0.0.0.0:48081 --sql-audit-dir=/data/hubbledir/auditdir2 --log-dir=/data/hubbledir/logs2 --log-dir-max-size=1GiB --external-io-dir=/data_shares
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hubble2
User=hubble
LimitNOFILE=1000000
[Install]
WantedBy=default.target
vi /etc/systemd/system/hubble3.service
[Unit]
Description=Hubble Database cluster
Requires=network.target
[Service]
Type=notify
WorkingDirectory=/var/lib/hubble
ExecStart=/usr/local/bin/hubble start --locality=country=cn,region=ch-beijin,datacenter=tianyun,rack=1,node=3 --certs-dir=certs --listen-addr=hubble01:15434 --advertise-host=hubble01 --join=hubble01:15432,hubble01:15433,hubble01:15434 --cache=30GiB --max-sql-memory=10GiB --store=path=/data1/hubbledir/hubble3,attrs=ssd,size=350GiB,rocksdb=write_buffer_size=134217728 --http-addr=0.0.0.0:48082 --sql-audit-dir=/data/hubbledir/auditdir3 --log-dir=/data/hubbledir/logs3 --log-dir-max-size=1GiB --external-io-dir=/data_shares
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hubble3
User=hubble
LimitNOFILE=1000000
[Install]
WantedBy=default.target
注意:
- ExecStart=
--locality
=country=cn,region=ch-beijin,datacenter=tianyun,rack=1,node=1 #设置区域 可以设置国家、地区、数据中心、机架、节点ID--certs-dir
=certs #设置证书--listen-addr
=hubble01:15432 #监听地址和端口--advertise-host
=hubble01 #当前节点的主机地址--join
=hubble01:15432,hubble02:15432,hubble03:15432,hubble04:15432,hubble05:15432 #集群中的节点--cache
=30GiB #缓存大小设置--max-sql-memory
=10GiB #最大查询过程中所占用的内存大小,可以使用%或者容量大小限制内存使用情况--store=path
=/data3/hubbledir/hubble,attrs=ssd,size=350GiB,rocksdb=write_buffer_size=134217728 #设置数据存储目录 ,size可以设置占用空间大小(选填),attrs 设置硬盘类型:转速, 可以设置rocksdb方式写入同步--http-addr
=0.0.0.0:48080 #页面访问端口--sql-audit-dir
=/data/hubbledir/auditdir #审计日志目录--log-dir
=/data/hubbledir/logs #日志输出目录--log-dir-max-size
=1GiB #设置日志文件生成大小--max-disk-temp-storage=10GiB
#可用于存储基于磁盘的临时文件的最大存储容量--external-io-dir
=/data_shares #指定外部目录 用于数据导入导出, NFS 模式,推荐使用NFS模式
更多信息详情,可以使用 hubble start --help 查看- RestartSec
RestartSec
=10 10s后重启- User
User
=hubble 设置用户
使用root用户操作
chown hubble:hubble /etc/systemd/system/hubble.service
vi /etc/sudoers
##Allows people in group wheel to run all commands
hubble ALL=(root) NOPASSWD:/usr/bin/systemctl start hubble1,/usr/bin/systemctl stop hubble1,/usr/bin/systemctl restart hubble1,/usr/bin/systemctl enable hubble1,/usr/bin/systemctl disable hubble1,/usr/bin/systemctl daemon-reload,/usr/bin/systemctl start hubble2,/usr/bin/systemctl stop hubble2,/usr/bin/systemctl restart hubble2,/usr/bin/systemctl enable hubble2,/usr/bin/systemctl disable hubble2,/usr/bin/systemctl start hubble3,/usr/bin/systemctl stop hubble3,/usr/bin/systemctl restart hubble3,/usr/bin/systemctl enable hubble3,/usr/bin/systemctl disable hubble3
:wq!
cd /var/lib/hubble/
hubble cert create-ca --certs-dir=certs --ca-key=mysafedirectory/ca.key #生成本机证书和密钥
cd /var/lib/hubble/
hubble cert create-node hubble01 192.168.1.11 --certs-dir=certs --ca-key=mysafedirectory/ca.key --overwrite
cd /var/lib/hubble/
hubble cert create-client root --certs-dir=certs --ca-key=mysafedirectory/ca.key --overwrite # root的,也可以生成其他账户的
注意:
如果在执行create-client客户端授权时,有的license申请期限时常较少,会出现"Error: failed to generate client certificate and key: xxx key: CA lifetime is 2364.193159h, shorter than the requested 43920.000000h. Renew CA certificate, or rerun with--lifetime=2364h
for a shorter duration" 需要后面在执行命令后面添加hubble cert create-client root --certs-dir=certs --ca-key=mysafedirectory/ca.key --overwrite--lifetime=2364h
sudo systemctl daemon-reload
sudo systemctl start hubble1
sudo systemctl start hubble2
sudo systemctl start hubble3
注意:
使用hubble用户执行
hubble init --certs-dir=/var/lib/hubble/certs --host=hubble01:15432
注意:
--host=
hubble01:15432 指定主机地址,集群中任意一台服务器
hubble sql --certs-dir=/var/lib/hubble/certs --host=hubble01 #连接
show databases;
create user hubble with password 'Sjk-Qkl^2021379';
grant admin to hubble with admin option;
set cluster setting kv.snapshot_rebalance.max_rate='10GiB';
set cluster setting kv.snapshot_recovery.max_rate='10GiB';
set cluster setting sql.distsql.temp_storage.workmem = '2GiB'
注意:
--host
=hubble01 指定主机地址,集群中任意一台服务器
https://192.168.1.11:48080/
systemctl status hubble1
systemctl status hubble2
systemctl status hubble3
systemctl enable hubble1
systemctl enable hubble2
systemctl enable hubble3
注意:
使用root操作