仮想マシンの構築後、http://192.168.55.108/でpgAdminにアクセスできます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.4"
config.vm.hostname = "co74pg96pgadmin4"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co74pg96pgadmin4"
vbox.cpus = 2
vbox.memory = 1024
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.108", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.108", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
# 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
# create users and databases...
su - postgres << EOF
psql -c "
alter user postgres with password 'postgres';
create user dwh with password 'dwh';
"
EOF
export PGPASSWD=psotgres
systemctl restart postgresql-9.5.service
su - postgres << EOF
createdb dwh
psql -c "
alter database dwh owner to dwh;
"
EOF
yum -y install epel-release
yum -y install pgadmin4-v2
cat << EOF >> /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
EOF
cd /usr/lib/python2.7/site-packages/pgadmin4-web
cat << EOF | python setup.py
admin@localhost
adminpass
adminpass
EOF
chown -R apache:apache /var/lib/pgadmin4
chown -R apache:apache /var/log/pgadmin4
cat << EOF > /etc/httpd/conf.d/pgadmin4-v2.conf
<VirtualHost *>
ServerName co74pg96pgadmin4
WSGIDaemonProcess pgadmin processes=1 threads=25
WSGIScriptAlias / /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi
<Directory "/usr/lib/python2.7/site-packages/pgadmin4-web/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
EOF
systemctl restart httpd
echo 'access to http://192.168.55.108/'
SHELL
end
○ログイン画面
○ログイン後の画面
0 件のコメント:
コメントを投稿