FoundationDB
FoundationDB是Apple维护的NoSQL资料库。
安装
在Ubuntu下可以使用官方打包好的deb安装7.1版:
cd /tmp; wget -c https://github.com/apple/foundationdb/releases/download/7.1.65/foundationdb-clients_7.1.65-1_amd64.deb; sudo dpkg -i foundationdb-clients_7.1.65-1_amd64.deb; wget -c https://github.com/apple/foundationdb/releases/download/7.1.65/foundationdb-server_7.1.65-1_amd64.deb; sudo dpkg -i foundationdb-server_7.1.65-1_amd64.deb
也可以安装7.3版,但我无法跑起cluster模式:
cd /tmp; wget -c https://github.com/apple/foundationdb/releases/download/7.3.43/foundationdb-clients_7.3.43-1_amd64.deb; sudo dpkg -i foundationdb-clients_7.3.43-1_amd64.deb; wget -c https://github.com/apple/foundationdb/releases/download/7.3.43/foundationdb-server_7.3.43-1_amd64.deb; sudo dpkg -i foundationdb-server_7.3.43-1_amd64.deb
设定
Cluster
这边假设有三台机器,先把FoundationDB跑在Public Interface上(预设会跑在127.0.0.1
上):
sudo python3 /usr/lib/foundationdb/make_public.py
sudo service foundationdb restart
然后修改/etc/foundationdb/fdb.cluster
档案,把第一个档案复制到其他两个,然后重启:
echo "username:password@192.168.1.1:4500" | sudo tee /etc/foundationdb/fdb.cluster
sudo service foundationdb restart
接著进入fdbcli设定成SSD:
configure perpetual_storage_wiggle=1 storage_migration_type=gradual
configure ssd
然后将Redundancy mode设定成double
(可以是single
或是triple
):
configure double
最后设定coordinators:
coordinators 192.168.1.1:4500 192.168.1.2:4500 192.168.1.3:4500
结束后可以用status
指令看cluster的状态。
测试
先进入CLI介面:
fdbcli
在CLI的预设是唯独模式,透过指令允许送出写入操作:
writemode on
接著可以进行操作:
get a/b/c
set a/b/c foo
get a/b/c
clear a/b/c
get a/b/c