以下のVagrantfileを使用して、H2 Databaseがインストールされた仮想マシン(Debian Stretch/9.3)を構築する事ができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/debian-9.3"
config.vm.hostname = "db93h2db"
config.vm.provider :virtualbox do |vbox|
vbox.name = "db93h2db"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.107", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.107", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install task-japanese
sed -i -e 's/# ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
update-locale LANG=ja_JP.UTF-8
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 java
apt-get -y install openjdk-8-jdk
# download h2 database
apt-get -y install unzip
wget http://www.h2database.com/h2-2018-03-18.zip
unzip h2-2018-03-18.zip
mv h2 /opt
mkdir /opt/h2/data
# setup console as service
cat << EOF > /opt/h2/bin/h2env
H2CUSTOMJARS=
EOF
cat << EOF > /etc/systemd/system/h2.service
[Unit]
Description=H2 database
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/opt/h2/bin/h2env
WorkingDirectory=/opt/h2
ExecStart=/usr/bin/java -cp "/opt/h2/bin/h2-1.4.197.jar:\\$H2CUSTOMJARS" org.h2.tools.Console -tcp -tcpAllowOthers -web -webAllowOthers -pg -pgAllowOthers -baseDir /opt/h2/data
ExecStop=/usr/bin/kill -3 \\${MAINPID}
[Install]
WantedBy=multi-user.target
EOF
systemctl enable h2.service
systemctl start h2.service
echo '--------------------------------------------------'
echo 'access URL: http://192.168.55.107:8082/'
echo 'username: sa default password: sa'
echo 'Driver class: org.h2.Driver'
echo 'JDBC URL: jdbc:h2:tcp://192.168.55.107/opt/h2/test'
SHELL
end
〇H2 Databaseの画面
○関連情報
・H2 Databaseに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