规划

192.168.56.11  k1
192.168.56.12  k2
192.168.56.13  k3
192.168.56.21  pg11n1
192.168.56.22  pg11n2

主机 pg11n1 、pg11n2上安装 postgresql 11

安装 yum 源

# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm;
yum clean all;
yum makecache;

# yum install postgresql11*

初始化 postgresql

pg_hba 文件

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

host	all             all             192.168.56.0/24         md5

# IPv6 local connections:
host    all             all             ::1/128                 trust

# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

postgresql.conf 文件

listen_addresses = '*'		# what IP address(es) to listen on;
port = 5432				# (change requires restart)
max_connections = 1000			# (change requires restart)
superuser_reserved_connections = 10	# (change requires restart)
shared_buffers = 256MB			# min 128kB
huge_pages = try			# on, off, or try
temp_buffers = 8MB			# min 800kB
work_mem = 4MB				# min 64kB
maintenance_work_mem = 64MB		# min 1MB
dynamic_shared_memory_type = posix	# the default is the first option
wal_level = logical			# minimal, replica, or logical
fsync = on				# flush data to disk for crash safety
synchronous_commit = on		# synchronization level;
wal_sync_method = fsync		# the default is the first option
full_page_writes = on			# recover from partial page writes
wal_compression = off			# enable compression of full-page writes
wal_log_hints = on			# also do full page writes of non-critical updates
max_wal_size = 1GB
min_wal_size = 80MB
wal_keep_segments = 100		# in logfile segments; 0 disables
wal_sender_timeout = 60s	# in milliseconds; 0 disables
track_commit_timestamp = on	# collect timestamp of transaction commit
hot_standby = on			# "off" disallows queries during recovery
hot_standby_feedback = on		# send info from standby to prevent
max_logical_replication_workers = 4	# taken from max_worker_processes
max_sync_workers_per_subscription = 2	# taken from max_logical_replication_workers
effective_cache_size = 2GB
log_destination = 'csvlog'		# 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-%a.log'	# log file name pattern,
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 = 0			# Automatic rotation of logfiles will
log_checkpoints = on
log_connections = on
log_disconnections = on
log_line_prefix = '%m [%p] '		# special values:
log_lock_waits = on			# log lock waits >= deadlock_timeout
log_statement = 'ddl'			# none, ddl, mod, all
log_replication_commands = on
log_timezone = 'Asia/Shanghai'
cluster_name = 'pg11n1'			# added to process titles if nonempty
track_activities = on
track_counts = on
track_io_timing = on
track_functions = none			# none, pl, all
track_activity_query_size = 102400	# (change requires restart)
stats_temp_directory = 'pg_stat_tmp'
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'
shared_preload_libraries = 'pg_stat_statements'	# (change requires restart)
deadlock_timeout = 2s

创建业务用户及业务数据库

模拟生产端、消费端

# su - postgresql
$ psql

postgres=# create user yewu with password 'yewuyewu';
create database yewudb owner=yewu;

参考:
https://ctypyb2002.blog.csdn.net/article/details/84861859
https://ctypyb2002.blog.csdn.net/article/details/84869547
https://www.postgresql.org/download/linux/redhat/

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