1、选择系统对应的版本
https://www.postgresql.org/download/linux/redhat/

image.png
添加RPM
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
安装PostgreSQL 9.5
yum install postgresql96-server postgresql96-contrib
初始化数据库
/usr/pgsql-9.6/bin/postgresql96-setup initdb
开机自启动
systemctl enable postgresql-9.6
启动数据库
systemctl start postgresql-9.6
创建用户
#添加用户和数据库
sudo -u postgres psql
#-- set up the users and the passwords
#-- (note that it is important to use single quotes and a semicolon at the end!)
create role chirpstack_as with login password 'dbpassword';
create role chirpstack_ns with login password 'dbpassword';
#-- create the database for the servers
create database chirpstack_as with owner chirpstack_as;
create database chirpstack_ns with owner chirpstack_ns;
#-- change to the ChirpStack Application Server database
\c chirpstack_as
#-- enable the pq_trgm and hstore extensions
#-- (this is needed to facilitate the search feature)
create extension pg_trgm;
#-- (this is needed to store additional k/v meta-data)
create extension hstore;
#-- exit psql
\q