postmaster

Name

postmaster -- PostgreSQL���û����ݿ������

Synopsis

postmaster [-A 0 | 1 ] [-B nbuffers] [-c name=value] [-d debug-level] [-D datadir] [-F] [-h hostname] [-i] [-k directory] [-l] [-N max-connections] [-o extra-options] [-p port] [-S] [--name=value] [-n | -s]

����

postmaster �� PostgreSQL ���û����ݿ�������� һ���ͻ���Ϊ�˷���һ�����ݿ⣬����ͨ������򱾵أ����ӵ�һ�������ŵ� postmaster�� Ȼ��� postmaster ����һ�������ķ��������̣�"postgres"�� �Բ������ӡ�postmaster �����Ʒ���������֮���ͨѶ��

ȱʡʱpostmaster��ǰ̨�����������׼����ϵͳ�����ӡ��־��Ϣ�� ��ʵ��Ӧ���postmasterӦ����Ϊ��̨����������Ҳ���������ʱ��

һ��postmaster���ǹ�������ͬһ�����ݿ⼯Ⱥ�����ݡ� һ�����ݿ⼯Ⱥ��һ����ͬһ���ļ�ϵͳλ�ô�����ݵ����ݿ⣨"������"���� һ��ϵͳ��ͬʱ�������м���postmaster���̣� ֻҪ����ʹ�ò�ͬ���������Ͳ�ͬ�Ķ˿ںţ������ģ��� һ������������ initdb �����ġ�

postmaster ������ʱ������Ҫ֪�����ݿ�����λ�á� ��λ��ͨ�� -D ѡ����� PGDATA �������������ģ� û��ȱʡֵ��ͨ����-D ���� PGDATA ָ��һ�� initdb ������Ŀ¼�� �������ܵIJ����� Section 16.4.1 �����ۡ�

ѡ��

postmaster �������������в����� ������Щѡ��ĸ���ϸ��������ο� Section 16.4�� ��Ҳ����ͨ������һ�������ļ��������û���Щѡ�

-A 0|1

������ʱ���Լ�飬�Ǽ���̴���ĵ��԰����� ֻ���ڱ��� PostgreSQL ʱ�������������ʹ�������������ʱ���ˣ�ȱʡ�Ǵ򿪡�

-B nbuffers

Ϊ���������̷���͹���Ĺ����ڴ滺���������� ���������ȱʡֵ�� initdb �Զ�ѡ��ģ� �ο� Section 16.4.3.1 ��ȡ������Ϣ��

-c name=value

����һ������������ʱ������PostgreSQL ֧�ֵ����ò����� Section 16.4 �������� ���������������ѡ��ʵ���϶��������IJ�����ֵ�Ķ���ʽ�� -c ���Գ��ֶ���������ö��������

-d debug-level

���õ��Լ�����ֵԽ�ߣ�д����������־�ĵ������Խ�ࡣ ��ֵ��Χ�� 1 �� 5��

-D datadir

��������Ŀ¼���������ļ����ļ�ϵͳ·����ϸ����� Section 16.4.1��

-F

�ر� fsync ���ã�������ܣ�����Ҫðϵͳ����ʱ���ݻٻ��ķ��ա� �������ѡ���Ч�ر��� fsync ��������ʹ��֮ǰ�Ķ���ϸ�ĵ���

--fsync=true �������ѡ��ķ���Ч����

-h hostname

���� postmaster �����ŵȴ�����ǰ��Ӧ�� TCP/IP ���ӵ� IP ���������ַ�� ��ֵҲ������һ���ÿո�ָ��ĵ�ַ�б�����*��ʾ�������п��õĵ�ַ�� ��ֵ��ʾ�������κ� IP ��ַ����ֻ��ʹ�� Unix ���׽��������� postmaster �����ӡ� ȱʡ��ʱ����ֻ���� localhost�� �������ѡ���Ч������ listen_addresses ���ò�����

-i

