〇DBeaverの画面
このVMにはXRDPもインストールされているので、Windowsのリモートデスクトップで接続することができます。ユーザ名はvagrant、パスワードもvagrantでログオンできます。
〇構築方法
以下のVagrantfileを使用して、DBeaverとOpenJDK11、CockroachDB, Gnome Desktop環境、XRDPをインストールした仮想マシンを構築できます。
Insecureモードで接続するには、ホストに192.168.1.101、ユーザにtestを指定、Edit Driver SettingsでAllow Empty Passwordにチェックをつけます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-8.1"
config.vm.hostname = "co81gnomedbeavercockroachdb"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co81gnomedbeavercockroachdb"
vbox.gui = true
vbox.cpus = 2
vbox.memory = 4096
end
config.vm.network "public_network", ip: "192.168.1.101", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
dnf -y install langpacks-ja
localectl set-locale LANG=ja_JP.UTF-8
dnf install -y epel-release
dnf check-update
dnf -y update
timedatectl set-timezone Asia/Tokyo
dnf -y groupinstall "Server with GUI" "Input Methods"
dnf -y install xrdp ibus-mozc
# hide dialogs
sudo sh -c "echo 'X-GNOME-Autostart-enabled=false' >> /etc/xdg/autostart/gnome-welcome-tour.desktop"
systemctl set-default graphical.target
systemctl enable xrdp.service
systemctl start xrdp.service
# install cockroachdb
cd /opt
wget -qO- https://binaries.cockroachdb.com/cockroach-v19.2.5.linux-amd64.tgz | tar xvz
mv cockroach-v19.2.5.linux-amd64 /opt/cockroach
/opt/cockroach/cockroach init --insecure --store=node1 --host=192.168.1.101:26257
cat << EOF > /etc/systemd/system/cockroachdb.service
[Unit]
Description=cockroachdb
Requires=network.target
[Service]
Type=forking
WorkingDirectory=/opt/cockroach
ExecStart=/opt/cockroach/cockroach start --insecure --host=192.168.1.101 --background
ExecStop=/opt/cockroach/cockroach quit
[Install]
WantedBy=multi-user.target
EOF
systemctl enable cockroachdb.service
systemctl start cockroachdb.service
# execute sample sql statements
/opt/cockroach/cockroach sql --insecure --host=192.168.1.101 << EOF
CREATE DATABASE test;
CREATE USER IF NOT EXISTS test;
GRANT ALL ON DATABASE test TO test;
CREATE TABLE test.messages (id INT PRIMARY KEY, message varchar(100));
INSERT INTO test.messages VALUES (1, 'hello world.');
select * from test.messages;
EOF
# install openjdk
dnf install -y java-11-openjdk
# install DBeaver
cd /opt
wget https://dbeaver.io/files/dbeaver-ce-latest-linux.gtk.x86_64.tar.gz
tar xvfz dbeaver-ce-latest-linux.gtk.x86_64.tar.gz
cat << EOF > /usr/share/applications/dbeaver.desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/opt/dbeaver/dbeaver
Icon=/opt/dbeaver/dbeaver.png
Name=DBeaver
Categories=Graphics;
EOF
telinit 5
SHELL
end