〇DBeaverの画面
このVMにはXRDPもインストールされているので、Windowsのリモートデスクトップで接続することができます。ユーザ名はvagrant、パスワードもvagrantでログオンできます。
〇構築方法
以下のVagrantfileを使用して、DBeaverとOpenJDK11、PostgreSQL12, Xfce Desktop環境、XRDPをインストールした仮想マシンを構築できます。
データベース接続作成時にデータベース名:test、ユーザ名:test、パスワード:testを指定します。ドライバはデータベース接続作成時にダウンロードできます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/debian-10"
config.vm.hostname = "db10xfcepg12dbeaver"
config.vm.network "public_network", ip:"192.168.55.109", :netmask => "255.255.255.0"
config.vm.provider :virtualbox do |vbox|
vbox.name = "db10xfcepg12dbeaver"
vbox.gui = true
vbox.cpus = 2
vbox.memory = 4096
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install task-japanese gawk
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
cat << EOF > /etc/default/keyboard
XKBMODEL="pc106"
XKBLAYOUT="jp"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
EOF
cat << EOF > /home/vagrant/.xsessionrc
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
sed -i -e "s/^EnabledIMList.*$/EnabledIMList=fcitx-keyboard-jp:True,mozc:True,fcitx-keyboard-us:False/" /home/vagrant/.config/fcitx/profile
fcitx-remote -r
fcitx -r -d
#startxfce4 &
EOF
chown vagrant:vagrant .xsessionrc
apt-get -y install xrdp fcitx-mozc task-xfce-desktop tigervnc-standalone-server
im-config -n fcitx
sudo -u vagrant bash -i -c "export DISPLAY=:0.0 && fcitx -r"
cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.org
cat /etc/xrdp/xrdp.ini.org | gawk '/\\[Globals\\]/,/\\[Xorg\\]/' | sed -e 's/\\[Xorg\\]//' > /etc/xrdp/xrdp.ini
cat << EOF >> /etc/xrdp/xrdp.ini
[Xvnc]
name=Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
EOF
systemctl restart xrdp
systemctl enable xrdp
# install postgresql
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get -y install postgresql-12
echo "listen_addresses='*'" >> /etc/postgresql/12/main/postgresql.conf
echo "host all all 127.0.0.1/32 password" >> /etc/postgresql/12/main/pg_hba.conf
echo "host all all 192.168.1.0/24 password" >> /etc/postgresql/12/main/pg_hba.conf
echo "host all all 192.168.55.0/24 password" >> /etc/postgresql/12/main/pg_hba.conf
systemctl restart postgresql.service
su - postgres << EOF
createdb -T template0 --locale=ja_JP.UTF-8 --encoding=UTF8 test
psql -c "
alter user postgres with password 'postgres';
create user test with password 'test';
grant all privileges on database test to test;
"
EOF
export PGPASSWORD=test
psql -h localhost -d test -U test -c "
create table messages (message_id integer not null, message varchar(100));
insert into messages values (1, 'hello world.');
insert into messages values (2, 'test message.');
"
EOF
echo "postgres:postgres" | chpasswd
systemctl restart postgresql.service
# install OpenJDK11
apt install -y openjdk-11-jdk
# 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
Name=DBeaver
Categories=Development;
Icon=/opt/dbeaver/icon.xpm
EOF
init 5
SHELL
end