16.3. �������ݿ������

���κ��˿��Է������ݿ�ǰ��������������ݿ�������� ���ݿ�������� postmaster�� postmaster ����֪�����������ҵ���Ҫ�õ����ݡ��������� -D ѡ����ʵ�ֵġ� ��ˣ���������������򵥵ķ����ǣ�����������������

$ postmaster -D /usr/local/pgsql/data

�������ѷ���������ǰ̨���С��������ͬ��������PostgreSQL �û��ʻ���¼������û�� -D ѡ���������ʹ�û������� PGDATA ������Ŀ¼�� ��������������Ҳû�У���������ʧ�ܡ�

ͨ��������ں�̨���� postmaster�� ʹ������� shell �﷨��

$ postmaster -D /usr/local/pgsql/data > logfile 2>&1 &

�ѷ�������stdout��stderr�ŵ�ij���ط��Ƿdz���Ҫ�ģ����������潨��������� �������ȿ��԰�������ֿ��԰���������⡣ ������ Section 21.3 ��ȡ�й���־�ļ�����ĸ����������ۡ���

postmaster ������һЩ������һЩ������ѡ� �������Ϣ��ο��ֲ�ҳ postmaster ������� Section 16.4��

��Щ shell �﷨���������˾������ġ���������ṩ�˷�װ���� pg_ctl �Լ�һЩ���񡣱��磬

pg_ctl start -l logfile

���ں�̨�������������Ұ�����ŵ�ָ������־�ļ��С� -D ѡ�����ֱ������postmasterʱ����˼��һ���ġ� pg_ctl ���������ڹرշ�������

ͨ�������ϣ���ڼ����������ʱ���������ݿ�������� �Զ������ű��������ϵͳ��صġ� PostgreSQL �Լ����˼����� ���� contrib/start-scripts Ŀ¼� Ҫ�밲װ����һ��������Ҫ root Ȩ�ޡ�

��ͬ��ϵͳ��������ʱ���в�ͬ�������ػ����̵ķ������������ǽ���������Ϥ���ǡ� ���ϵͳ�����ֳ�Ϊ /etc/rc.local �� /etc/rc.d/rc.local �������ļ��� �����Ļ��� rc.d Ŀ¼�� ��������ô�ɣ���Ҫ��ס������������ PostgreSQL �û��ʻ��������� root���������κ��û���������С� ���������������Ҫ���������е����ӹ��������� su -c '...' postgres�����磺

su -c 'pg_ctl -D /usr/local/pgsql/data -l serverlog' postgres

������һЩ�Ƚ���ϸ�������ϵͳ��صĽ��顣��ÿ������������ʹ�þ�����ֵ��ʱ�򣬶���ע�����Щ�滻�ɺ��ʵİ�װ·�����û�������

postmaster ���е�ʱ������PID�DZ���������Ŀ¼����ļ� postmaster.pid ��ġ���������Ϊ�˱�����postmaster��ͬһ������Ŀ¼�����У����ļ�ͬ���������ڹر�postmaster��

16.3.1. ����������ʧ��

�м����dz�������ԭ��ᵼ�� postmaster ����ʧ�ܡ� ͨ����� postmaster ��־����ʹ���ֹ������ķ��������� stdout��stderr ���ض��򣩣� �Ϳ��Կ���������Ϣ���������Ǹ���ϸ�ؽ���������һЩ������Ϣ��

LOG:  could not bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
FATAL:  could not create TCP/IP listen socket

��������ʾ������������ͼ���Ѿ���һ�� postmaster �����ŵĶ˿�����������һ�� postmaster������������ں˵Ĵ�����Ϣ���� Address already in use �����������ı��֣��Ǿ��п����DZ��ë���� ���磬��ͼ��һ�������Ķ˿�������postmaster���յ�������������Ϣ��

$ postmaster -p 666
LOG:  could not bind IPv4 socket: Permission denied
HINT:  Is another postmaster already running on port 666? If not, wait a few seconds and retry.
FATAL:  could not create TCP/IP listen socket

����������Ϣ

FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5440001, size=4011376640, 03600).

������ζ������ں˶Թ����ڴ���������С��PostgreSQL ��ͼ����Ļ�������С���������� 4011376640 �ֽڣ��� ���߿�����ζ���������û������System-V���Ĺ����ڴ�֧�֡� ��Ϊһ����ʱ�Ľ���취�������������С�����������Ļ���������-B���أ������������� �����ջ��ǻ�ϣ��������������ںˣ������ӹ����ڴ�ijߴ硣�������ͼ��ͬһ̨��������������������� ��������������ܿռ䳬�����ں˵����ƣ�Ҳ�ᱨ�����

�����������Ĵ���

FATAL:  could not create semaphores: No space left on device
DETAIL:  Failed system call was semget(5440126, 17, 03600).

������ζ�������Ѿ��ù���̿ռ��ˡ� ������˼������ں˵�System V�źŵƵ�����С�� PostgreSQL �봴����������������һ���������ͨ�������������������-N���أ����ƿ����������㻹�ǻ�ϣ�������ں˵����ơ�

������յ�һ�� "illegal system call" ������ô���п���������ں˸�����֧�ֹ����ڴ�����źŵơ� ����������Ļ������Ψһѡ�����������������ں˲��Ұ���Щ���Դ򿪡�

��������ϵͳSystem V IPC��Դ��ϸ�ڼ� Section 16.5.1��

16.3.2. �ͻ�����������

���ܿ����ڿͻ��˳��ֵĴ���������Χ��㣬���һ���Ӧ����أ�����ȷ�м��ִ������������������ʽֱ����ء� ���������ᵽ�ļ��ִ�����������ⶼӦ������Ӧ�Ŀͻ���Ӧ�õ��ĵ��С�

psql: could not connect to server: Connection refused
        Is the server running on host "server.joe.com" and accepting
        TCP/IP connections on port 5432?

���Ǵ���� "���Ҳ������Խ�̸�ķ�����"���� ����ͼ���� TCP/IP ͨѶʱ������������������ӡ� �����Ĵ��������ǰѷ��������ó����� TCP/IP ���ӡ�

���⣬����ͼͨ��һ�� Unix �׽����뱾��������ͨѶʱ����ῴ�������

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

���һ�п�����Ч����֤�ͻ��˽������ӳ���ʱ�Ƿ�������λ�á� ���ʵ����û�з��������������У����͵��ں˴�������������ʾ������������ Connection refused ������ No such file or directory�� ������Ҫע��������ֻ����� Connection refused ����Ϣ��ʾ������ζ�ŷ������յ��������Ȼ��ܾ������ӡ� �����Ļ������һ����ͬ����Ϣ���� Section 19.3 ������ʾ�������� ������ Connection timed out ��������Ϣ��ʾ�����������⣬����ȱ���������ӵȡ