A Guide for DeepDive Installation on Ubuntu 12.04 - postgresql

After having many problems installing the DeepDive project on Ubuntu, I decided to write out a detailed guide. These problems were based on the output from the test.sh file provided with the source - I can't speak to the functionality of the source just yet (just starting to learn).
Because I messed up a few configuration files, and this is still early in my Ubuntu experience, I decided to reinstall the OS (Precise 12.04) and redo everything from scratch. So, this guide is based off of a clean version of Ubuntu 12.04, after installing all relevant updates (via Update Manager) as of 20-Mar-2014.
DeepDive gives us a few prerequisites: Java, Python 2.X, PostgreSQL, and SBT. Ubuntu 12.04 already has Python 2.X, so we'll worry about the others.
We're going to go with the Ubuntu recommended OpenJDK-7. Enter the following in the terminal.
sudo apt-get update
sudo apt-get install openjdk-7-jdk icedtea-7-plugin
Now, let's install SBT. Use the following link to download the debian file or get it from the site. SBT has a dependence on curl, so first I'll install that.
sudo apt-get install curl
cd /home/tom/Downloads
sudo dpkg -i sbt.deb
Now I need to install PostgreSQL, which was by far the trickiest part. In this tutorial, I'm assuming that the computer you're working on will also be the PostgreSQL host. It's also important to note that DeepDive uses JSON, which is apparently not supported by PostgreSQL 9.1 and under. To install version 9.3, I'm going to use the instruction given by "Danny" in this StackExchange post, and just change the numbers to 9.3:
wget -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo gedit /etc/apt/sources.list.d/pgdg.list
Add the following line to the file, then save and close:
deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
Note that "precise-pgdg" corresponds to your Ubuntu version. Now let's update and install.
sudo apt-get update
sudo apt-get install pgdg-keyring postgresql-9.3
Now we'll install DeepDive. First, I need to install git, since I'm on a fresh version of the OS. Then, the instructions come from the DeepDive page. I'm going to install DeepDive in my home directory, but if you want it somewhere else, modify the cd line.
sudo apt-get install git
cd
git clone https://github.com/dennybritz/deepdive.git
cd deepdive
sbt compile
If we run the deepdive test now, it will give us some errors:
cd deepdive
./test.sh
[info] Run completed in 8 seconds, 322 milliseconds.
[info] Total number of tests run: 71
[info] Suites: completed 18, aborted 0
[info] Tests: succeeded 69, failed 2, canceled 0, ignored 0, pending 3
[info] *** 2 TESTS FAILED ***
[error] Failed tests:
[error] org.deepdive.test.integration.LogisticRegressionApp
[error] org.deepdive.test.unit.InferenceManagerSpec
[error] Error during tests:
[error] org.deepdive.test.unit.PostgresInferenceDataStoreSpec
[error] org.deepdive.test.unit.PostgresExtractionDataStoreSpec
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 29 s, completed Mar 20, 2014 6:45:30 PM
To fix this, we need to set up PostgreSQL. First, let's activate the local and TCP/IP connections.
sudo gedit /etc/postgresql/9.3/main/postgresql.conf
Modify the following line in the "Connections and Authentication" from:
#listen addresses = 'localhost'
to:
listen_addresses = 'localhost, 127.0.0.1, 192.168.1.10'
Note that you should check your own IP address in your network connections and use that instead of mine, which ends in .10. It's also worth noting that localhost and 127.0.0.1 are equivalent. Now, you'll need to make sure the port 5432 is activated/open on your router. For me, it was something like the following: Access the router from a browser typing 192.168.1.0 -> Virtual servers -> enable port 5432 for IP Address 192.168.1.10
Now we need to set up the postgres superuser for the first time. The following line will open psql as user postgres (thanks to the Ubuntu-PostgreSQL community Wiki)
sudo -u postgres psql postgres
You should see postgres=# and a cursor. Type the following, then enter your password of choice:
\password postgres
While we're still in psql as the postgres superuser, let's go ahead and create a regular user, who has the same name as your Ubuntu user account. This will make life easier (for me at least). You can use \du to check the characteristics of your users.
CREATE ROLE tom WITH SUPERUSER CREATEDB CREATEROLE REPLICATION LOGIN;
\du
Now add a password to that user too, then quit psql.
ALTER ROLE tom WITH PASSWORD 'your_pa$$w0rd';
\q
Check that you are now user 'tom' again, and not user 'postgres-tom.' If the latter, type exit
We now need one additional dependency to be error-free.
sudo apt-get install gnuplot-x11
Lastly, we need to slightly modify the test.sh file in the deepdive directory. It seems like there's a bug, where the test 'forgets' the password you provided in the middle of the run. So, let's just hardwire it in there.
cd
gedit deepdive/test.sh
You'll notice the following lines right at the top.
# Set username and password
export PGUSER=${PGUSER:-`whoami`}
export PGPASSWORD=${PGPASSWORD:-}
If you'd like to save the original file, then change the name to test_original.sh. We're going to change those lines to the following (as per your case):
# Set username and password
export PGUSER=tom
export PGPASSWORD=your_pa$$w0rd
OK, now go to your deepdive folder, and run the test!
cd deepdive
./test.sh
Success! Sweet, sweet success! You should see the following:
[info] Run completed in 21 seconds, 280 milliseconds.
[info] Total number of tests run: 90
[info] Suites: completed 20, aborted 0
[info] Tests: succeeded 90, failed 0, canceled 0, ignored 0, pending 3
[info] All tests passed.
[success] Total time: 23 s, completed Mar 20, 2014 7:27:21 PM
Don't ask me what tests are "pending." No idea.

