当我们准备好了集群环境服务配置之后,就可以正式安装hubble集群了
使用root用户操作
tar -zxvf hubble.tar.gz
/usr/local/bin
目录下
cp -r hubble /usr/local/bin/
/usr/local/bin/hubble
到集群所有节点的该目录下scp -r /usr/local/bin/hubble node:/usr/local/bin/hubble
在集群每个节点上,使用root用户操作
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
mkdir -p /data/hubbledir ## 数据存储目录,按集群存储规划创建
chown -R hubble:hubble /data/hubbledir
注意:
certs
生成CA证书以及所有节点和客户端证书
mysafedirectory
用于创建签名证书CA密钥,用于整个集群创建和验证证书
在集群每个节点上,使用root用户操作
vi /etc/systemd/system/hubble.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,hubble02:15432,hubble03:15432,hubble04:15432,hubble05:15432 --cache=30GiB --max-sql-memory=10GiB --store=path=/data3/hubbledir/hubble,size=350GiB --store=path=/data4/hubbledir/hubble,size=350GiB --store=path=/data5/hubbledir/hubble,size=350GiB --http-addr=0.0.0.0:48080 --max-disk-temp-storage=10GiB --log-config-file=certs/logs.yaml --external-io-dir=/data_shares
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hubble
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 #页面访问端口--max-disk-temp-storage=10GiB
#可用于存储基于磁盘的临时文件的最大存储容量--log-config-file=logs.yaml
#或 --log="$(cat logs.yaml)" 或 --log="sinks: {file-groups: {ops: {channels: [OPS, HEALTH]}}}" ## 请注意,必须保留内联空格--external-io-dir
=/data_shares #指定外部目录 用于数据导入导出, NFS 模式,推荐使用NFS模式
更多信息详情,可以使用 hubble start --help 查看- RestartSec
RestartSec
=10 10s后重启- User
User
=hubble 设置用户
mkdir -p /data/hubble3.10/hubble-data/logs
chown -R hubble:hubble /data/hubble3.10/hubble-data/logs
chmod 755 /data/hubble3.10/hubble-data/logs
--store=path在配置文件中所用到的目录,比如 /data3/hubbledir/hubble,可以参考三个语句进行创建
vi /var/lib/hubble/certs/logs.yaml
# configuration after validation:
file-defaults:
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false ## 默认情况下是禁用的。启用后,redact自动编辑日志输出中的敏感数据。
redactable: true
exit-on-error: true
auditable: false
fluent-defaults:
filter: INFO
format: json-fluent-compact
redact: false
redactable: true
exit-on-error: false
auditable: false
sinks:
file-groups:
default:
channels: [DEV, OPS, HEALTH, SQL_SCHEMA, USER_ADMIN, PRIVILEGES]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
pebble:
channels: [STORAGE]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
sql-audit:
channels: [SENSITIVE_ACCESS]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: false
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
sql-auth:
channels: [SESSIONS]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: false
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
sql-exec:
channels: [SQL_EXEC]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
sql-slow:
channels: [SQL_PERF]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
sql-slow-internal-only:
channels: [SQL_INTERNAL_PERF]
dir: /data/hubble3.10/hubble-data/logs
max-file-size: 10MiB
max-group-size: 100MiB
buffered-writes: true
filter: INFO
format: hubdb-v2
redact: false
redactable: true
exit-on-error: true
stderr:
channels: all
filter: NONE
format: hubdb-v2-tty
redact: false
redactable: true
exit-on-error: true
capture-stray-errors:
enable: true
dir: /data/hubble3.10/hubble-data/logs
max-group-size: 100MiB
在集群每个节点上,使用root用户操作
## 修改 hubble.service 文件的用户权限
chown hubble:hubble /etc/systemd/system/hubble.service
## 添加普通用户权限
vi /etc/sudoers
## Same thing without a password
hubble ALL=(root) NOPASSWD:/usr/bin/systemctl start hubble,/usr/bin/systemctl stop hubble,/usr/bin/systemctl restart hubble,/usr/bin/systemctl enable hubble,/usr/bin/systemctl disable hubble,/usr/bin/systemctl daemon-reload
:wq!
之后的所有操作均在license执行注册的节点上使用普通用户操作
cd /var/lib/hubble/
hubble cert create-ca --certs-dir=certs --ca-key=mysafedirectory/ca.key #生成本机证书和密钥
cd /var/lib/hubble/
hubble cert create-node hubble02 192.168.1.12 --certs-dir=certs --ca-key=mysafedirectory/ca.key --overwrite
scp -r certs/ hubble@hubble02:/var/lib/hubble/
scp -r mysafedirectory/ hubble@hubble02:/var/lib/hubble/
注意:
create-node hubble02 192.168.1.12
创建其他节点的证书
基于ca.key 生成其他节点证书
scp
分发到对应的节点上
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
使用hubble用户操作
sudo systemctl daemon-reload
sudo systemctl start hubble
使用hubble用户操作
hubble init --certs-dir=/var/lib/hubble/certs --host=hubble01:15432
注意:
--host=
hubble01:15432 指定主机地址,集群中任意一台服务器
使用hubble用户操作
hubble sql --certs-dir=/var/lib/hubble/certs --host=hubble01:15432 #连接
show databases;
create user hubble with password 'hubble';
grant admin to hubble with admin option;
set cluster setting kv.snapshot_rebalance.max_rate='32MiB';
set cluster setting kv.snapshot_recovery.max_rate='32MiB';
set cluster setting sql.distsql.temp_storage.workmem = '2GiB'
注意:
--host
=hubble01 指定主机地址,集群中任意一台服务器
https://192.168.1.11:48080/
systemctl status hubble
systemctl enable hubble ## root用户操作
sudo systemctl enable hubble ## hubble用户操作