以下のVagrantfileを使用して、FoundationDBとPythonインターフェイスをインストールした仮想マシンを構築する
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.hostname = "ub1604foundationdb"
config.vm.provider :virtualbox do |vbox|
vbox.name = "ub1604foundationdb"
vbox.cpus = 4
vbox.memory = 4096
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
# private network
config.vm.network "private_network", ip: "192.168.55.103", :netmask => "255.255.255.0"
# bridge netwrok
config.vm.network "public_network", ip: "192.168.1.103", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
#localectl set-locale LANG=ja_JP.UTF-8
#localectl set-keymap jp106
apt-get update
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
# install FoundationDB
wget https://www.foundationdb.org/downloads/5.1.5/ubuntu/installers/foundationdb-clients_5.1.5-1_amd64.deb
wget https://www.foundationdb.org/downloads/5.1.5/ubuntu/installers/foundationdb-server_5.1.5-1_amd64.deb
dpkg -i foundationdb-clients_5.1.5-1_amd64.deb
dpkg -i foundationdb-server_5.1.5-1_amd64.deb
systemctl enable foundationdb
systemctl start foundationdb
wget https://www.foundationdb.org/downloads/5.1.5/bindings/python/foundationdb-5.1.5.tar.gz
tar xvfz foundationdb-5.1.5.tar.gz
cd foundationdb-5.1.5
python setup.py install
cd /home/vagrant
cat << EOF > test.py
import fdb
fdb.api_version(510)
db = fdb.open()
test = fdb.directory.create_or_open(db, ('test',))
db[test['foo']] = 'hello world!'
print(db[test['foo']])
EOF
python test.py
SHELL
end
0 件のコメント:
コメントを投稿