〇pgAdmin4の画面
ユーザはadmin@localhost、パスワードにはadminpassを指定します。
接続情報として、DBとしてdwh、ユーザ名dwh、パスワードdwhを指定します。
〇構築方法
以下のVagrantfileを使用して、pgAdmin4とPostgreSQL10をインストールした仮想マシン(CentOS7.5)を構築する事ができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.5"
config.vm.hostname = "co75pg10pgadmin4v3"
config.vm.provider :virtualbox do |vbox|
vbox.name = "co75pg10pgadmin4v3"
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/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
rpm -Uvh pgdg-centos10-10-2.noarch.rpm
yum -y update
yum -y install postgresql10-server postgresql10-devel postgresql10-contrib
systemctl enable postgresql-10
# initialize postgresql server
/usr/pgsql-10/bin/postgresql-10-setup initdb
echo "listen_addresses='*'" >> /var/lib/pgsql/10/data/postgresql.conf
sed -i 's/host.*all.*all.*127.0.0.1/#host all all 127.0.0.1/g' /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 127.0.0.1/32 password" >> /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 192.168.1.0/24 password" >> /var/lib/pgsql/10/data/pg_hba.conf
echo "host all all 192.168.55.0/24 password" >> /var/lib/pgsql/10/data/pg_hba.conf
systemctl start postgresql-10.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-10.service
su - postgres << EOF
createdb dwh
psql -c "
alter database dwh owner to dwh;
"
EOF
yum -y install epel-release
yum -y install pgadmin4
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 co75pg10pgadmin4v3
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 件のコメント:
コメントを投稿