PostgreSQL 11原始碼安裝
阿新 • • 發佈:2018-12-07
PostgreSQL 11原始碼安裝
測試環境:RedHat 7.0 Linux 64bit
PostgreSQL 11原始碼安裝包下載地址link
系統環境準備
RedHat 7.0預設會安裝相關係統包,還需要增加PostgreSQL編譯時必須包,如下:
gcc, bison, gcc-c++, readline, readline-devel, zlib, zlib-devel, perl, perl-devel
建立postgres使用者,並建立安裝目錄
useradd Postgres mkdir -p /opt/pgsql/data chown -R postgres:postgres /opt/pgsql
安裝PostgreSQL
解壓、編譯、安裝
tar -zxvf postgresql-11.1.tar.gz
cd postgresql-11.1
./configure --prefix=/opt/pgsql
make & make install
初始化資料庫
su - postgres [[email protected] bin]$cd /opt/pgsql/bin [[email protected] bin]$ ./initdb -D /opt/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 /opt/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB 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 /opt/pgsql/data/ -l logfile start [
[email protected] bin]$./pg_ctl -D /opt/pgsql/data -l logfile start waiting for server to start.... done server started #配置使用者環境變數檔案.bash.profile增加如下內容 export PATH=$PATH:/opt/pgsql/bin [[email protected] ~]$ psql psql (11.1) Type "help" for help. postgres=# postgres=# postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres=#