Related

Postgres 13 fails at the initdb stage

I've followed the official installation instructions for my Centos 7 machine:
# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install -y postgresql13-server
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
The issue comes at the initdb stage. Instead of getting the typical "OK" at the end of execution, I'm given nothing. After looking through the postgresql-13-setup script, I managed to find an ouput log at /var/lib/pgsql/13/initdb.log:
/usr/pgsql-13/bin/initdb: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
It looks like, for whatever reason, libpq.so.5 (which is present in other past postgres installs) is missing from /usr/pgsql-13/lib/.
I've tried uninstalling/reinstalling postgres-13 multiple times now, clearing out the service, deleting all the directories, etc. This issue is only happening in this specific machine (I've installed postgres 13 in various other similar machines with no issue).
edit:
Ad requested, running:
/usr/pgsql-13/bin/initdb -E UTF8 /var/lib/pgsql/13/data
Returns the same exact error:
/usr/pgsql-13/bin/initdb: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

Firebird 2.5 Database Server on FreeBSD 11.2

I install a Firebird database server (ver. 2.5) according to the instructions on https://www.howtoforge.com/the-perfect-database-server-firebird-2.5-and-freebsd-8.1 and I get this message "Please do not build firebird as 'root' because this may cause conflicts with SysV semaphores of running services".
Trying to compile as normal user failed because I do not have access to write in this directory.
After Firebird installation as root, when I try to create local database I got error:
# isql-fb
Use CONNECT or CREATE DATABASE to specify a database
SQL> CREATE DATABASE '/test/my.fdb';
Bus error (core dumped)
Can someone help me please?
The easiest way would be to install the package as root user, for example:
# pkg install firebird25-server
If you would like to use the ports try this:
# cd /usr/ports/databases/firebird25-server
# make install clean
In either case, the message you get will be something like this (you could ignore it to continue with the installation, just need to wait 5 seconds and then it will proceed):
> pkg install firebird25-server
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating poudriere repository catalogue...
poudriere repository is up to date.
All repositories are up to date.
Updating database digests format: 100%
The following 2 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
firebird25-server: 2.5.8_1 [FreeBSD]
firebird25-client: 2.5.8_1 [FreeBSD]
Number of packages to be installed: 2
The process will require 22 MiB more space.
5 MiB to be downloaded.
Proceed with this action? [y/N]: y
[1/2] Fetching firebird25-server-2.5.8_1.txz: 100% 2 MiB 2.4MB/s 00:01
[2/2] Fetching firebird25-client-2.5.8_1.txz: 100% 3 MiB 943.7kB/s 00:03
Checking integrity... done (0 conflicting)
[1/2] Installing firebird25-client-2.5.8_1...
[1/2] Extracting firebird25-client-2.5.8_1: 100%
[2/2] Installing firebird25-server-2.5.8_1...
===> Creating groups.
Creating group 'firebird' with gid '90'.
===> Creating users
Creating user 'firebird' with uid '90'.
###############################################################################
** IMPORTANT **
Keep in mind that if you build firebird server as 'root', this may cause
conflicts with SysV semaphores of running services.
If you want to cancel it, press ctrl-C now if you need check some things
before of build it.
###############################################################################
Here sleeps for 5 seconds and then continues:
[2/2] Extracting firebird25-server-2.5.8_1: 100%
Message from firebird25-server-2.5.8_1:
###############################################################################
Firebird was installed.
1) Support for Super Server has been added
2) Before start the server ensure that the following line exists in /etc/services:
gds_db 3050/tcp #InterBase Database Remote Protocol
3) If you use inetd (Classic Server) then add the following line to /etc/inetd.conf
gds_db stream tcp nowait firebird /usr/local/sbin/fb_inet_server fb_inet_server
And finally restart inetd.
4) If you want to use SuperClassic Server then you must add the following lines
to /etc/rc.conf file.
firebird_enable="YES"
firebird_mode="superclassic"
5) If you want to use Super Server then you must add the following lines to
/etc/rc.conf file.
firebird_enable="YES"
firebird_mode="superserver"
Note: Keep in mind that you only can add one of them but never both modes on
the same time
6) It is STRONGLY recommended that you change the SYSDBA
password with:
# gsec -user SYSDBA -pass masterkey
GSEC> modify SYSDBA -pw newpassword
GSEC> quit
before doing anything serious with Firebird.
7) See documentation in /usr/local/share/doc/firebird/ for more information.
8) Some firebird tools were renamed for avoid conflicts with some other ports
/usr/local/bin/isql -> /usr/local/bin/isql-fb
/usr/local/bin/gstat -> /usr/local/bin/fbstat
/usr/local/bin/gsplit -> /usr/local/bin/fbsplit
9) Enjoy it ;)
To start it just add to /etc/rc.conf as indicated in the message in point 4 or 5, for example:
firebird_enable="YES"
firebird_mode="superserver"
To compile it as non-root an easy way could be to change the owner of the port dir to your user, for example:
# chown -R foo:foo /usr/ports/databases/firebird25-server
Then as your user cd to the port and build by typing only make:
$ cd /usr/ports/databases/firebird25-server
$ make
Then switch back to root to install the port:
# make install
Here is a procedure I used to get around this issue in the past (based on FreeBSD 10.2). This is for firebird client, but should work similarly for server. This procedure assumes sudo is set up for the user performing the installation.
cd /usr/ports
sudo chown non-root-user-name distfiles (was root)
cd /usr/ports/databases
sudo chown non-root-user-name firebird25-client (was root)
cd /usr/ports/databases/firebird25-client
make -DPACKAGE_BUILDING (Note: No sudo is used here! This process can take a long time.)
(Note: You may be required to supply root password on this step)
make install clean (Note: You may be required to supply root password on this step)
cd /usr/ports
sudo chown root distfiles
cd /usr/ports/databases
sudo chown root firebird25-client
As for FreeBSD 11.x and Firebird...I was seeing the same "Bus error". I have concluded for now (perhaps incorrectly) that Firebird is not yet compatible with FreeBSD 11.x. If you revert to FreeBSD 10.x, you should not see this problem.

