本篇內(nèi)容介紹了“怎么在CentOS 7.4環(huán)境下源碼編譯安裝postgreSQL 11.4”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
專注于為中小企業(yè)提供成都網(wǎng)站制作、成都網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)沂源免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
1. 安裝依賴包
yum install -y readline readline-devel openssl openssl-devel zlib zlib-devel
2. 下載軟件
wget https://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.gz
3. 解壓并安裝
tar -zvvf postgresql-11.4.tar.gz #進(jìn)入解壓后的文件夾cd postgresql-11.4 ./configure --prefix=/usr/local/pgsql #指定默認(rèn)安裝路徑 make #編譯 make install #安裝
4. 添加用戶并更改權(quán)限
useradd postgres #添加用戶 passwd postgres #設(shè)置密碼 mkdir -p /data/pgsql/data mkdir -p /data/pgsql/log cd /data/pgsql/log touch pgsql.log chown -R postgres:postgres /data/pgsql
5. 添加環(huán)境變量
vim /etc/profile
內(nèi)容如下:
#postgresql export PGHOME=/data/pgsql export PGBASE=/usr/local/pgsql export PATH=$PATH:$PGBASE/bin
使之生效
source /etc/profile
6. 初始化數(shù)據(jù)
切換到postgres用戶下 su - postgres
[postgres@localhost ~]$ cd /usr/local/pgsql/bin/ [postgres@localhost bin]$ ls clusterdb ecpg pg_config pg_isready pg_rewind pg_waldump vacuumdb createdb initdb pg_controldata pg_receivewal pg_test_fsync postgres createuser pg_archivecleanup pg_ctl pg_recvlogical pg_test_timing postmaster dropdb pg_basebackup pg_dump pg_resetwal pg_upgrade psql dropuser pgbench pg_dumpall pg_restore pg_verify_checksums reindexdb
[postgres@localhost bin]$ ./initdb -D /data/pgsql/data The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /data/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... PRC selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: ./pg_ctl -D /data/pgsql/data -l logfile start
7. 檢查數(shù)據(jù)目錄:
[root@localhost data]# ls base pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf global pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact
其中
base
目錄是表空間目錄;
global
目錄是相關(guān)全局變量目錄;
pg_hba.conf
是訪問控制配置文件;
postgresql.conf
是postgresql的主配置文件。
將該文件中的IPV4的連接修改為0.0.0.0/0
,表示信任來自所有id連接的客戶端,加密方式改為md5
,如下圖所示:
將localhost
改為*
,表示監(jiān)聽所有的網(wǎng)絡(luò)連接。其他的參數(shù)保持默認(rèn)即可。
10. 關(guān)閉防火墻
systemctl stop firewalld
11. 啟動(dòng)數(shù)據(jù)庫
[postgres@localhost bin]$ ./pg_ctl -D /data/pgsql/data -l /data/pgsql/log/pgsql.log start waiting for server to start.... done server started
12. 登錄數(shù)據(jù)庫并設(shè)置密碼
[postgres@localhost bin]$ ./psql psql (11.4) Type "help" for help. postgres=# \password Enter new password: Enter it again: postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows)
13. navicat 登錄
“怎么在CentOS 7.4環(huán)境下源碼編譯安裝postgreSQL 11.4”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!