VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.3"
config.vm.hostname = "h2db"
config.vm.provider :virtualbox do |vbox|
vbox.name = "h2db"
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.86", :netmask => "255.255.255.0"
# bridge netwrok
config.vm.network "public_network", ip: "192.168.1.86", :netmask => "255.255.255.0"
config.vm.network "forwarded_port", guest:22, host:19022, id:"ssh"
config.vm.provision "shell", inline: <<-SHELL
yum -y install unzip
# install JDK
yum -y install java-1.8.0-openjdk
# download h2 database
export h2db=h2-2017-06-10.zip
wget http://www.h2database.com/$h2db
# install h2 database
unzip $h2db
echo 'webAllowOthers = true' > ~root/.h2.server.properties
mv h2 /opt
# setup console as service
cp /vagrant/h2 /etc/sysconfig
cp /vagrant/h2.service /etc/systemd/system
systemctl enable h2.service
systemctl start h2.service
echo 'access URL: http://192.168.55.86:8082/'
echo 'username: sa default password: sa'
echo 'Driver class: org.h2.Driver
echo 'JDBC URL: jdbc:h2:tcp://192.168.55.86/~/test'
SHELL
end
h2.service
[Unit]
Description=H2 database
After=syslog.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/h2
WorkingDirectory=/opt/h2
ExecStart=/bin/java -cp "/opt/h2/bin/h2-1.4.196.jar:$H2CUSTOMJARS" org.h2.tools.Console
ExecStop=/bin/kill -3 ${MAINPID}
[Install]
WantedBy=multi-user.target
h2
H2CUSTOMJARS=
○関連情報
・H2 Databaseに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