���ѡ��� TCP/IP ���������׽��֣�ͨѶ�� û�����ѡ�ֻ�ܽ��ܱ������ӡ� ���ѡ���Ч���� postgresql.conf �л���ͨ�� -h ���� listen_addresses Ϊ *��

���ѡ���Ѿ������ˣ���Ϊ������ʵ�� listen_addresses �����й��ܡ� �������ֱ������ listen_addresses��

-k directory

���� postmaster �����ŵȴ�����ǰ��Ӧ�����ӵ� Unix ���׽��ֵ�λ�á� ȱʡͨ���� /tmp�����ǿ�����������ʱ���޸ġ�

-l

���ѡ����� SSL ���еİ�ȫͨѶ��Ҫʹ�����ѡ�����PostgreSQLʱ�������� SSL ѡ� �й�ʹ�� SSL ����Ϣ����ο� Section 16.7��

-N max-connections

����postmaster���������ķ������������������Ŀ��ȱʡ����ʱ����ֵΪ 32�� ������ϵͳ��֧�ָ�����̣���ֵ����������Ϊ���ϵͳ����֧�ֵļ��ޡ� ʱ�޸ģ����� src/include/config.h���� ����ע��-Bѡ��Ҫ������������-N���� Section 16.5 ��ȡ�йش�ͻ�����ϵͳ��Դ���󡣣� �������ѡ���Ч������ max_connections ���ò�����

-o extra-options

�� extra-options �������� postgres ѡ����ݸ���������� postmaster �����ķ�����̡� ���� postgres ��ȡ����ѡ� ���ѡ���ִ������κοհף������ִ�������������

-p port

���� postmaster �����ŵȴ��ͻ���Ӧ�����ӵĻ����� TCP/IP �˿ڻ�һ������ Unix ���׽����ļ���չ������������ ȱʡ�Ķ˿ں��ǻ������� PGPORT ��ֵ�����û������ PGPORT ȱʡ�� PostgreSQL ����ʱ������ֵ��ͨ���� 5432���� �����������һ����ȱʡ�˿ڣ���ô����ǰ��Ӧ�ã����� psql����������������ѡ����� PGPORT ����ͬһ���˿ڡ�

-S

ָ�� postmaster ���̽��԰���ģʽ������Ҳ����˵�� �������û��ģ����ƣ�tty ���벢������������Ľ����顣 �������ѱ�׼����ͱ�׼�����ض��� /dev/null��

ʹ��������ػὫ��־��������������ܲ�����ϣ���ģ� ��Ϊ�����������ҷdz����ѡ��������Ļ�ȡһ���ں�̨���� postmaster �ĸ��õķ�����

--silent_mode=false �����ú����ѡ���Ч�������෴��

--name=value

����һ������������ʱ����������д��ʽ�� -c��

�����������������ѡ��������ڵ��Ե��·������쳣�˳��� ��������״����һ�������֪ͨ�������������������˳��� Ȼ�����³�ʼ�������ڴ���źŵơ�������Ϊһ������ķ��������˳�ǰ�����Ѿ��ƻ���һЩ�����״̬�� ��Щѡ��������ֻ����µ� postmaster �����ʣ�����û���ĸ�ѡ����Ϊ��ͨ����׼������

��Щ����ѡ���ǣ�

-n

postmaster ���������³�ʼ���������ݽṹ�� һ���о����ϵͳ����Ա��ʱ�Ϳ���ʹ�õ�������鹲���ڴ���źŵ�״̬��

-s

postmaster ��ͨ�������ź�SIGSTOP ֹͣ�����������������̣������ᵼ�������˳��� ����������ϵͳ����Ա�ֹ������з����������ռ��㵹�ĺ��ģ�core dumps����

����

PGCLIENTENCODING

�ͻ���ʹ�õ�ȷȱʡ�ַ����롣���ͻ��˿��Զ����ظ�������������ֵҲ�����������ļ������á�

PGDATA

