postgres的安装与配置_第1页
postgres的安装与配置_第2页
postgres的安装与配置_第3页
postgres的安装与配置_第4页
postgres的安装与配置_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、tgres 的安装、配置准备选择tgresql-9.4.2 版本,地址上传至/usr/local/src 下配置好 yum 源设置环境变量 配置ROSOZY IUTL 文件O KZI YKIXOZ_ ROSOZY IUTLYULZ TULORK NGXJ TULORK YULZ TVXUI NGXJ TVXUI YULZ IUXK TROSOZKJNGXJ IUXK TROSOZKJ 时间与时间服务器同步,在 IXUTZGH 里添加: YX YHOT TZVJGZK GYOG VUUR TZV YHOT NIRUIQ Y_YZUNI 配置内核参数O KZI Y_YIZR IUTL QKXTKR

2、 YNSSTO # QKXTKR YKS # LY LORK SG # TKZ OV OVERUIGREVUXZEXGTMK # TKZ IUXK XSKSEJKLGRZ # TKZ IUXK XSKSESG # TKZ IUXK SKSEJKLGRZ # TKZ IUXK SKSESG # TKZ OV ZIVEZEXKI_IRK # TKZ OV ZIVESGEY_TEHGIQRUM # TKZ IUXK TKZJKESGEHGIQRUM # SOZESKSUX_ # TKZ OV OVEIUTTZXGIQESG # LY GOU SG TX # TKZ OV ZIVEZOSKYZY #

3、将参数加载到内核,执行Y_YIZR V安装3. 编译 tgresql 源码rootlocalhost rootlocalhost tgresql-9.4.2# yum -y install readline-devel.x86_64 tgresql-9.4.2# yum -y install zlib-devel.x86_64rootlocalhost tgresql-9.4.2#./configure -prefix=/usr/local/tgresql-9.4.2 -with-pgport=5432 HYPERLINK mailto:rootlocalhostpgsql-9.4.2 roo

4、tlocalhost pgsql-9.4.2#make HYPERLINK mailto:rootlocalhostpgsql-9.4.2 rootlocalhost pgsql-9.4.2#make install HYPERLINK mailto:rootlocalhostpgsql-9.4.2 rootlocalhost pgsql-9.4.2#cd /usr/localrootlocalhost local# ln -s tgresql-9.4.2 pgsqlrootlocalhost local# rootlocalhost local#n -R n -R tgres: tgres:

5、tgres tgresql-9.4.2tgres pgsql注:编译安装过程中可能因为缺包报错,缺什么补什么,再重新执行即可。4. 设置tgres 用户环境变量rootlocalhost pgsql-9.1.1# su -tgrestgreslocalhost $ more .bash_profiletgreslocalhost $ vi .bash_profile2. 解压安装包tgresql-9.4.2.tar.bz2 rootlocalhost src# tar -jxvftgresql-9.4.2.tar.bz2rootlocalhost src#cdtgresql-9.4.21.创建

6、 pg 用户及组rootlocalhost# groupaddtgres rootlocalhost# useradd -gtgrestgresrootlocalhost# passwdtgressoft memlock 50000000hard memlock 50000000查看书否修改成功:ulimit -a4. 关闭SElinuxvi /etc/sysconfig/selinux SELINUX=disabled重启服务器5.设置状态:chkconfig -list |grep -i iptables关闭:# /sbin/chkconfig iptables off6. 设置tgres

7、 开机自启动rootlocalhost start-scripts# pwd/usr/local/src/tgresql-9.4.2/contrib/start-scriptsrootlocalhost start-scripts# cp /usr/local/src/tgresql-9.4.2/contrib/start- scripts/linux /etc/init.d/tgresqlrootlocalhost start-scripts# cd /etc/init.d/ rootlocalhost init.d# ls -l|grep -itgresql-rw-r-r- 1 root

8、root 3437 Jul 29 09:45tgresql rootlocalhost init.d#od +xtgresql rootlocalhost init.d# vitgresql #prefix=/usr/local/pgsqlprefix=/usr/local/pgsql -tgresql 安装路径#PGDATA=/usr/local/pgsql/data PGDATA=/PGDATA/data -tgresql 的数据目录路径设置tgresql 服务开机自启动rootlocalhost init.d# chkconfig -addtgresql5 初始化数据库rootlocal

