用RPM包安装postgresql

 

1. 配置yum源

yum -y install epel-release
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install  https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

 

2. 安装

-- 安装11版本
yum -y install postgresql11-server
yum -y install postgresql11-devel

 

3. 初始化

-- rhel6
 service postgresql initdb
 chkconfig postgresql on
 
-- rhel7/8
# 修改数据目录路径
vi /usr/lib/systemd/system/postgresql-11.service
Environment=PGDATA=/var/lib/pgsql/11/data/      >>>>>>>配置自定义数据目录 Environment=PGDATA=/ups/data/pgdata/11/pg_root
/usr/pgsql-11/bin/postgresql-11-setup initdb 

or
su - postgres
/usr/pgsql-11/bin/initdb -D /ups/data/pgdata/11/pg_root
 systemctl enable postgresql-11 systemctl start postgresql-11

 

4. 启动服务

-- rhel6
service postgresql start

-- rhel7/8
systemctl start postgresql11

 

5. 其它相关配置

-- 配置环境变量
vi /home/postgres/.bash_profile
export PGPORT=1921
export PGUSER=postgres
export PGGROUP=postgres
export PGDATA=/ups/data/pgdata/11/pg_root
export LANG=en_US.UTF-8
export PGHOME=/ups/app/pgsql-11
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH

-- 配置IP和端口
vi ${PGDATA}/postgresql.conf
-- 修改listen_addresses如下
listen_addresses = '*'

-- 配置连接方式
cp ${PGDATA}/pg_hba.conf ${PGDATA}/pg_hba.conf_${MDATE}
vi ${PGDATA}/pg_hba.conf
host    all             all             192.168.10.0/24           md5

-- 配置共享内存
vi ${PGDATA}/postgresql.conf
shared_buffers = 128MB            # min 128kB      <<<<<<<<默认值

 

上一篇:【无标题】


下一篇:本地mysql库安装