Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

split some config and sql file from INSTALL

  • Loading branch information...
commit 6f0558212448449cd860e415a942acff64c08ac9 1 parent 229e4f7
@digoal authored
View
2  INSTALL.txt
@@ -1,4 +1,4 @@
-SAMPLE :
+sky PostgreSQL Cluster Implement Example :
PostgreSQL HA 环境 :
服务器 : DELL R610 8G MEM
View
3  TUTORIAL.txt
@@ -67,6 +67,9 @@ ip, port, lag
+# Author : Digoal zhou
+# Email : digoal@126.com
+# Blog : http://blog.163.com/digoal@126/
View
6 example.pgpass
@@ -0,0 +1,6 @@
+192.168.169.110:1921:replication:replica:REPLICA321
+192.168.169.111:1921:replication:replica:REPLICA321
+192.168.169.116:1921:replication:replica:REPLICA321
+192.168.169.116:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
+127.0.0.1:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
+192.168.101.35:11921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
View
55 postgresql.example.conf
@@ -0,0 +1,55 @@
+listen_addresses = '0.0.0.0' # what IP address(es) to listen on;
+port = 1921 # (change requires restart)
+max_connections = 1000 # (change requires restart)
+superuser_reserved_connections = 13 # (change requires restart)
+unix_socket_directory = '.' # (change requires restart)
+unix_socket_permissions = 0700 # begin with 0 to use octal notation
+tcp_keepalives_idle = 60 # TCP_KEEPIDLE, in seconds;
+tcp_keepalives_interval = 10 # TCP_KEEPINTVL, in seconds;
+tcp_keepalives_count = 10 # TCP_KEEPCNT;
+shared_buffers = 1024MB # min 128kB
+maintenance_work_mem = 512MB # min 1MB
+max_stack_depth = 8MB # min 100kB
+shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
+vacuum_cost_delay = 10ms # 0-100 milliseconds
+vacuum_cost_limit = 5000 # 1-10000 credits
+bgwriter_delay = 10ms # 10-10000ms between rounds
+wal_level = hot_standby # minimal, archive, or hot_standby
+synchronous_commit = off # synchronization level;
+wal_sync_method = fdatasync # the default is the first option
+wal_writer_delay = 10ms # 1-10000 milliseconds
+checkpoint_segments = 128 # in logfile segments, min 1, 16MB each
+archive_mode = on # allows archiving to be done
+archive_command = '/bin/date' # command to use to archive a logfile segment
+max_wal_senders = 32 # max number of walsender processes
+wal_keep_segments = 1024 # in logfile segments, 16MB each; 0 disables
+hot_standby = on # "on" allows queries during recovery
+max_standby_archive_delay = 300s # max delay before canceling queries
+max_standby_streaming_delay = 300s # max delay before canceling queries
+wal_receiver_status_interval = 1s # send replies at least this often
+hot_standby_feedback = on # send info from standby to prevent
+random_page_cost = 2.0 # same scale as above
+effective_cache_size = 8192MB
+log_destination = 'csvlog' # Valid values are combinations of
+logging_collector = on # Enable capturing of stderr and csvlog
+log_directory = '/var/applog/pg_log/digoal/1921' # directory where log files are written,
+log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
+log_file_mode = 0600 # creation mode for log files,
+log_truncate_on_rotation = on # If on, an existing log file with the
+log_rotation_age = 1d # Automatic rotation of logfiles will
+log_rotation_size = 10MB # Automatic rotation of logfiles will
+log_checkpoints = on
+log_statement = 'ddl' # none, ddl, mod, all
+log_timezone = 'PRC'
+autovacuum = on # Enable autovacuum subprocess? 'on'
+log_autovacuum_min_duration = 0 # -1 disables, 0 logs all actions and
+autovacuum_max_workers = 3 # max number of autovacuum subprocesses
+datestyle = 'iso, mdy'
+timezone = 'PRC'
+lc_messages = 'C' # locale for system error message
+lc_monetary = 'C' # locale for monetary formatting
+lc_numeric = 'C' # locale for number formatting
+lc_time = 'C' # locale for time formatting
+default_text_search_config = 'pg_catalog.english'
+pg_stat_statements.max = 1000
+pg_stat_statements.track = all
View
4 recovery.example.conf
@@ -0,0 +1,4 @@
+recovery_target_timeline = 'latest'
+standby_mode = on
+primary_conninfo = 'host=192.168.169.116 port=1921 user=replica keepalives_idle=60' # e.g. 'host=localhost port=1921'
+trigger_file = '/data/pgdata/pg_root/.1921.trigger'
View
30 sky_postgresql_cluster.example.sql
@@ -0,0 +1,30 @@
+-- 新建pg_stat_statements模块
+\c postgres postgres
+create extension pg_stat_statements;
+-- 新建流复制角色用户
+create role replica nosuperuser nocreatedb nocreaterole noinherit replication connection limit 32 login encrypted password 'REPLICA321';
+
+-- 新建集群角色
+create role sky_pg_cluster nosuperuser nocreatedb nocreaterole noinherit login encrypted password 'SKY_PG_cluster_321';
+create database sky_pg_cluster with template template0 encoding 'UTF8' owner sky_pg_cluster;
+\c sky_pg_cluster sky_pg_cluster
+create schema sky_pg_cluster authorization sky_pg_cluster;
+create table cluster_status (id int unique default 1, last_alive timestamp(0) without time zone);
+-- 限制cluster_status表有且只有一行 :
+CREATE FUNCTION cannt_delete ()
+RETURNS trigger
+LANGUAGE plpgsql AS $$
+BEGIN
+ RAISE EXCEPTION 'You can not delete!';
+END; $$;
+
+CREATE TRIGGER cannt_delete
+BEFORE DELETE ON cluster_status
+FOR EACH ROW EXECUTE PROCEDURE cannt_delete();
+
+CREATE TRIGGER cannt_truncate
+BEFORE TRUNCATE ON cluster_status
+FOR STATEMENT EXECUTE PROCEDURE cannt_delete();
+
+-- 插入初始数据
+insert into cluster_status values (1, now());
Please sign in to comment.
Something went wrong with that request. Please try again.