Larry Rosenman Did you install the readline-devel stuff? It needs to see the headers. FYI: $ uname -a FreeBSD lerlaptop. How to Install and Configure PostgreSQL. Installing Postgre. SQL without Root . However this way you just depend on the installation settings chosen by the packages mainainers. Installation requires root privileges, on some machines programmers are not allowed to do that. What’s more, this way you rather will not install the Postgre. SQL beta version. How To: PostgreSQL Install, Configure and. Before installing check the USE flags, readline. Mkdir /usr/local/pgsql9.1 mkdir /var/lib/pgsql9.1 mkdir /var/lib/pgsql9.1/data chown postgres. The only way to install Postgres without root privileges, in home directory, is to compile it from sources. That’s not very difficult. Download Sources. First of all you need to download sources. I use Github for getting the latest sources. There is Postgres Github mirror. I clone that, but you could just download zip file. Unpack it somewhere, and you have the Postgres sources you need. Install Needed Software. For compiling Postgres you will need some libraries and programs. The complete list can be found in Postgres documentation. I’m using Ubuntu, the packages I use for compiling Postgres are: gcc – C compilerlibreadline. Postgreslibpython. Python support. If you are using different system, or different system/Postgres version, then your packages/libraries can be named differently. I used sudo apt-get install readline, thinking it was somehow missing from my Ubuntu installation but that failed with 'Unable to locate package readline'.Configure. Now you should enter the directory where your sources are and run below command for source configuration./configure - -prefix=$HOME/postgres/ - -with- python PYTHON=/usr/bin/python. The - -prefix parameter shows the path where Postgres will be installed. The - -with- python parameter enables compiling with plpython support. PYTHON parameter points to current python binary installation. The configure command should finish without any errors. If you have any errors, most probably you don’t have some needed libraries installed. Compile. If configure succeeded, you can compile the sources. It is simple: make - j 4. The - j parameter allows for this maximum number of jobs at the same time. My computer has 4 cores, I want to use all of them, this way compilation time will be much shorter. On my laptop compilation with 4 cores takes 1 minute 2. Using one core is almost 4 times longer. Install. If compilation ended without error, you can install the database. Installation copies all files into the directory from the - -prefix parameter. For installation just run: make install. This should create four directories in ~/postgres/* bin. Create database. I’m going to keep the database in the same directory as the installed files. The data will be at ~/postgres/data directory. For this I need to use initdb program, but not this one installed at system level, but this one from ~/postgres/bin/ directory: ~/postgres/bin/initdb - D ~/postgres/data/Your output should look like this: The files belonging to this database system will be owned by user . MB. creating configuration files .. The recommended way is to install the prebuilt postgresql binaries. Postgres provides a Tool to manage the Database called psql. The readline library; The readline-devel library; The zlib compression library; The zlib-devel compression library. You can now start the database server using. D /home/szymon/postgres/data/. This shows you exact commands needed for running Postgres at this location with this database. Run. Let’s run, I will use the first command, the log lines will be printed on console: /home/szymon/postgres/bin/postgres - D /home/szymon/postgres/data/. LOG: database system was shut down at 2. CEST. LOG: database system is ready to accept connections. LOG: autovacuum launcher started. Readline install questions. Connect. Connect to the database. One important notice, you should use the psql program which you’ve already installed: ~/postgres/bin/psql - -version. Postgre. SQL) 9. 3beta. The Postgre. SQL installation uses my system username szymon as Postgres admin name. The default database created in Postgres is postgres. To login to this database I use: ~/postgres/bin/psql - U szymon postgres. Type . If you want to run multiple Postgres versions on the same machine, they must have different data directories and different ports. The port number can be changed in ~/postgres/data/postgresql. Deleting Installation. If you want to delete the installation – nothing easier. Just stop the Postgres if it is running, and delete the whole ~/postgres/ directory. If you want to delete the whole data – just stop Postgres if it is running, and delete ~/postgres/data directory. Then you can run initdb once again to have a brand new database. Summary. I know that there are many ways of installing, and compiling Postgres in local directory. I know that there can be made some more advanced tweaks and automations. I also have my makefile with some default values. My goal here was to show that it is very easy and there is nothing too difficult for programmers to do it, without asking for root privileges for installation or even starting/stopping database. This method also works if you need some older Postgres versions and there are no packages for your system, you don’t want to mess with existing packages or the packages require some old libraries you cannot install.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |