安裝Postgresql12.1
1、上傳安裝包
# cd /usr/src # rz # tar -zxvf postgresql-12.1.tar.gz # rm -rf postgresql-12.1.tar.gz
2、新增第三方外掛
下載地址:
# 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、新增使用者配置環境變數
# 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、修改核心引數
$ 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、關閉防火牆
# 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、啟動資料庫
$ pg_ctl start [-d $PGDATA]
11、進入資料庫
$ psql -h 127.0.0.1 -p 7788 -U postgres postgres
12、停止資料庫
$ 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
訪問:埠/pgadmin4/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25357621/viewspace-2667245/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 安裝npm 解除安裝npm 安裝apidocNPMAPI
- BiocManager安裝,devtools安裝dev
- Linux安裝解除安裝MySQLLinuxMySql
- linux 安裝yum 安裝phpLinuxPHP
- Ubuntu解除安裝和安裝Ubuntu
- 02 安裝git、安裝TortoiseGitGit
- cocoapods安裝/解除安裝/使用
- JDK安裝和解除安裝JDK
- ffmpeg安裝之mac安裝Mac
- docker安裝及解除安裝Docker
- [ 安裝 ] Zeppelin安裝步驟!
- win10安裝版怎麼安裝_安裝版win10安裝教程Win10
- ElasticSearch的安裝和使用,Postman的安裝,Kibana的安裝,EShead外掛的安裝ElasticsearchPostman
- Mac Redis安裝與解除安裝MacRedis
- 安裝了IDLE後安裝tensorflow
- kratos安裝及依賴安裝
- Linux 解除安裝openjdk 安裝oraclejdkLinuxJDKOracle
- debian安裝和解除安裝vmware
- JDK的安裝與解除安裝JDK
- linux 解除安裝jdk和安裝LinuxJDK
- 【推薦 - glibc安裝】MySQL - 安裝MySql
- linux下安裝snap安裝工具Linux
- [雲原生]Docker - 安裝&解除安裝Docker
- Ubuntu安裝和解除安裝mongodbUbuntuMongoDB
- window下安裝並使用nvm(含解除安裝node、解除安裝nvm、全域性安裝npm)NPM
- 安裝
- air安裝win10怎麼解除安裝_air安裝win10如何解除安裝AIWin10
- Centos Docker安裝、升級、解除安裝CentOSDocker
- Webpack學習 – Webpack安裝及安裝Web
- Linux-Ubuntu-mysql-安裝&解除安裝LinuxUbuntuMySql
- Centos7.9安裝解除安裝DockerCentOSDocker
- Centos7安裝安裝部署dockerCentOSDocker
- Linux系統安裝——Centos 7.6安裝LinuxCentOS
- PostgreSQL 10.12 安裝系列 - 原始碼安裝SQL原始碼
- PostgreSQL 10.12 安裝系列 - 本地RPM安裝SQL
- 【 Linux 軟體安裝 】- 1 JDK安裝LinuxJDK
- Python pip的安裝及解除安裝Python
- CentOS7安裝php、安裝MySqlCentOSPHPMySql