当我们准备好了集群环境服务配置之后,就可以正式安装Hubble集群了。
使用root用户操作
tar -zxvf hubble-3.23.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 -p /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 --certs-dir=certs --listen-addr=0.0.0.0:15432 --advertise-host=hubble01 --join=hubble01:15432,hubble02:15432,hubble03:15432,hubble04:15432,hubble05:15432 --cache=30GiB --max-sql-memory=10GiB --store=path=/data/hubbledir/,size=350GiB --store=path=/data4/hubbledir/,size=350GiB --http-addr=0.0.0.0:48080 --max-disk-temp-storage=10GiB
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hubble
User=hubble
LimitNOFILE=1000000
[Install]
WantedBy=default.target注意:
- ExecStart=
--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,size=350GiB #设置数据存储目录 ,size可以设置占用空间大小--http-addr=0.0.0.0:48080 #页面访问端口--max-disk-temp-storage=10GiB#可用于存储基于磁盘的临时文件的最大存储容量--external-io-dir=/data_shares #指定外部目录 用于数据导入导出, NFS模式,推荐使用NFS模式
更多信息详情,可以使用 hubble start --help 查看- RestartSec
RestartSec=10 10s后重启- User
User=hubble 设置用户
在集群每个节点上,使用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 --overwritescp -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 --overwritecd /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 hubblesystemctl enable hubble ## root用户操作
sudo systemctl enable hubble ## hubble用户操作