這篇文章主要介紹“安裝Postgresql12.1的詳細(xì)步驟”,在日常操作中,相信很多人在安裝Postgresql12.1的詳細(xì)步驟問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”安裝Postgresql12.1的詳細(xì)步驟”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供慶安網(wǎng)站建設(shè)、慶安做網(wǎng)站、慶安網(wǎng)站設(shè)計(jì)、慶安網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、慶安企業(yè)網(wǎng)站模板建站服務(wù),10年慶安做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。1、上傳安裝包
# cd /usr/src # rz # tar -zxvf postgresql-12.1.tar.gz # rm -rf postgresql-12.1.tar.gz
2、添加第三方插件
下載地址: https://www.postgresql.org/docs/12/contrib.html
# cd /usr/src/postgresql-12.1/contrib/ # rz # unzip zhparser-master.zip # rm -rf zhparser-master.zip
3、安裝postgresql依賴庫
# sudo apt-get install -y gcc libreadline-dev zlib1g zlib1g.dev make
4、安裝
# cd /usr/src/postgresql-12.1/ # ./configure --prefix=/opt/pgsql12.1/ --with-wal-blocksize=32 --with-blocksize=32 # make world # make install-world
5、添加用戶配置環(huán)境變量
# useradd postgres -m # passwd postgres # su - postgres $ vi ~/.profile export PGPORT=8899 export PGDATA=/home/postgres/pgsql12.1/pg_root export LANG=en_US.utf8 export PGHOME=/opt/pgsql12.1/ export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH export DATE=`date +"%Y%m%d%H%M"` export PATH=$PGHOME/bin:$PATH:. export MANPATH=$PGHOME/share/man:$MANPATH export PGUSER=postgres export PGHOST=$PGDATA alias rm='rm -i' alias ll='ls -lh' export PGDATABASE=center $ exit # reboot 或者 source ~/.profile # usermod -s /bin/bash postgres # su - postgres $ mkdir -p /home/postgres/pgsql12.1/pg_root $ initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W # 這里需要輸入兩次密碼
6、修改內(nèi)核參數(shù)
$ su - root # vi /etc/sysctl.conf kernel.shmmax = 68719476736 kernel.shmall = 4294967296 kernel.shmmni = 4096 kernel.sem = 50100 64128000 50100 1280 fs.file-max = 7672460 net.ipv4.ip_local_port_range = 9000 65000 net.core.rmem_default = 1048576 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 # sysctl -p # vi /etc/security/limits.conf * soft nofile 131072 * hard nofile 131072 * soft nproc 131072 * hard nproc 131072 * soft core unlimited * hard core unlimited * soft memlock 50000000 * hard memlock 50000000
7、關(guān)閉防火墻
# sudo ufw status verbose Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), disabled (routed) New profiles: skip # sudo ufw disable Firewall stopped and disabled on system startup # sudo ufw status verbose Status: inactive
8、配置pg_hba.conf
$ cd $PGDATA $ vi pg_hba.conf 添加允許訪問的IP段 host all all 192.168.0.0/16 md5 host all all 10.10.0.0/16 md5
9、配置 postgresql.conf
listen_addresses = '0.0.0.0' port = 7788 max_connections = 100 superuser_reserved_connections = 13 unix_socket_directories = '.' unix_socket_permissions = 0700 tcp_keepalives_idle = 60 tcp_keepalives_interval = 10 tcp_keepalives_count = 10 shared_buffers = 128MB vacuum_cost_delay = 10 bgwriter_delay = 10ms wal_writer_delay = 10ms log_destination = 'csvlog' logging_collector = on log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_file_mode = 0600 log_truncate_on_rotation = on log_rotation_age = 1d log_rotation_size = 10MB log_checkpoints = on log_connections = on log_disconnections = on log_error_verbosity = verbose log_timezone = 'Asia/Shanghai'
10、啟動數(shù)據(jù)庫
$ pg_ctl start [-d $PGDATA]
11、進(jìn)入數(shù)據(jù)庫
$ psql -h 127.0.0.1 -p 7788 -U postgres postgres
12、停止數(shù)據(jù)庫
$ pg_ctl stop [-m fast|smart|immediate][-d $PGDATA]
13、安裝Pgadmin
# sudo apt update -y && sudo apt upgrade -y # sudo apt-get install -y pgadmin4 pgadmin4-apache2
訪問:http://ip:端口/pgadmin4/
到此,關(guān)于“安裝Postgresql12.1的詳細(xì)步驟”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!
分享名稱:安裝Postgresql12.1的詳細(xì)步驟-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://jinyejixie.com/article18/deojdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、微信小程序、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站內(nèi)鏈、企業(yè)網(wǎng)站制作、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容