RHEL6.9+PG12
1.安裝postgresql軟體
--1.安裝依賴包 yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel zlib zlib-devel perl python36 tcl openssl ncurses-devel openldap pam systemd-devel --2.建立使用者與使用者組 groupadd -g 5432 postgres useradd -u 5432 -g postgres postgres echo "oracle" |passwd --stdin postgres --3.建立相關目錄 mkdir -p /postgresql/{app12,data,archive_wals,scripts,backup} chown -R postgres:postgres /postgresql chmod -R 774 /postgresql --4通過原始碼編譯安裝 [root@mysql-oracle soft]# tar -zxvf postgresql-12.2.tar.gz cd postgresql-12.2 tar -zxvf postgresql-12.2.tar.gz cd postgresql-12.2 ./configure --prefix=/postgresql/app12 --with-openssl gmake world gmake install-world
2.配置環境變數
su - postgres vim ~/.bash_profile export.UTF8 export PS1="[`whoami`@`hostname`:"'$PWD]$' export PGPORT=5432 export PGDATA=/postgresql/data export PGHOME=/postgresql/app12 export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib 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 source ~/.bash_profile
3.初始化資料庫
--postgresql.conf su - postgres cat >>/postgresql/data/postgresql.conf<<EOF listen_addresses = '*' port = 5432 max_connections = 1000 logging_collector = on log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_truncate_on_rotation = on shared_buffers = 1024MB unix_socket_directories = '/postgresql/data' EOF --pg_hba.conf cat>>/postgresql/data/pg_hba.conf<<EOF host all all 0.0.0.0/0 md5 EOF
4. 配置引數檔案
--postgresql.conf su - postgres cat >>/postgresql/data/postgresql.conf<<EOF listen_addresses = '*' port = 5432 max_connections = 1000 logging_collector = on log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_truncate_on_rotation = on shared_buffers = 1024MB unix_socket_directories = '/postgresql/data' EOF --pg_hba.conf cat>>/postgresql/data/pg_hba.conf<<EOF host all all 0.0.0.0/0 md5 EOF
5.配置linux服務指令碼
[root@mysql-oracle ~]# cp /soft/postgresql-12.2/contrib/start-scripts/linux /etc/init.d/postgresql chmod u+x /etc/init.d/postgresql vim /etc/init.d/postgresql prefix=/postgresql/app12 PGDATA="/postgresql/data" --測試 [root@mysql-oracle ~]# service postgresql start Starting PostgreSQL: ok [root@mysql-oracle ~]# service postgresql status pg_ctl: server is running (PID: 17638) /postgresql/app12/bin/postgres "-D" "/postgresql/data" [root@mysql-oracle ~]# service postgresql stop Stopping PostgreSQL: ok
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31355629/viewspace-2761617/,如需轉載,請註明出處,否則將追究法律責任。