9、hostmkdir -p /PGDATA/data rootlocalhostn -Rtgres:tgres /PGDATA rootlocalhost su -tgrestgreslocalhost $/usr/local/tgresql-9.4.2/bin/initdbexport PATH PATH=$PATH:$HOME/bin # .bash_profile# Get the aliases and functions if -f /.bashrc ; then. /.bashrcfi# User specific environment and startup programs e

10、xport PGPORT=5432export PGHOME=/usr/local/pgsql export PGDATA=/PGDATA/dataexport PATH=$PGHOME/bin:$PATH:$HOME/binexport LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH tgreslocalhost $ source .bash_profile配置tgres 数据库(/pgdata/data 下)1.tgreslocalhost $ cd /PGDATA/datavi pg_hba.conf# TYPE DATABASE USER AD

11、DRESS METHOD# local is for Unix local all all trust# IPv4 local connections: socket connections onlyhost all all 127.0.0.1/32 trust# IPv6 local connections: host all all :1/128 trusthost all all 192.168./24 trust# Allow replication connections from localhost, by a user with the# replication privileg

12、e.#local replication #host replication tgres trusttgres 127.0.0.1/32 trust2. 修改tgreSQL.conf 文件 tgresxing data$ cattgresql.conf#tgreSQL configuration file# This file consists of lines of the form:# name = value# (The = is optional.) Whitespace may be used. Comments are roduced with# # anywhere on a l

13、ine. The comple ist of parameter names and allowed# values can be foundhetgreSQLation.# The commented-out settings shownhis file represent the default values.#menting a setting is NOT sufficient to revert it to the default value;# you need to reload the server.# This file is read on server startup a

14、nd when the server receives a SIGHUP# signal. If you edit the file on a running system, you have to SIGHUP the# server for the changes to take effect, or use pg_ctl reload. Some# parameters, which are marked below, require a server shutdown and restart to# take effect.# Any parameter cso be given as

15、 ad-line option to the server, e.g.,# tgres -c log_connections=on. Some parameters can be changed at run time# with the SET SQLd.# Memory units:kB = kilobytesTime units:ms= milliseconds#MB = megabytess = seconds#GB = gigabytesmin = minutes#TB = terabytesh = hours修改tgreSQL 配置文件添加网段 192.168.数据库#d = da

16、y# FILE LOCATIONS#-# The default values of these variables are driven from the -Dd-line# option or PGDATA environment variable, represented here as ConfigDir.#data_directory = ConfigDir# use data in another directory# (change requires restart)#hba_file = ConfigDir/pg_hba.conf# host-based authenticat

17、ion file# (change requires restart)#ident_file = ConfigDir/pg_ident.conf # ident configuration file# (change requires restart)# If external_ _file is not explicitly set, no extrafile is written.#external_ _file = # write an extrafile# (change requires restart)# CONNECTIONS AND AUTHENTICATION#-# - Co

18、nnection Settings -listen_addresses = *# what IP address(es) to listen on;# comma-separated list of addresses;# defaults to localhost; use * for all# (change requires restart)port = 5432# (change requires restart)max_connections = 300# (change requires restart)# Note: Increasing max_connections cost

19、s 400 bytes of shared memory per# connection slot, plus lock space (see max_locks_per_tranion).#superuser_connections = 3# (change requires restart)#unix_socket_directories = /tmp# comma-separated list of directories# (change requires restart)#unix_socket_group = # (change requires restart)#unix_soc

20、ket_permiss = 0777# begin with 0 to use octal no ion# (change requires restart)#bonjour = off# advertise server via Bonjour# (change requires restart)#bonjour_name = # defaults to the computer name# (change requires restart)# - Security and Authentication -#authentication_timeout = 1min# 1s-600s#ssl

21、 = off# (change requires restart)#ssl_ciphers = HIGH:MEDIUM:+3DES:!aNULL # allowed SSL ciphers# (change requires restart)#ssl_prefer_server_ciphers = on# (change requires restart)#ssl_ecdh_curve = prime256v1# (change requires restart)#ssl_renegotiation_limit = 512MB# amount of data betn renegotiatio

22、ns#ssl_cert_file = server.crt# (change requires restart)#ssl_key_file = server.key# (change requires restart)#ssl_ca_file = # (change requires restart)#ssl_crl_file = # (change requires restart)#password_encryption = on#db_user_namespace = off# GSSAPI using Kerberos#krb_server_keyfile = #krb_caseins

