SQLite可以和GlusterFS一起使用吗?

我想build立一个基于GlusterFS的自动文件复制(AFR)的分布式存储,以容错的方式存储用户文件。

但是我也想从多个客户端访问存储在GlusterFS卷上(并在多个服务器上复制)的SQLite3数据库。 可能吗? 几个客户之间的协调能力是否得到妥善处理,不会导致腐败?

还是有更好的替代GlusterFS分配SQLite3数据库?

    即使在复制模式下,GlusterFS也支持完整的POSIX文件/logging级locking。 它应该工作正常。

    我写了一个sqlite_shared_fs_check.sh脚本来模拟sqlite3数据库的许多读写操作。 它应该运行在几个客户端机器上的同一个GlusterFS目录中。

    我testing了以下configuration:

    • GlusterFS 3.2和sqlite3 3.5.9(Ubuntu 8.10)。 数据库没有被损坏。
    • GlusterFS 3.2和sqlite3 3.6.22-1(Ubuntu 10.04)。 TBD。
    • Ext3和sqlite3 3.5.9(ubuntu 8.10):testing是从两个terminal窗口一次运行。 testing完成没有任何问题。

    最后的testing结果(ext3 + sqlite3)把POSIXlocking不合格归咎于GlusterFS 3.2。

    这是我用来做testing的脚本:

    #!/bin/bash function ErrorExit() { echo Error: $@ exit 1 } # Microseconds timeout=5000 if [ ! -f test.sqlite3 ]; then touch test.sqlite3 echo 'create table test1 (id integer primary key autoincrement,datetime text,hostname text);' | sqlite3 test.sqlite3 || ErrorExit "Create" fi if [ ! -f /tmp/insert.sql ]; then echo .timeout $timeout > /tmp/insert.sql echo "insert into test1 values (NULL,datetime('now','localtime'),'$HOSTNAME');" >> /tmp/insert.sql fi if [ ! -f select.sql ]; then echo .timeout $timeout > select.sql echo "select * from test1 order by id desc limit 1;" >> select.sql fi if [ ! -f count.sql ]; then echo .timeout $timeout > count.sql echo "select count(*) from test1;" >> count.sql fi i=1 while [ $i -le 1000 ]; do lockfile-create --retry 20 test.sqlite3 || echo -n "?" sqlite3 test.sqlite3 < /tmp/insert.sql lockfile-remove test.sqlite3 # Sleep a bit to allow other users sleep 0.5 lockfile-create --retry 20 test.sqlite3 || echo -n "?" sqlite3 test.sqlite3 < select.sql >/dev/null || ErrorExit select [$i] sqlite3 test.sqlite3 < count.sql >/dev/null || ErrorExit count [$i] lockfile-remove test.sqlite3 let i++ echo -n "." done 

    请注意,我不得不使用lockfile-create实用程序来获取数据库上的locking,因为sqlite的内部locking不够可靠。

    我认为locking可能是其中的难点。 想象一下,写入过程必须在写入sqlite3数据库(文件)的时候locking它。 问题是你需要什么水平的并发? 我认为你将面临一个写绑定应用程序可能的性能问题。

    在一个客户端一次可以写入文件的地方(实际上),您将遇到locking问题。