一、机器信息
IP/主机名 备注
192.168.50.1/Rz01.local 主库
192.168.50.2/Rz02.local 从库
二、编译包下载
链接:https://pan.baidu.com/s/1fiOmYB8uplfA1LQDy_LhqQ
提取码:5yxz
三、配置免密登录(两台都做)
#生成私钥
[root@localhost lib]# vim /etc/profile
[root@localhost lib]# cd
[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:lHsJtF23Wf/zZHWv4SzBR7Iml6K2Kyws/NIJHcf4IBA [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|E. . . . .|
|. . + . . +.|
| . o = . . + +|
| . + o. o o = =|
| o = S = B o.=|
| . . . o = = =o|
| . + o o . + .|
| + = o. . . |
| +.. .o. |
+----[SHA256]-----+
#拷贝密钥到其他机器(例举一台)
[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.65.132
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.65.132 (192.168.65.132)' can't be established.
ECDSA key fingerprint is SHA256:MaIR4AJ02WMecACcn4Kw8wM+oZJFTbf/zdCIkR92ez4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed # 试图用新的密钥登录,以过滤掉任何已经安装的密钥
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys # 1个密钥仍待安装——如果现在提示您安装新的密钥
Authorized users only. All activities may be monitored and reported. # 仅限授权用户使用。所有活动都可以被监测和报告。
[email protected]'s password:
[email protected]'s password:
Connection closed by 192.168.65.132 port 22
四、解压并安装postgresql-12.5
1、#安装包
[root@localhost ~]# yum install -y openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel install perl-ExtUtils-Embed readline readline-devel zlib zlib-devel gettext gettext-devel bison flex gcc gcc-c++ readline-devel
上次元数据过期检查:0:23:02 前,执行于 2023年03月03日 星期五 10时19分26秒。
软件包 openssl-1:1.1.1f-15.p06.ky10.x86_64 已安装。
软件包 openssl-devel-1:1.1.1f-15.p06.ky10.x86_64 已安装。
软件包 pam-1.4.0-8.p03.se.03.ky10.x86_64 已安装。
软件包 pam-devel-1.4.0-8.p03.se.03.ky10.x86_64 已安装。
软件包 libxml2-2.9.10-25.ky10.x86_64 已安装。
软件包 libxml2-devel-2.9.10-25.ky10.x86_64 已安装。
软件包 libxslt-1.1.34-4.ky10.x86_64 已安装。
软件包 perl-4:5.28.3-7.se.01.ky10.x86_64 已安装。
软件包 perl-devel-4:5.28.3-7.se.01.ky10.x86_64 已安装。
未找到匹配的参数: install
软件包 perl-4:5.28.3-7.se.01.ky10.x86_64 已安装。
软件包 readline-8.0-3.ky10.x86_64 已安装。
软件包 readline-devel-8.0-3.ky10.x86_64 已安装。
软件包 zlib-1.2.11-18.ky10.x86_64 已安装。
软件包 zlib-devel-1.2.11-18.ky10.x86_64 已安装。
软件包 gettext-0.21-4.ky10.x86_64 已安装。
软件包 gettext-devel-0.21-4.ky10.x86_64 已安装。
软件包 bison-3.6.4-2.ky10.x86_64 已安装。
软件包 flex-2.6.4-3.ky10.x86_64 已安装。
软件包 gcc-7.3.0-20220207.45.p01.ky10.x86_64 已安装。
软件包 gcc-c++-7.3.0-20220207.45.p01.ky10.x86_64 已安装。
错误:没有任何匹配: install
2、上传postgresql-12.5.tar.gz安装包,我的放在了/root/postgresql-12.5文件夹下
3、解压
[root@localhost ~]# tar -xf postgresql-12.5.tar.gz # 解压并得到文件夹
4、创建文件路径,并将解压后的文件复制到该路径下
[root@localhost ~]# mkdir -p /export/servers/app/postgresql-12.5 # 创建文件路径,并将解压后的文件复制到该路径下
[root@localhost ~]# cd postgresql-12.5
[root@localhost postgresql-12.5]# ./configure --prefix=/export/servers/app/postgresql-12.5 &&make &&make install # 打开并安装make
表示安装完成
#添加环境变量:wq保存退出。
[root@localhost postgresql-12.5]# vim /etc/profile
export PGHOME=/export/servers/app/postgresql-12.5
export PGDATA=/export/servers/data/pgsql/
export PATH=$PGHOME/bin:$PATH
export LANG=en_US.utf8
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
#刷新并使文件生效
[root@localhost postgresql-12.5]# source /etc/profile
#创建数据目录
useradd postgres
mkdir -p /export/servers/data/pgsql/
chown postgres:postgres /export/servers/data/pgsql/
#初始化数据库,
[root@localhost postgresql-12.5]# su - postgres # 切换用户
进入相应路径:
[postgres@localhost postgresql-12.5]$ cd /export/servers/app/postgresql-12.5/bin
在上面已经配置过了环境变量这里不用在配置了
export PGHOME=/export/servers/app/postgresql-12.5
export PGDATA=/export/servers/data/pgsql
export PATH=$PGHOME:/bin:$PATH
[postgres@localhost bin]$ /export/servers/app/postgresql-12.5/bin/initdb -D /export/servers/data/pgsql/
#修改监听端口
[postgres@localhost bin]$ vim /export/servers/data/pgsql/postgresql.conf
listen_addresses = '*'
#启动
/export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile start
[postgres@localhost bin]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile start
waiting for server to start..../bin/sh: logfile: Permission denied
stopped waiting
pg_ctl: could not start server
Examine the log output.
# 启动服务
[postgres@localhost bin]$ pg_ctl start
waiting for server to start....2023-03-03 11:27:58.887 CST [41939] LOG: starting PostgreSQL 12.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.0, 64-bit
2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv4 address "0.0.0.0", port 5432
2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv6 address "::", port 5432
2023-03-03 11:27:58.890 CST [41939] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-03-03 11:27:58.908 CST [41940] LOG: database system was shut down at 2023-03-03 11:12:37 CST
2023-03-03 11:27:58.911 CST [41939] LOG: database system is ready to accept connections
done
server started
#验证5432端口已经开启
[postgres@localhost bin]$ netstat -anp | grep 5432
登录并修改postgres密码
[root@localhost pgsql]# passwd postgres # 修改密码,我的密码是:“·1234qwert”
[root@localhost pgsql]# su - postgres # 切换用户
[postgres@localhost pgsql]# psql # 登录数据库
alter user postgres with password 'postgres'; # 修改用户密码为postgres
exit
#修改为md5表示用密码登录,如果为trust表示不需要密码,
[postgres@localhost bin]$ cd /export/servers/data/pgsql/
[postgres@localhost bin]$ vim pg_hba.conf
把trust修改成md5,保存
#重启
[postgres@localhost pgsql]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile restart
验证密码是否修改成功
密码修改前的状态如下
密码修改后的状态如下:
[postgres@localhost pgsql]$ psql Password for user postgres: # 输入修改的密码:这里是postgres
标签:Postgres,V10,export,12.5,64,root,localhost,postgres From: https://www.cnblogs.com/liunaixu/p/17175202.html