簡(jiǎn)介
FoudationDB是蘋果公司近期開(kāi)源的一款分布式庆捺,支持事務(wù)型的key-value數(shù)據(jù)庫(kù)她我。
安裝
- 準(zhǔn)備A,B兩臺(tái)在同一網(wǎng)段內(nèi)的Ubuntu服務(wù)器(我用了兩個(gè)ECS)
- 下載安裝Server , Client 和 Python版的API
$ wget https://www.foundationdb.org/downloads/5.1.7/ubuntu/installers/foundationdb-clients_5.1.7-1_amd64.deb
$ wget https://www.foundationdb.org/downloads/5.1.7/ubuntu/installers/foundationdb-server_5.1.7-1_amd64.deb
$ wget https://www.foundationdb.org/downloads/5.1.7/bindings/python/foundationdb-5.1.7.tar.gz
$ sudo dpkg -i foundationdb-server_5.1.7-1_amd64.deb foundationdb-clients_5.1.7-1_amd64.deb
$ tar -zxf foundationdb-5.1.7.tar.gz
$ cd foundationdb-5.1.7 && python setup.py install
此時(shí)AB之間不能相互訪問(wèn)殿较,需要配置cluster
- 配置訪問(wèn)權(quán)限
- 配置B機(jī)器使其對(duì)外可用
$ sudo /usr/lib/foundationdb/make_public.py /etc/foundationdb/fdb.cluster is now using address 172.17.xxx.xxx
- 將B的配置文件
/etc/foundationdb/fdb.cluster
覆蓋掉A的配置后重啟A的服務(wù)
$ sudo service foundationdb restart
測(cè)試
- 在B機(jī)器中寫入一個(gè)key-value
$ python
>>> import fdb
>>> fdb.api_version(510)
>>> db = fdb.open()
>>> db['hello'] = 'world'
>>> db['hello']
'world'
- 在A機(jī)器中讀取
$ python
>>> import fdb
>>> fdb.api_version(510)
>>> db = fdb.open()
>>> db['hello']
'world'
- 在A機(jī)器中寫入一個(gè)key-value
>>> db['hi'] = 'foundationDB'
>>> db['hi']
'foundationDB'
- 在B機(jī)器中讀取
>>> db['hi']
'foundationDB'
參考
- 項(xiàng)目地址: https://github.com/apple/foundationdb
- 文檔地址: https://apple.github.io/foundationdb/index.html
"Knowledge is of no value unless you put it into practice" -- Anton Chekhov