Installing postgresql on CentOS 5.5 postgresql-setup initdb command not found error

I was following these steps to install postgresql and then odoo v9 :
https://www.odoo.com/documentation/9.0/setup/install.html
Basically it follows these steps outlined here:
https://www.odoo.com/forum/help-1/question/issue-while-installing-following-the-instructions-for-packaged-installers-rpm-93756
I get exactly the same situation. The first steps go through without issue but then the postgresql-setup initdb command cannot be found.
I have root access to the server and I know it's running centOS5.5. How can I troubleshoot this? I believe I installed the 9.4 version but when I do psql -V I get the server has v8.3.
I ran some commands on the server and here are the results:
postgresql-setup initdb
command cannot be found
postgres
root execution is not permitted, server must be restarted as underprivileged id...
initdb
no data directory specified, you must identify dir where datase system will reside
locate postgresql
i get an .rb, .xml and .yml files
locate psql
/usr/lib64 - a few libodbcpsql.so files
pqsl -V
8.1.23
I get command not found for all other commands in the list of commands to install odoo up until sudo yum config manager --add-repo etc...
sudo su postgres -c "psql -c 'show data_directory'"
could not change directory to 'the directory im currently in on my server'

How to install PostgreSQL on OSX Yosemite using MacPorts

I want to install PostgreSQL for a node project that I'm developing in OSX Yosemite. I use MacPorts and so tried the method described here: https://github.com/codeforamerica/ohana-api/wiki/Installing-PostgreSQL-with-MacPorts-on-OS-X
...but I get an error during step 2:
$ sudo gem install pg -- --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config > ruby_error
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config
Using config values from /opt/local/lib/postgresql93/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
...thinking that I may not need to install the pg gem since I want to work with Node and not Ruby, I moved on to the next steps. But there I run into an error during step 3.3:
$ sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
...checking my /opt/local/lib/postgresql93/bin/ directory, I see both initdb and postgres. I see those lines saying Permission denied and am wondering what that's about.
Not sure how to progress. Thinking of using Postgres.app if it really is easier but not sure whether it would be better to install using MacPorts since I install most other things using MacPorts. Tips about any of my problems are appreciated!
The permissions/ownership on the directories between / and defaultdb likely need to be fixed. I think PostgreSQL can be sensitive to ownership of these, though it seems that in your case PostgreSQL simply doesn't have access to those. This is what I have for each directory.
$ ls -hlt /opt/local/var/db/
total 0
drwxr-xr-x 7 root admin 238B Jan 23 16:54 texmf
drwxr-xr-x 3 root admin 102B Dec 25 07:37 postgresql94
You could fix permissions by doing sudo chmod a+rx /opt/local/var/db/ as needed.
For the defaultdb directory itself, you should follow the instructions that you link to, which seem to have the same as I have:
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
Below are instructions adapted from my blog (though I recommend using PostgreSQL 9.4, which I now do). I've been running PostgreSQL using MacPorts since 9.1 without major problems.
1. Install PostgreSQL using MacPorts.
Of course, I assume you’ve got MacPorts up and running on your system.
sudo port install postgresql93 +perl +python27
sudo port install postgresql93-server
2. Set up PostgreSQL
I first need to initialize the database cluster and then get the server running. The following comes straight from the on-screen instructions supplied with the MacPorts port postgresql93-server.
sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
Note that MacPorts creates a launch daemon. To load it now and to make sure it launches on system start, do:
sudo defaults write /Library/LaunchDaemons/org.macports.postgresql93-server.plist Disabled -bool false
sudo launchctl load /Library/LaunchDaemons/org.macports.postgresql93-server.plist
I then use psql for some set-up to get my database going.
sudo su - postgres
/opt/local/lib/postgresql93/bin/psql -U postgres -d template1
If you get to here, then you have PostgreSQL running on your system.
I had the same issue when attempting to run initdb, even when following the description by Ian Gow:
$ sudo su postgres -c '/opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb'
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
Turns out that user postgres cannot do anything if you try to make it run a command from within your own home directory, because in there postgres is not allowed to read its own location and hence cannot figure out any other paths, either. So the simple solution is to run cd / before any command that must be run as postgres (initdb, pg_ctl, etcetera). Afterwards, you can quickly jump back to your previous working directory using cd -.

