centos7 源码安装pg12.3

源码安装

官方安装文档

源码下载地址

wget https://ftp.postgresql.org/pub/source/v12.3/postgresql-12.3.tar.gz

环境准备
  • 添加系统用户 groupadd postgres && useradd -g postgres postgres
  • 创建数据目录 mkdir /data/pg_data && cd /data && chown -R postgres: pg_data
  • 添加依赖包 yum -y install readline-devel.x86_64 zlib-devel.x86_64
编译安装
tar -zxvf postgresql-12.3.tar.gz && cd postgresql-12.3
./configure --prefix=/opt/postgresql-12.3
make world
make install-world
配置环境变量并初始化
--添加软连接
ln -s /opt/postgresql-12.3 /opt/pgsql
chown -R postgres: pgsql postgresql-12.3

--postgres用户下编辑环境变量
cat ~/.bash_profile
.
.
.
export PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/opt/pgsql/bin

--postgres用户下环境变量生效
source ~/.bash_profile

--postgres用户下初始化数据库
initdb -D /data1/pg_data
.
.
.
Success. You can now start the database server using:

    pg_ctl -D /data1/pg_data -l logfile start

修改数据库参数
listen_addresses = '*'      # what IP address(es) to listen on;
port = 5432             # (change requires restart)
max_connections = 5000          # (change requires restart)
superuser_reserved_connections = 10 # (change requires restart)
unix_socket_directories = '/tmp'    # comma-separated list of directories
shared_buffers = 4GB            # min 128kB
temp_buffers = 32MB         # min 800kB
work_mem = 64MB             # min 64kB
maintenance_work_mem = 128MB        # min 1MB
shared_memory_type = mmap       # the default is the first option
dynamic_shared_memory_type = posix  # the default is the first option
max_files_per_process = 1000        # min 25
vacuum_cost_delay = 10          # 0-100 milliseconds (0 disables)
vacuum_cost_limit = 200     # 1-10000 credits
bgwriter_delay = 200ms          # 10-10000ms between rounds
effective_io_concurrency = 600      # 1-1000; 0 disables prefetching
max_worker_processes = 16       # (change requires restart)
max_parallel_maintenance_workers = 4    # taken from max_parallel_workers
max_parallel_workers_per_gather = 4 # taken from max_parallel_workers
parallel_leader_participation = on
max_parallel_workers = 8        # maximum number of max_worker_processes that
wal_level = logical         # minimal, replica, or logical
full_page_writes = off          # recover from partial page writes
wal_compression = off           # enable compression of full-page writes
wal_log_hints = off         # also do full page writes of non-critical updates
checkpoint_timeout = 30min      # range 30s-1d
max_wal_size = 4GB
min_wal_size = 512MB
checkpoint_completion_target = 0.8  # checkpoint target duration, 0.0 - 1.0
checkpoint_flush_after = 512kB      # measured in pages, 0 disables
checkpoint_warning = 30s        # 0 disables
archive_mode = on       # enables archiving; off, on, or always
archive_command = '/bin/true'       # command to use to archive a logfile max_wal_senders = 10        # max number of walsender processes
wal_keep_segments = 1000        # in logfile segments; 0 disables
max_replication_slots = 10  # max number of replication slots
hot_standby = on            # "off" disallows queries during recovery
max_standby_archive_delay = 30s # max delay before canceling queries
max_standby_streaming_delay = 30s   # max delay before canceling queries
max_logical_replication_workers = 4 # taken from max_worker_processes
max_sync_workers_per_subscription = 2   
min_parallel_table_scan_size = 8MB
min_parallel_index_scan_size = 512kB
effective_cache_size = 4GB
log_destination = 'stderr'      # Valid values are combinations of
logging_collector = on      # Enable capturing of stderr and csvlog
log_directory = 'log'           # directory where log files are written,
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
log_rotation_size = 32MB        # Automatic rotation of logfiles will
log_min_duration_statement = 1000   # -1 is disabled, 0 logs all statements
log_checkpoints = off
log_connections = off
log_duration = off
log_hostname = off
log_line_prefix = '%m %d %r %u %p %x %v '       # special values:
log_statement = 'mod'           # none, ddl, mod, all
log_timezone = 'Asia/Shanghai'
autovacuum = on         # Enable autovacuum subprocess?  'on'
lock_timeout = 10000            # in milliseconds, 0 is disabled
datestyle = 'iso, mdy'
timezone = 'Asia/Shanghai'
lc_messages = 'en_US.UTF-8'         # locale for system error message
lc_monetary = 'en_US.UTF-8'         # locale for monetary formatting
lc_numeric = 'en_US.UTF-8'          # locale for number formatting
lc_time = 'en_US.UTF-8'             # locale for time formatting
default_text_search_config = 'pg_catalog.english'
deadlock_timeout = 1s

启动数据库
pg_ctl -D /data1/pg_data start

psql
psql (12.3)
Type "help" for help.

postgres=#
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,324评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,303评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,192评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,555评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,569评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,566评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,927评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,583评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,827评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,590评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,669评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,365评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,941评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,928评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,159评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,880评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,399评论 2 342

推荐阅读更多精彩内容