rqlite安装、java客户端使用详细教程

安装

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]# ./rqlite -H 192.168.46.25 -p 4101
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 <file>                      Write database backup to SQLite file
.consistency [none|weak|strong]     Show or set read consistency level
.dump <file>                        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 <raft ID>                   Remove a node from the cluster
.restore <file>                     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 <file>                     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磁盘数据库

#创建tmpfs-文件系统
mount -t tmpfs -o size=5120m tmpfs /mnt/ramtmp

#将数据库文件保存到tmpfs文件系统中
./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😉

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值