Postgresql日常運維-安裝(Linux)01
Postgresql 12.2 日常運維 - 安裝 (Linux)01
一:Linux 下安裝 Postgresql
二:Windows 下安裝 Postgresql
一:Linux 下安裝 Postgresql
環境說明:
Linux OS:Red Hat Enterprise Linux Server release 7.5 (Maipo)
Windows OS:Windows 10
DB : PostgreSQL 12.2
1 下載 PostgreSQL 12.2
二進位制包下載
原始碼包下載
本次實驗使用原始碼包
......
[root@cjcos package]# pwd
/package
[root@cjcos package]# ll -rth postgresql-12.2.tar.gz
-rw-r--r-- 1 root root 26M Apr 2 11:11 postgresql-12.2.tar.gz
[root@cjcos package]# md5sum postgresql-12.2.tar.gz
939acc9359abf0de9838965947a19158 postgresql-12.2.tar.gz
2 建立使用者,組,目錄等
[root@cjcos ~]# groupadd postgres
[root@cjcos ~]# useradd -g postgres postgres
[root@cjcos ~]# passwd postgres
[root@cjcos ~]# mkdir /usr/local/pgsql/data -p
[root@cjcos ~]# chown postgres.postgres /usr/local/pgsql -R
[root@cjcos package]# chown postgres.postgres /package/postgres -R
3 解壓
[root@cjcos package]# su - postgres
[postgres@cjcos ~]$ cd /package/postgres/
[postgres@cjcos postgres]$ ll -rth
total 26M
-rw-r--r-- 1 postgres postgres 26M Apr 2 11:11 postgresql-12.2.tar.gz
[postgres@cjcos postgres]$ tar -zxvf postgresql-12.2.tar.gz
4 安裝
[postgres@cjcos postgres]$ cd postgresql-12.2/
[postgres@cjcos postgresql-12.2]$ pwd
/package/postgres/postgresql-12.2
[postgres@cjcos postgresql-12.2]$ ./configure --prefix=/usr/local/pgsql
[postgres@cjcos postgresql-12.2]$ make
......
All of PostgreSQL successfully made. Ready to install.
[postgres@cjcos postgresql-12.2]$ make install
......
PostgreSQL installation complete.
[root@cjcos pgsql]# pwd
/usr/local/pgsql
[root@cjcos pgsql]# ls
bin data include lib share
5 配置環境變數
[postgres@cjcos ~]$ vim .bash_profile
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
PATH=$PATH:$HOME/bin:$PGHOME/bin
[postgres@cjcos ~]$ source .bash_profile
6 使用initdb 初使用化資料庫
[postgres@cjcos bin]$ ./initdb -D /usr/local/pgsql/data
[root@cjcos data]# pwd
/usr/local/pgsql/data
[root@cjcos data]# ls
base pg_hba.conf pg_notify pg_stat_tmp pg_twophase postgresql.conf
global pg_ident.conf pg_serial pg_subtrans PG_VERSION
pg_clog pg_multixact pg_snapshots pg_tblspc pg_xlog
7 修改引數
[root@cjcos data]# vim postgresql.conf
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
#port = 5432 # (change requires restart)
listen_addresses = '*'
[root@cjcos data]# vim pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
8 啟動資料庫
[postgres@cjcos bin]$ ./pg_ctl -D /usr/local/pgsql/data -l logfile start
waiting for server to start.... done
server started
9 登入資料庫
[postgres@cjcos bin]$ ./psql
psql (12.2)
Type "help" for help.
postgres=# select current_setting('server_version_num');
current_setting
-----------------
120002
(1 row)
10 問題彙總:
問題一: configure: error: readline library not found
問題原因:沒有安裝 readline-devel
解決方案:通過yum 安裝 readline-devel
過程如下:
[postgres@cjcos postgresql-12.2]$ ./configure --prefix=/usr/local/pgsql
......
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
[root@cjcos pgsql]# rpm -qa | grep readline
readline-6.2-10.el7.x86_64
[root@cjcos pgsql]# yum search readline
掛載映象
[root@cjcos yum.repos.d]# mount /package/V975367-01.iso /mnt -o loop
配置本地yum
[root@cjcos yum.repos.d]# cat yum.repo
[Oralin7u5]
name=local yum
baseurl=file:///mnt
gpgcheck=0
enabled=1
安裝
[root@cjcos pgsql]# yum -y install -y readline-devel
同時安裝其他依賴包
[root@cjcos yum.repos.d]# yum -y install perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake
問題二:postgresql 啟動報錯版本不相容
問題原因:在安裝postgresql12.2 之前,作業系統上已經預設安裝了一個 9.2 版本的 pg 。
解決方案:解除安裝pg9.2 ,重新初始化資料庫。
過程如下:
[postgres@cjcos bin]$ ./pg_ctl -D /usr/local/pgsql/data -l logfile start
......
2020-04-02 14:43:25.405 CST [27701] FATAL: database files are incompatible with server
2020-04-02 14:43:25.405 CST [27701] DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 12.2.
stopped waiting
pg_ctl: could not start server
Examine the log output.
[root@cjcos ~]# rpm -qa|grep postgre
postgresql-docs-9.2.23-3.el7_4.x86_64
postgresql-9.2.23-3.el7_4.x86_64
postgresql-libs-9.2.23-3.el7_4.x86_64
postgresql-server-9.2.23-3.el7_4.x86_64
[root@cjcos ~]# rpm -e postgresql-docs-9.2.23-3.el7_4.x86_64
[root@cjcos ~]# rpm -e postgresql-9.2.23-3.el7_4.x86_64 --nodeps
[root@cjcos ~]# rpm -e postgresql-libs-9.2.23-3.el7_4.x86_64 --nodeps
[root@cjcos ~]# rpm -e postgresql-server-9.2.23-3.el7_4.x86_64
[postgres@cjcos bin]$ ./initdb -D /usr/local/pgsql/data
[postgres@cjcos bin]$ ./pg_ctl -D /usr/local/pgsql/data -l logfile start
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2684244/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Postgresql日常運維-安裝(Windows)02SQL運維Windows
- MongoDB日常運維-02安裝MongoDB運維
- Linux 系統日常運維 9 大技能,搞定 90% 日常運維Linux運維
- 【Linux】運維入門 -01Linux運維
- RAC日常運維運維
- Linux(01):RedHat 7.6 安裝LinuxRedhat
- 如何安裝Linux作業系統?Linux運維教學Linux作業系統運維
- 運維日常工作運維
- 【linux運維】Linux伺服器玩轉vsftpd安裝與配置Linux運維伺服器FTP
- Oracle 19C Data Guard基礎運維-01安裝物理standbyOracle運維
- 高階Linux運維工程師日常涉及哪些工作?Linux學習Linux運維工程師
- linux安裝postgresql三種方式LinuxSQL
- postgreSQL學習(一):在Linux下安裝postgreSQLSQLLinux
- 【PG安裝】postgresql10 for linux 原始碼安裝SQLLinux原始碼
- redis安裝和運維Redis運維
- GitLab 安裝、管理、運維Gitlab運維
- SQL SERVER日常運維(一)SQLServer運維
- 《前端運維》一、Linux基礎--09常用軟體安裝前端運維Linux
- Linux系統安裝01-centos7系統安裝LinuxCentOS
- 【小白必看】Linux運維工程師日常崗位職責有哪些?Linux運維工程師
- Alibaba Cloud Linux 安裝 PostgreSQL 資料庫CloudLinuxSQL資料庫
- Docker Swarm 日常運維命令筆記DockerSwarm運維筆記
- Lync日常運維常用命令運維
- Redis日常運維-基礎認識Redis運維
- Redis日常運維-引數詳解Redis運維
- MySQL 資料庫日常運維文件MySql資料庫運維
- 達夢資料庫日常運維資料庫運維
- ORACLE OGG運維及日常監控Oracle運維
- Linux安裝要注意哪些問題?運維管理軟體有哪些Linux運維
- Linux系統運維筆記,openEuler-22.03 安裝阿里(aliyun)yumLinux運維筆記阿里
- 學習Linux安裝虛擬機器有哪些步驟?Linux運維學習Linux虛擬機運維
- Linux運維職責是什麼?日常工作內容有哪些?Linux運維
- MySQL-01.Linux下MySQL安裝和使用MySqlLinux
- pytest跟我練01-->安裝&簡單運用
- redis運維(三)redis6.0.8安裝Redis運維
- Oracle RAC日常運維-ASM磁碟擴容Oracle運維ASM
- MongoDB日常運維-04副本集搭建MongoDB運維
- Redis日常運維-02主從複製Redis運維