[原]Postgresql 12 Centos8 一键配置脚本

89921334 2020-02-02

#!/bin/bash
echo "write repo"
sudo cat>/etc/yum.repos.d/pgdg-redhat-12.repo<<EOF
[pgdg12]
name=pgdg12
baseurl=https://mirrors.cnnic.cn/postgresql/repos/yum/12/redhat/rhel-8-x86_64/
enabled=1
gpgcheck=0
EOF
echo "install postgresql12"
sudo dnf install postgresql12-server -y --disablerepo=BaseOS --disablerepo=AppStream
echo "postgresql initdb"
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
echo "postgresql start"
sudo systemctl enable --now postgresql-12
echo "postgresql add firewall"
sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload
echo "postgresql password postgres"
sudo su - postgres <<<"psql -c \"alter user postgres with password ‘postgres‘\""
echo "postgresql bind *"
sudo su - postgres <<<"sed -i ‘s/‘\"#listen_addresses = ‘localhost‘\"/\"listen_addresses = ‘*‘    \"‘/g‘ /var/lib/pgsql/12/data/postgresql.conf"
echo "postgresql allow 0.0.0.0/0"
sudo su - postgres <<<"echo \"host    all             all             0.0.0.0/0               md5\">>/var/lib/pgsql/12/data/pg_hba.conf"
echo "postgresql restart"
sudo systemctl restart postgresql-12

相关推荐

84593973 / 0评论 2020-06-14