从下述链接 下载源码安装包 postgresql-14.9.tar.gz
https://pan.baidu.com/s/1tdz9oj2Z8JgjzSmDcZnGVQ?pwd=38tw 提取码: 38tw
[root@pghost02~]# groupadd -g 60000 pgsql
[root@pghost02 ~]# useradd -u 60000 -g pgsql pgsql
[root@pghost02 ~]# echo "jem" | passwd --stdin pgsql
[root@pghost02 ~]# mkdir -p /postgresql/{pgdata,archive,scripts,backup,pg14,soft}
[root@pghost02 ~]# chown -R pgsql:pgsql /postgresql
[root@pghost02 ~]# chmod -R 775 /postgresql
[root@pghost02 ~]$ su - pgsql
[pgsql@pghost02 soft]$ cp /opt/postgresql-14.9.tar.gz /postgresql/soft/
[pgsql@pghost02 soft]$ cd /postgresql/soft
[pgsql@pghost02 soft]$ pwd
/postgresql/soft
[pgsql@pghost02 soft]$ tar zxvf postgresql-14.9.tar.gz
[pgsql@pghost02 soft]$ cd postgresql-14.9
[pgsql@pghost02 postgresql-14.9]$ du -sh .
本地yum的配置
mkdir -p /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
vi /etc/yum.repos.d/dvd.repo
添加:
[RHEL]
name=RHEL7
baseurl=file:///mnt/cdrom
gpgcheck=0
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7
enabled=1
--此处一定要安装依赖
yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel
yum install -y zlib libicu
yum install -y zlib-devel perl python36 tcl openssl ncurses-devel openldap pam
[pgsql@pghost02 postgresql-14.9]$ ./configure --prefix=/postgresql/pg14 --without-readline
[pgsql@pghost02 postgresql-14.9]$ make -j 4 && make install
cat >> ~/.bash_profile <<"EOF"
export LANG=en_US.UTF-8
export PS1="[\u@\h \W]\$ "
export PGPORT=5432
export PGDATA=/postgresql/pgdata
export PGHOME=/postgresql/pg14
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:$PATH:.
export DATE=`date +"%Y%m%d%H%M"`
export MANPATH=$PGHOME/share/man:$MANPATH
export PGHOST=$PGDATA
export PGUSER=postgres
export PGDATABASE=postgres
EOF
[pgsql@pghost02 ~]$ source ~/.bash_profile
#初始化
[root@pghost02 /]# su - pgsql
[pgsql@pghost02 ~]$ /postgresql/pg14/bin/initdb -D /postgresql/pgdata -E UTF8 --locale=en_US.utf8 -U postgres
/postgresql/pg14/bin/pg_ctl -D /postgresql/pgdata -l logfile start
两个参数文件:
/postgresql/pgdata/postgresql.conf
/postgresql/pgdata/pg_hba.conf
[pgsql@pghost02 ~]$ more /postgresql/pgdata/postgresql.conf | grep list
#修改参数
cat >> /postgresql/pgdata/postgresql.conf <<"EOF"
listen_addresses = '*'
port=5432
unix_socket_directories='/postgresql/pgdata'
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%a.log'
log_truncate_on_rotation = on #日志循环
EOF
cat > /postgresql/pgdata/pg_hba.conf << EOF
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md5
host replication all 0.0.0.0/0 md5
local replication all trust
EOF
#启动
[root@pghost02 /]# su - pgsql
[pgsql@pghost02 ~]$ pg_ctl start
[pgsql@pghost02 ~]$ pg_ctl status
[pgsql@pghost02 ~]$ pg_ctl stop
[pgsql@pghost02 ~]$ netstat -anp | grep 5432
[pgsql@pghost02 ~]$ cd /postgresql/pgdata/pg_log --日志文件
[pgsql@pghost02 ~]$ psql
postgres=# \password
查看pg的进程号
#远程登陆方式
psql -U postgres -h 192.168.1.10 -d postgres -p 5432
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。