After Postgresql is installed using the Fedora package management tool, it cannot be automatically started by the random device. Today, I spent some time reading some related documents and finally found a solution. In fact, it is also very simple.
The root cause is that after Postgresql is installed, the database is stored in/var/pgsql/data, while the default storage location of Postgresql is/var/lib/pgsql/data. Therefore, the database cannot be found using the default installation configuration, so the startup fails.
In the process of solving the problem, I first wanted to customize a boot script to solve the problem, but there was a problem with all the online solutions. The root cause is that after Fedora15, Systemd is used to replace the original init. Therefore, it is no longer feasible to write or modify rc scripts on the Internet.
In Systemd, the startup service is configured in/etc/systemd/system and/lib/systemd/system. The/lib/systemd/system/postgresql. service file is the default service configuration file installed in postgresql. The Recommended Practice (http://docs.fedoraproject.org/zh-CN/Fedora/16/html/Release_Notes/sect-Release_Notes-Changes_for_Sysadmin.html) should not directly modify this file, but should be copied to/etc/systemd/system and then modified.
Now the location is changed:
Sudo cp/lib/systemd/system/postgresql. service/etc/systemd/system
Sudo servicectl enable postgresql. service # activate the postgresql service
Open/etc/systemd/system/postgresql. service in the editor and set the PGDATA modifier to the correct path (my options are/var/pgsql/data)
Sudo systemctl -- system daemon-reload
Success.