23、_users = off# - TCP Keepalives -# see man 7 tcp for details#tcp_keepalives_idle = 0# TCP_KE DLE, in seconds;# 0 selects the system default#tcp_keepalives_ erval = 0# TCP_KE NTVL, in seconds;# 0 selects the system default#tcp_keepalives_count = 0#T;# 0 selects the system default# RESOURCE USAGE (exce

24、pt WAL)#-# - Memory -shared_buffers = 512MB# min 128kB# (change requires restart)#huge_pages = try# on, off, or try# (change requires restart)#temp_buffers = 8MB# min 800kB#max_prepared_tranions = 0# zero disables the feature# (change requires restart)# Note: Increasing max_prepared_tranions costs 6

25、00 bytes of shared memory# per tranion slot, plus lock space (see max_locks_per_tranion).# It is not advisable to set max_prepared_tranions nonzero unless you# actively end to use prepared tranions.#work_mem = 4MB# min 64kB#ma enance_work_mem = 64MB# min 1MB#autovacuum_work_mem = -1# min 1MB, or -1

26、to use ma enance_work_mem#max_stack_depth = 2MB# min 100kBdynamic_shared_memory_type =ix# the default is theoption# supported by the operating system:#ix# sysv# windows# mmap# use none to disable dynamic shared memory# - Disk -#temp_file_limit = -1# limits per-sestemp file space# in kB, or -1 for no

27、 limit# - Kernel Resource Usage -#max_files_per_pro s = 1000# min 25# (change requires restart)#shared_preload_libraries = # (change requires restart)# - Cost-Based Vacuum Delay -#vacuum_cost_delay = 0# 0-100 milliseconds#vacuum_cost_page_hit = 1# 0-10000 credits#vacuum_cost_page_miss = 10# 0-10000

28、credits#vacuum_cost_page_dirty = 20# 0-10000 credits#vacuum_cost_limit = 200# 1-10000 credits# - Background Writer -#bgwriter_delay = 200ms# 10-10000ms betn rounds#bgwriter_lru_maxpages = 100# 0-1000 max buffers written/round#bgwriter_lru_multip r = 2.0# 0-10.0 multipler on buffers scanned/round# -

29、Asynchronous Behavior -#effective_io_concurrency = 1# 1-1000; 0 disables prefetching#max_worker_pro ses = 8# WRITE AHEAD LOG#-# - Settings -wal_level = hot_standby# minimal, archive, hot_standby, or logical# (change requires restart)#fsync = on# turns forced synchronization on or offmit = on# synchr

30、onization level;# off, local, remote_write, or on#wal_sync_method = fsync# the default is theoption# supported by the operating system:#open_datasync#fdatasync (default on Linux)#fsync#fsync_writethrough#open_sync#full_page_writes = on# recover from partial page writes#wal_log_h s = off# also do ful

31、l page writes of non-critical updates# (change requires restart)#wal_buffers = -1# min 32kB, -1 sets based on shared_buffers# (change requires restart)#wal_writer_delay = 200ms# 1-10000 milliseconds#commit_delay = 0# range 0-100000,icroseconds#commit_siblings = 5# range 1-1000# - Checkpo s -checkpo

32、_segments = 16# in logfile segments, min 1, 16MB each#checkpo _timeout = 5min# range 30s-1hpletion_= 0.5# checkpoduration, 0.0 - 1.0#checkpo _warning = 30s# 0 disables# - Archiving -archive_mode = on# allows archiving to be done# (change requires restart)mand = cp -i %p /PGDATA/archive_log/%f#d to u

33、se to archive a logfile segment# placeholders: %p = path of file to archive#%f = file name only# e.g. test ! -f /mnt/server/archivedir/%f & cp %p /mnt/server/archivedir/%f#archive_timeout = 0# force a logfile segment switch after this# number of seconds; 0 disables# REPLICATION#-# - Sending Server(s

34、) -# Set these on the master and on any standbyt will send replication data.max_wal_senders = 5# max number of walsendro ses# (change requires restart)wal_keep_segments = 1000# in logfile segments, 16MB each; 0 disables#wal_sender_timeout = 60s#illiseconds; 0 disables#max_replication_slots = 0# max