ȱʡ����Ŀ¼λ��

PGDATESTYLE

����ʱ���� DateStyle ��ȱʡֵ�����Ѿ����ٹ���ʹ�û��������ˡ���

PGPORT

ȱʡ�˿ڣ�����������ļ������ã�

TZ

������ʱ��

���

һ���ᵽ�� semget ���� shmget �Ĵ�����Ϣ������ζ������Ҫ��������ںˣ� �ṩ�㹻�Ĺ����ڴ���źŵơ��������ۣ����� Section 16.5��

��ʾ: ��Ҳ����ͨ������ shared_buffers ����ֵ�Լ��� PostgreSQL�Ĺ����ڴ�����ģ� ���߽���max_connections�IJ���ֵ����PostgreSQL���źŵƵ����ģ� �Դ˿����Ƴ����������ںˡ�

�����һ��˵����һ�� postmaster �������еĴ�����Ϣ������Ӧ��ȷ��û�������� postmaster �����������С��ж�����������򵥵İ취��ʹ������

$ ps ax | grep postmaster

����

$ ps -e | grep postmaster

����ʹ������ȡ�������ϵͳ�����ȷ��û�г�ͻ�� postmaster �����У���ô�����ɾ����Ϣ���ᵽ�����ļ�Ȼ���ٴ����С�

һ��˵�޷��󶨶˿ڵĴ�����Ϣ���ܱ����ö˿��Ѿ��������� PostgreSQL ����ʹ�á� �������ֹpostmaster����������ͬһ���˿�����������Ҳ�п��ܵõ����������Ϣ�� ��ʱ��������ȼ��룬�Ȳ���ϵͳ�ر��˸ö˿ں����ԡ� ��������ʹ����һ������ϵͳ��Ϊ�DZ����Ķ˿ڣ�Ҳ���ܵ������������Ϣ�� ���磬�ҵ� Unix �汾��Ϊ���� 1024 �Ķ˿ں���"�����ε�"�����ֻ�� Unix �����û�����ʹ�����ǡ�

ע��

����п��ܣ���Ҫʹ�� SIGKILLɱ�� postmaster�� ��������ֹ postmaster���˳�ǰ�ͷ������е�ϵͳ��Դ�����繲���ڴ���źŵƣ���

Ҫ�������� postmaster������ʹ���ź� SIGTERM��SIGINT�� �� SIGQUIT�� ��һ���źŽ��ȴ����еĿͻ����˳�����˳��� �ڶ�����ǿ�ƶϿ����пͻ��ˣ�������������ֹͣ�����˳��� ����������ʱ�Ļָ����С�

�������� pg_ctl �������ڰ�ȫ����Ч����ͣ postmaster��

-- ��FreeBSD���� OpenBSD���޷����С� Ӧ���� -c��������Ӱ���ϵͳ���Ǹ����棻 ������ë��û���޲��ã������� PostgreSQL �汾���ṩһ���ƿ��İ취��

����

��ȱʡֵ�ں�̨����postmaster�����룺

$ nohup postmaster >logfile 2>&1 </dev/null &

��ָ���Ķ˿����� postmaster��

$ postmaster -p 1234

��������ڶ˿� 1234 ���� postmaster�� Ϊ����psql����� postmaster ���ӣ� ��Ӧ����ô����psql

$ psql -p 1234

�������û������� PGPORT��

$ export PGPORT=1234
$ psql

����������ʱ�������������еķ��֮һ���ã�

$ postmaster -c work_mem=1234
$ postmaster --work-mem=1234

������ʽ��������Щ���е��� postgresql.conf ����� work_mem �����á� ��ע���ڲ���������»������������Ͽ���д���»��ߣ�Ҳ����д�ɻ��ߡ�

��ʾ: �������ڶ��ڵ�ʵ�����⣬���õ�ϰ���DZ༭���� postgresql.conf ��������ã� ���������������п������ò�����

�ּ�

initdb, pg_ctl