Linux下PostgreSQL安装部署指南(2)

建议使用较新的编译器,安装 gcc 6.2.0 略

cd ~ tar -jxvf gcc6.2.0.tar.bz2 tar -jxvf python2.7.12.tar.bz2 # vi /etc/ld.so.conf /home/digoal/gcc6.2.0/lib /home/digoal/gcc6.2.0/lib64 /home/digoal/python2.7.12/lib # ldconfig

环境变量

# vi ~/env_pg.sh export PS1="$USER@`/bin/hostname -s`-> " export PGPORT=$1 export PGDATA=/$2/digoal/pg_root$PGPORT export LANG=en_US.utf8 export PGHOME=/home/digoal/pgsql9.6 export LD_LIBRARY_PATH=/home/digoal/gcc6.2.0/lib:/home/digoal/gcc6.2.0/lib64:/home/digoal/python2.7.12/lib:$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=/home/digoal/gcc6.2.0/bin:/home/digoal/python2.7.12/bin:/home/digoal/cmake3.6.3/bin:$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 alias rm='rm -i' alias ll='ls -lh' unalias vi 编译PostgreSQL

建议使用NAMED_POSIX_SEMAPHORES

. ~/env_pg.sh 1921 u01 cd postgresql-9.6.1 export USE_NAMED_POSIX_SEMAPHORES=1 LIBS=-lpthread CC="/home/digoal/gcc6.2.0/bin/gcc" CFLAGS="-O3 -flto" ./configure --prefix=/home/digoal/pgsql9.6 LIBS=-lpthread CC="/home/digoal/gcc6.2.0/bin/gcc" CFLAGS="-O3 -flto" make world -j 64 LIBS=-lpthread CC="/home/digoal/gcc6.2.0/bin/gcc" CFLAGS="-O3 -flto" make install-world 初始化数据库集群

pg_xlog建议放在IOPS最好的分区。

. ~/env_pg.sh 1921 u01 initdb -D $PGDATA -E UTF8 --locale=C -U postgres -X /u02/digoal/pg_xlog$PGPORT 配置postgresql.conf

以PostgreSQL 9.6, 512G内存主机为例

最佳到文件末尾即可,重复的会以末尾的作为有效值。 $ vi postgresql.conf listen_addresses = '0.0.0.0' port = 1921 max_connections = 5000 unix_socket_directories = '.' tcp_keepalives_idle = 60 tcp_keepalives_interval = 10 tcp_keepalives_count = 10 shared_buffers = 128GB maintenance_work_mem = 4GB dynamic_shared_memory_type = posix vacuum_cost_delay = 0 bgwriter_delay = 10ms bgwriter_lru_maxpages = 1000 bgwriter_lru_multiplier = 10.0 bgwriter_flush_after = 0 max_parallel_workers_per_gather = 0 old_snapshot_threshold = -1 backend_flush_after = 0 wal_level = replica synchronous_commit = off full_page_writes = on wal_buffers = 1GB wal_writer_delay = 10ms wal_writer_flush_after = 0 checkpoint_timeout = 30min max_wal_size = 256GB min_wal_size = 64GB checkpoint_completion_target = 0.05 checkpoint_flush_after = 0 max_wal_senders = 5 random_page_cost = 1.0 parallel_tuple_cost = 0 parallel_setup_cost = 0 min_parallel_relation_size = 0 effective_cache_size = 300GB force_parallel_mode = off log_destination = 'csvlog' logging_collector = on log_truncate_on_rotation = on log_checkpoints = on log_connections = on log_disconnections = on log_error_verbosity = verbose log_timezone = 'PRC' autovacuum = on log_autovacuum_min_duration = 0 autovacuum_max_workers = 16 autovacuum_naptime = 15s autovacuum_vacuum_scale_factor = 0.02 autovacuum_analyze_scale_factor = 0.01 vacuum_freeze_table_age = 1500000000 vacuum_multixact_freeze_table_age = 1500000000 datestyle = 'iso, mdy' timezone = 'PRC' lc_messages = 'C' lc_monetary = 'C' lc_numeric = 'C' lc_time = 'C' default_text_search_config = 'pg_catalog.english' shared_preload_libraries='pg_stat_statements' 配置pg_hba.conf

避免不必要的访问,开放允许的访问,建议务必使用密码访问。

$ vi pg_hba.conf host all all 0.0.0.0/0 md5 启动数据库 pg_ctl start

好了,你的PostgreSQL数据库基本上部署好了,可以愉快的玩耍了。

------------------------------------华丽丽的分割线------------------------------------

CentOS 6.5上编译安装PostgreSQL 9.3数据库

CentOS 6.3环境下yum安装PostgreSQL 9.3

PostgreSQL缓存详述

Windows平台编译 PostgreSQL

Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)环境的配置与安装

Ubuntu上的phppgAdmin安装及配置

CentOS平台下安装PostgreSQL9.3

PostgreSQL配置Streaming Replication集群

------------------------------------华丽丽的分割线------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/299d7192ce5afd97be96d240d603c5e2.html