35、number of replication slots# (change requires restart)# - Master Server -# These settings are ignored on a standby server.#synchronous_standby_names = # standby serverst provide sync rep# comma-separated list of application_name# from standby(s); * = all#vacuum_defer_cleanup_age = 0 # number of xact

36、s by which cleanup is delayed# - Standby Servers -# These settings are ignored on a master server.hot_standby = on# on allows queries during recovery# (change requires restart)#max_standby_archive_delay = 30s# max delay before canceling queries# when reading WAL from archive;# -1 allows indefinite d

37、elay#max_standby_streaming_delay = 30s# max delay before canceling queries# when reading streaming WAL;# -1 allows indefinite delay#wal_receiver_s us_ erval = 10s# send rep s east this often# 0 disables#hot_standby_feedback = off# send info from standby to prevent# querys#wal_receiver_timeout = 60s#

38、 time t receiver waits for# communication from master#illiseconds; 0 disables# QUERY TUNING#-# - Planner Method Configuration -#enable_bitmapscan = on#enable_hashagg = on#enable_hashjoin = on#enable_indexscan = on#enable_indexonlyscan = on#enable_material = on#enable_mergejoin = on#enable_nestloop =

39、 on#enable_seqscan = on#enable_sort = on#enable_tidscan = on# - Planner Cost Constants -#seq_page_cost = 1.0# measured on an arbitrary scale#random_page_cost = 4.0# same scale as above#cpu_tuple_cost = 0.01# same scale as above#cpu_index_tuple_cost = 0.005# same scale as above#cpu_operator_cost = 0.

40、0025# same scale as above#effective_cache_size = 4GB# - Genetic Query Optimizer -#geqo = on#geqo_threshold = 12#geqo_effort = 5# range 1-10#geqo_pool_size = 0# selects default based on effort#geqo_generations = 0# selects default based on effort#geqo_selection_bias = 2.0# range 1.5-2.0#geqo_seed = 0

41、.0# range 0.0-1.0# - Othlanner Options -#default_s istics_= 100# range 1-10000#constra _exclu= partition# on, off, or partition#cursor_tuple_fraction = 0.1# range 0.0-1.0#from_collapse_limit = 8#join_collapse_limit = 8# 1 disables collapsing of explicit# JOIN clauses# ERROR REPORTING AND LOGGING#-#

42、- Where to Log -log_destination = csvlog# Valid values are combinations of# stderr, csvlog, syslog, and eventlog,# depending on platform. csvlog# requires logging_collector to be on.# This is used when logging to stderr:logging_collector = on# Enable capturing of stderr anvlog# o log files. Required

43、 to be on for# csvlogs.# (change requires restart)# These are only used if logging_collector is on:log_directory = /PGDATA/data/pg_log# directory where log files are written,# can be absolute or relative to PGDATAlog_filename = tgresql-%Y-%m-%d_%H%M%S.log # log file name pattern,# can include strfti

44、me() esc s#log_file_mode = 0600# creation mode for log files,# begin with 0 to use octal no ion#log_truncate_on_ro ion = off# If on, an existing log file with the# same name as the new log file will be# truncated rather n appended to.# But such truncation only occurs on# time-driven ro ion, not on r

45、estarts# or size-driven ro ion. Default is# off, meaning append to existing files# in all cases.#log_ro ion_age = 1d# Automatic ro ion of logfiles will# happen aftert time. 0 disables.#log_ro ion_size = 10MB# Automatic ro ion of logfiles will# happen aftert much log output.# 0 disables.# These are r

46、elevant when logging to syslog:#syslog_facility = LOCAL0#syslog_ident = tgres# This is only relevant when logging to eventlog (win32):#event_source = tgreSQL# - When to Log -#c nt_min_messages = notice# values in order of decreasing detail:#debug5#debug4#debug3#debug2#debug1#log#notice#warning#error

47、#log_min_messages = warning# values in order of decreasing detail:#debug5#debug4#debug3#debug2#debug1#info#notice#warning#error#log#fatal#panic#log_min_error_s ement = error# values in order of decreasing detail:#debug5#debug4#debug3#debug2#debug1#info#notice#warning#error#log#fatal#panic (effective

