Because the customer has recently CentOS7 a virtual machine, but without networking, you need to install the offline installation of PostgreSQL
1, first go to the official website to download the offline installation package
https://www.postgresql.org/download/
Note: You can click on the download system, you can also click on the left navigation source Download tar.gz
Select the lower end of the page
I installed the version 11.6
After the download is complete, there are three packages below
2, PostgreSQL installation package
postgresql11-libs-11.6-1PGDG.rhel7.x86_64.rpm
postgresql11-11.6-1PGDG.rhel7.x86_64.rpm
postgresql11-server-11.6-1PGDG.rhel7.x86_64.rpm
If you do not libicu installed, also need to download libicu-50.2-3.el7.x86_64.rpm. Specifically Download, Baidu it.
3, pg upload packets to / tmp
Can be uploaded to their new catalog, I have here is uploaded to the server's tmp
cd /tmp rpm -ivh postgresql11-libs-11.6-1PGDG.rhel7.x86_64.rpm rpm -ivh postgresql11-11.6-1PGDG.rhel7.x86_64.rpm rpm -ivh postgresql11-server-11.6-1PGDG.rhel7.x86_64.rpm
Met here to install depend test fails, refer to: https://www.cnblogs.com/whitebai/p/12128078.html configure
4, after the installation is complete to initialize the database and enable the boot from the start
You should cd to root directory, just really tmp directory, or will not find the path.
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
5、配置/etc/hosts
其实这部我没有配置
6、最后添加主机ip和主机名
vim /var/lib/pgsql/11/data/postgresql.conf
7、根据实际需求开放访问ip
vim /var/lib/pgsql/11/data/pg_hba.conf
8、重启postgresql
systemctl restart postgresql-11 su - postgres psql 创建数据库用户 create user postgres password ‘pg’; 赋予账号权限 ALTER ROLE postgres SUPERUSER; 新建数据库 create database postgres; 退出
使用链接工具进行测试
安装具体参考:https://blog.csdn.net/TheDreamMaster/article/details/90318602 https://www.jianshu.com/p/b4a759c2208f