安装
https://github.com/rqlite/rqlite/releases/tag/v6.10.2
下载最新版本
将安装包解压即可使用零配置
mkdir -p /opt/rqlite
cd /opt/rqlite
wget https://github.com/rqlite/rqlite/releases/download/v6.10.2/rqlite-v6.10.2-linux-amd64.tar.gz
tar -zxvf rqlite-v6.10.2-linux-amd64.tar.gz
cd rqlite
启动服务
./rqlited -http-addr 192.168.46.25:4101 -raft-addr 192.168.46.25:4102 /opt/rqlite/rqlite/data
-http-addr
:对外 http请求暴露的ip
-raft-addr: 集群中各个节点通信的ip,不可进行 http请求
/opt/rqlite/rqlite/data:为数据库存放位置
启动命令行操作
./rqlite -H 192.168.46.25 -p 4101
注意:host需要与 -http-addr
一致
.help 呼出帮助信息
[root@store rqlite]
Welcome to the rqlite CLI. Enter ".help" for usage hints.
Version v6.9.0, commit 6751b5fc4a88b95c47cb5e97042ae3fd67e46616, branch master
Connected to rqlited version v6.9.0
192.168.46.25:4101> .help
.backup Write database backup to SQLite file
.consistency [none|weak|strong] Show or set read consistency level
.dump Dump the database in SQL text format to a file
.expvar Show expvar (Go runtime) information for connected node
.help Show this message
.indexes Show names of all indexes
.nodes Show connection status of all nodes in cluster
.ready Show ready status for connected node
.remove Remove a node from the cluster
.restore Restore the database from a SQLite dump file
.schema Show CREATE statements for all tables
.status Show status and diagnostic information for connected node
.sysdump Dump system diagnostics to a file for offline analysis
.tables List names of tables
基本操作
1、查看数据库中存在的表 .tables
192.168.46.25:4101> .tables
+--------------+
| name |
+--------------+
| BakHistory |
+--------------+
| I2FileStatus |
+--------------+
| DiskInfos |
+--------------+
2、查看表结构 .schema
192.168.46.25:4101> .schema
192.168.46.25:4101> .nodes
192.168.46.25:4102:
leader: true
time: 0.000021073
api_addr: http://192.168.46.25:4101
addr: 192.168.46.25:4102
reachable: true
集群操作
1、将节点加入集群,可以加入多个节点
./rqlited -http-addr 192.168.46.11:4105 -raft-addr 192.168.46.11:4106 -join http://192.168.46.25:4101 /opt/rqlite/rqlite/data1
2、查看集群节点状态 .nodes
192.168.46.25:4101> .nodes
192.168.46.11:4106:
leader: false
time: 0.001503349
api_addr: http://192.168.46.11:4105
addr: 192.168.46.11:4106
reachable: true
192.168.46.25:4102:
time: 0.000031826
api_addr: http://192.168.46.25:4101
addr: 192.168.46.25:4102
reachable: true
leader: true
3、将节点踢出集群
注意
,踢出节点的IP对应 -raft-addr
.remove 192.168.46.11:4106
再次查看集群状态,发现刚踢出的那个节点已经不存在了
192.168.46.25:4101> .nodes
192.168.46.25:4102:
addr: 192.168.46.25:4102
reachable: true
leader: true
time: 0.000015031
api_addr: http://192.168.46.25:4101
高级操作
结合tmpfs-内存文件系统与SQLite磁盘数据库
mount -t tmpfs -o size=5120m tmpfs /mnt/ramtmp
./rqlited -http-addr 192.168.46.25:4101 -raft-addr 192.168.46.25:4102 /mnt/ramtmp
详细操作请看我的另一篇文章rqlite与sqlite性能测试及最佳实践
java客户端操作
https://github.com/999bug/rqlite-java
尽情star😉
Original: https://blog.csdn.net/qq_40965479/article/details/122497713
Author: AKA石头
Title: rqlite安装、java客户端使用详细教程
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/816881/
转载文章受原作者版权保护。转载请注明原作者出处!