1 | $ su - |
ファイヤーウォールの設定
PostgreSQLへのアクセスを有効にします。
1 2 | # firewall-cmd --add-service=postgresql --zone=public --permanent # systemctl restart firewalld |
SELinuxの設定
PostgreSQLへのアクセスを有効にします。
1 2 3 | # setsebool -P postgresql_can_rsync on # setsebool -P postgresql_selinux_transmit_client_label on # setsebool -P selinuxuser_postgresql_connect_enabled on |
確認
1 | # getsebool -a | grep postgresql |
自動起動設定
サービス定義ファイルを作成します。
1 | #vi /usr/lib/systemd/system/postgresql.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # It's not recommended to modify this file in-place, because it will be # overwritten during package upgrades. If you want to customize, the # best way is to create a file "/etc/systemd/system/postgresql.service", # containing # .include /lib/systemd/system/postgresql.service # ...make your changes here... # For more info about custom unit files, see # http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F # For example, if you want to change the server's port number to 5433, # create a file named "/etc/systemd/system/postgresql.service" containing: # .include /lib/systemd/system/postgresql.service # [Service] # Environment=PGPORT=5433 # This will override the setting appearing below. # Note: changing PGPORT or PGDATA will typically require adjusting SELinux # configuration as well; see /usr/share/doc/postgresql-*/README.rpm-dist. # Note: do not use a PGDATA pathname containing spaces, or you will # break postgresql-setup. # Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line # though /lib/... will still work. [Unit] Description=PostgreSQL database server After=network.target [Service] Type=forking User=postgres Group=postgres # Port number for server to listen on Environment=PGPORT=5432 # Location of database directory Environment=PGDATA=/usr/local/pgsql/data # Where to send early-startup messages from the server (before the logging # options of postgresql.conf take effect) # This is normally controlled by the global default set by systemd # StandardOutput=syslog # Disable OOM kill on the postmaster OOMScoreAdjust=-1000 #ExecStartPre=/usr/local/pgsql/bin/postgresql-check-db-dir ${PGDATA} <=このモジュールは存在しないのでコメント ExecStart=/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300 ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 [Install] WantedBy=multi-user.target EOF |
サービスでの起動と停止
1 | # systemctl start postgresql |
1 | # systemctl stop postgresql |
1 | # systemctl enable postgresql |
最後に、PGAdmin等から接続出来るか確認します。