当我们准备好了单台服务器环境配置之后,就可以正式安装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密钥,用于整个集群创建和验证证书
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,size=350GiB --http-addr=0.0.0.0:48080 --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,size=350GiB --http-addr=0.0.0.0:48081 --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,size=350GiB --http-addr=0.0.0.0:48082 --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 #页面访问端口--max-disk-temp-storage=10GiB
#可用于存储基于磁盘的临时文件的最大存储容量--external-io-dir
=/data_shares #指定外部目录 用于数据导入导出, NFS 模式,推荐使用NFS模式
更多信息详情,可以使用 hubble start --help 查看- RestartSec
RestartSec
=10 10s后重启- User
User
=hubble 设置用户
创建要用到的目录/data1/hubbledir/hubble1
(/data1/hubbledir/hubble2
,/data1/hubbledir/hubble3
同理)
mkdir -p /data1/hubbledir/hubble1
chown -R hubble:hubble /data1/hubbledir/hubble1
chmod 755 /data1/hubbledir/hubble1
使用root用户操作
chown hubble:hubble /etc/systemd/system/hubble1.service
chown hubble:hubble /etc/systemd/system/hubble2.service
chown hubble:hubble /etc/systemd/system/hubble3.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
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 '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 hubble1
systemctl status hubble2
systemctl status hubble3
使用root操作
systemctl enable hubble1
systemctl enable hubble2
systemctl enable hubble3