〇pgwebの画面
〇構築方法
以下のVagrantfileを使用して、pgwebとPostgreSQL12をインストールした仮想マシン(CentOS 8.1)を構築する事ができます。
仮想マシン構築後、ブラウザからhttp://<仮想マシンのアドレス>:8080/にアクセスします。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-8.1"
config.vm.hostname = "co81pgwebpg12"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co81pgwebpg12"
vbox.gui = true
vbox.cpus = 2
vbox.memory = 4096
end
config.vm.network "private_network", ip: "192.168.55.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
# download and install postgresql.
wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
rpm -Uvh pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql
dnf -y update
dnf -y install postgresql12-server postgresql12-devel postgresql12-contrib
systemctl enable postgresql-12
# initialize postgresql server
/usr/pgsql-12/bin/postgresql-12-setup initdb
echo "listen_addresses='*'" >> /var/lib/pgsql/12/data/postgresql.conf
sed -i 's/host.*all.*all.*127.0.0.1/#host all all 127.0.0.1/g' /var/lib/pgsql/12/data/pg_hba.conf
echo "host all all 127.0.0.1/32 password" >> /var/lib/pgsql/12/data/pg_hba.conf
echo "host all all ::1/128 password" >> /var/lib/pgsql/12/data/pg_hba.conf
echo "host all all 192.168.55.0/24 password" >> /var/lib/pgsql/12/data/pg_hba.conf
systemctl start postgresql-12.service
# create users and databases...
su - postgres << EOF
psql -c "
alter user postgres with password 'postgres';
create user test with password 'test';
"
EOF
export PGPASSWD=psotgres
systemctl restart postgresql-12.service
su - postgres << EOF
createdb test
psql -c "
alter database test owner to test;
"
EOF
# install pgweb
yum -y install unzip
wget https://github.com/sosedoff/pgweb/releases/download/v0.11.6/pgweb_linux_amd64.zip
unzip pgweb_linux_amd64.zip
mkdir -p /opt/pgweb
mv pgweb_linux_amd64 /opt/pgweb
cat << EOF > /etc/systemd/system/pgweb.service
[Unit]
Description=pgweb
[Service]
Type=simple
ExecStart=/opt/pgweb/pgweb_linux_amd64 --sessions --bind=0.0.0.0 --listen=8080
WorkingDirectory=/opt/pgweb
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
systemctl enable pgweb
systemctl start pgweb
echo 'access http://192.168.55.101:8080/'
echo 'host:127.0.0.1, user: postgres, password: postgres'
SHELL
end
0 件のコメント:
コメントを投稿