How to initialize initdb in fedora postgresql

I was installed postgresql on fedora 20 using rpm packages. i was manually downloaded the packages which were required for postgres those packages are as follows:
libxslt-1.1.28-5.fc20.x86_64.rpm postgresql-9.3.1-2.fc20.x86_64.rpm
postgresql93-9.3.4-1PGDG.f20.x86_64.rpm
postgresql93-contrib-9.3.4-1PGDG.f20.x86_64.rpm
postgresql93-libs-9.3.4-1PGDG.f20.x86_64.rpm
postgresql93-server-9.3.4-1PGDG.f20.x86_64.rpm
postgresql-libs-9.3.1-2.fc20.x86_64.rpm uuid-1.6.2-26.el7.x86_64.rpm
and i was installed those packages like this.
[root#fedorarpmpostgres ~]# rpm -ivh libxslt-1.1.28-5.fc20.x86_64.rpm
Output
Preparing... ################################# [100%]
package libxslt-1.1.28-5.fc20.x86_64 is already installed
so its already installed ok now i'm successfull in stalling all this packages. now how can i
install initdb
i tried like this way but i got this error.
[root#fedorarpmpostgres ~]# /usr/pgsql-9.3/bin/initdb --encoding=UTF8 --
Output:
pgdata=/var/lib/pgsql/9.3/data/
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
one thing i was to inform you is i'm success in installing postgres through yum but i need postgres installation through rpm only like the way i did above
could any body help me how to initialize initdb.
Thanks.
With your root user, if you haven't set the postgres user password, which is not set by default, do a su postgres and you should be able to do a initdb.