Debian and Ubuntu:
根据官网执行下面命令:
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql
安装指定版本:
apt-get install postgresql-12
postgresql-client-12 | client libraries and client binaries |
postgresql-12 | core database server |
postgresql-contrib-9.x | additional supplied modules (part of the postgresql-xx package in version 10 and later) |
libpq-dev | libraries and headers for C language frontend development |
postgresql-server-dev-12 | libraries and headers for C language backend development |
pgadmin4 | pgAdmin 4 graphical administration utility |
启动服务:
具体是 12 还是 postgres-12 看情况而定:
# 网上很多说用 pg_ctl 启动,但是发现没有这个命令,所以只能用 pg_ctlcluster
pg_ctlcluster 12 main start
# 或者
pg_ctlcluster postgres-12 main start
会用到的命令:
进程:
不知道具体的应用名称
ps -ef | grep -E "post|PID"
知道应用名称:
# 这个命令只会列出所有的进程号,没有其他信息
pidof postgres
端口:
通过进程号获取端口号信息:
sudo netstat -antup | grep <PID>
查看所有的 postgres集群:
pg_lsclusters