48、ly off)#log_min_duration_s ement = -1# -1 is disabled, 0 logs all s ements# and their durations, 0 logs only# s ements running east this number# of milliseconds# - What to Log -#debug_pr_parse = off#debug_pr_rewritten = off#debug_pr_plan = off#debug_pretty_pr = on#log_checkpo s = off#log_connections

49、 = off#log_disconnections = off#log_duration = off#log_error_ver ity = default# terse, default, or ver e messages#log_hostname = off#log_line_prefix = %t %r %a %d %c %u# spe l values:#%a = application name#%u = user name#%d = database name#%r = remote host and port#%h = remote host#%p = pro s ID#%t

50、= timestwithout milliseconds#%m = timestwith milliseconds#%i =d tag#%e = SQL se#%c = sesID#%l = sesline number#%s = sesstart timest#%v = virtual tranion ID#%x = tranion ID (0 if none)#%q = stop here in non-ses#pro ses#% = %# e.g. #log_lock_waits = off# log lock waits = deadlock_timeout#log_s ement =

51、 none# none, ddl, mod, all#log_temp_files = -1# log temporary files equal or larger#n the specified size in kilobytes;# -1 disables, 0 logs all temp fileslog_timezone = PRC# RUNTIME S ISTICS#-# - Query/Index S istics Collector -#track_activities = on#track_counts = on#track_io_timing = off#track_fun

52、ctions = none# none, pl, all#track_activity_query_size = 1024# (change requires restart)#update_pro s_title = on#s s_temp_directory = pg_s _tmp# - S istics Monitoring -#log_parser_s s = off#log_planner_s s = off#log_executor_s s = off#log_s ement_s s = off# AUTOVACUUM PARAMETERS#autovacuum = on# Ena

53、ble autovacuum subpro s? on# requires track_counts to also be on.#log_autovacuum_min_duration = -1# -1 disables, 0 logs all actions and# their durations, 0 logs only# actions running east this number# of milliseconds.#autovacuum_max_workers = 3# max number of autovacuum subpro ses# (change requires

54、restart)#autovacuum_naptime = 1min# time betn autovacuum runs#autovacuum_vacuum_threshold = 50# min number of row updates before# vacuum#autovacuum_yze_threshold = 50# min number of row updates before#yze#autovacuum_vacuum_scale_factor = 0.2# fraction of table size before vacuum#autovacuum_yze_scale

55、_factor = 0.1# fraction of table size beforeyze#autovacuum_freeze_max_age = 200000000 #um XID age before forced vacuum# (change requires restart)#autovacuum_multixact_freeze_max_age = 400000000#um multixact age# before forced vacuum# (change requires restart)#autovacuum_vacuum_cost_delay = 20ms# def

56、ault vacuum cost delay for# autovacuum,illiseconds;# -1 means use vacuum_cost_delay#autovacuum_vacuum_cost_limit = -1# default vacuum cost limit for# autovacuum, -1 means use# vacuum_cost_limit# C NT CONNECTION DEFAULTS#-# - S ement Behavior -#search_path = $user,public# schema names#default_tablesp

57、ace = # a tablespace name, uses the default#temp_tablespa= # a list of tablespace names, uses# only default tablespace#check_function_bodies = on#default_tranion_isolation = read committed#default_tranion_read_only = off#default_tranion_deferrable = off#ses_replication_role = origin#s ement_timeout

58、= 0#illiseconds, 0 is disabled#lock_timeout = 0#illiseconds, 0 is disabled#vacuum_freeze_min_age = 50000000#vacuum_freeze_table_age = 150000000#vacuum_multixact_freeze_min_age = 5000000#vacuum_multixact_freeze_table_age = 150000000#bytea_output = hex# hex, esc#xmlbinary = base64#xmloption = content#

59、 - Locale and Formatting -datestyle = iso, mdy# ervalstyle =tgrestimezone = PRC#timezone_abbreviations = Default# Select the set of available time zone# abbreviations. Currently, there are# Default# Australia (historical usage)# You can create your own file in# share/timezots/.#extra_float_digits =

60、0# min -15, max 3#c nt_encoding = sql_ascii# actually, defaults to database# encoding# These settings are initialized by initdb, but they can be changed.lc_messages = en_US.utf8# locale for system error message# stringslc_monetary = en_US.utf8# locale for monetary formattinglc_numeric = en_US.utf8#

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论