以下のVagrantfileを使用して、pgwebとPostgreSQLをインストールした仮想マシン(CenttOS7.4)を構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.55.109:8080/にアクセスします。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.4"
config.vm.hostname = "co74pgweb"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co74pgweb"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
# private network
config.vm.network "private_network", ip: "192.168.55.118", :netmask => "255.255.255.0"
# bridge netwrok
config.vm.network "public_network", ip: "192.168.1.118", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
yum check-update
yum -y update
# download and install postgresql.
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
rpm -Uvh pgdg-centos96-9.6-3.noarch.rpm
yum -y update
yum -y install postgresql96-server postgresql96-devel postgresql96-contrib
systemctl enable postgresql-9.6
# initialize postgresql server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
echo "listen_addresses='*'" >> /var/lib/pgsql/9.6/data/postgresql.conf
echo "standard_conforming_strings=off" >> /var/lib/pgsql/9.6/data/postgresql.conf
sed -i 's/host.*all.*all.*127.0.0.1/#host all all 127.0.0.1/g' /var/lib/pgsql/9.6/data/pg_hba.conf
echo "host all all 127.0.0.1/32 password" >> /var/lib/pgsql/9.6/data/pg_hba.conf
echo "host all all 192.168.1.0/24 password" >> /var/lib/pgsql/9.6/data/pg_hba.conf
echo "host all all 192.168.55.0/24 password" >> /var/lib/pgsql/9.6/data/pg_hba.conf
systemctl start postgresql-9.6.service
su - postgres << EOF
psql -c "
alter user postgres with password 'postgres';
"
EOF
echo "postgres:postgres" | chpasswd
# install pgweb
yum -y install unzip
wget https://github.com/sosedoff/pgweb/releases/download/v0.9.11/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.118:8080/'
echo 'user: postgres, password: postgres'
SHELL
end
〇pgwebの画面
○関連情報
・pgwebに関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