New Issue:
I am trying to run my check_sql command and am running into this problem
./odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/unixODBC/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
[root#]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)
[root#]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)
---------- FIXED --------- DOWNLOADED AND INSTALLED 1.48 WITH NO ERRORS
------ OLD ISSUE with 1.1X ODBC ----------
I am currently in the DBD-ODBC-1.13 directory
export LD_LIBRARY_PATH=/usr/lib:/usr/local/unixODBC
export ODBCHOME=/usr
export DBI_DSN=dbi:ODBC:JDBC
export DBI_USER=guest
export DBI_PASS=sybase
perl Makefile.PL
perl Makefile.PL
Useless use of private variable in void context at Makefile.PL line 431.
Argument "6.55_02" isn't numeric in numeric ge (>=) at Makefile.PL line 33.
Configuring DBD::ODBC ...
>>> Remember to actually *READ* the README file!
And re-read it if you have any problems.
Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Using ODBC in /usr/local/unixODBC
Umm, this looks like a unixodbc type of driver manager.
We expect to find the sql.h, sqlext.h and (which were
supplied with unixODBC) in $ODBCHOME/include directory alongside
the /usr/local/unixODBC/lib/libodbc.so library. in $ODBCHOME/lib
Use of uninitialized value in pattern match (m//) at Makefile.PL line 272.
Warning: LD_LIBRARY_PATH doesn't include /usr/local/unixODBC
Injecting selected odbc driver into cc command
Injecting selected odbc driver into cc command
Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Writing Makefile for DBD::ODBC
The DBD::ODBC tests will use these values for the database connection:
DBI_DSN=dbi:ODBC:JDBC e.g. dbi:ODBC:demo
DBI_USER=guest
DBI_PASS=sybase
Thanks in advance!
I had to properly setup my system for unixODBC to talk with FreeTDS:
I did this by configuring FreeTDS the following way: taken from http://www.unixodbc.org/doc/FreeTDS.html
./configure --with-tdsver=8.0 --prefix=/usr/local/freetds --with-unixodbc=/usr/local/unixODBC
make && make install
cd /usr/local/unixODBC/
mkdir templates && cd templates
vim tds.driver.template
[FreeTDS]
Description = v0.91 with protocol v8.0
Driver = /usr/local/freetds/lib/libtdsodbc.so
# Register ODBC Driver
../bin/odbcinst -i -d -f tds.driver.template
# Setup default DB - easily add or remove DSNs
vim tds.datasource.template
[ODBCTestServer]
Driver = FreeTDS
Description = Test
Trace = No
Server = 5.5.5.5
Port = 1433
Database = Test
# Create ODBC data source
../bin/odbcinst -i -d -f tds.datasource.template
/usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:DRIVER={FreeTDS};Server=5.5.5.5;dbname=test" -U TEST -P PASS
This finally allows for connections to occur.
Related
I have a PostgreSQL instance running on Digital Ocean. When using the command line tool psql, I am able to connect to the database fine. I am using the following command:
psql "host=db-postgresql-nyc1-70444-do-user-4921290-0.b.db.ondigitalocean.com port=25060 dbname=defaultdb user=doadmin password=MY_PASSWORD sslmode=require"
I have now compiled an executable which makes use of libpq and libpqxx. I have compiled the two libraries using the following arguments (as you can see, ssl is supported).
# Unix like system
test -e postgresql-12.2.tar.gz || wget https://ftp.postgresql.org/pub/source/v12.2/postgresql-12.2.tar.gz
test -e postgresql-12.2 || tar -xzvf postgresql-12.2.tar.gz
cd postgresql-12.2
test -e build_amd64 && rm -rf build_amd64
mkdir build_amd64
cd build_amd64
../configure --without-readline CFLAGS="-O3 -fpic" CXXFLAGS="-fpic" CPPFLAGS="-fpic" --prefix=$PWD/packaged --with-includes=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_amd64/packaged/include/ --with-openssl --with-libraries=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_amd64/packaged/lib/
# multithreaded make
if [ "$(uname)" == "Darwin" ]; then
sysctl -n hw.physicalcpu | xargs -I % make -j%
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
nproc | xargs -I % make -j%
fi
make install
ar dv packaged/lib/libpq.a legacy-pqsignal.o
test -e 7.0.7.tar.gz || wget https://github.com/jtv/libpqxx/archive/7.0.7.tar.gz
test -e libpqxx-7.0.7 || tar -xzvf 7.0.7.tar.gz
cd libpqxx-7.0.7
test -e build_amd64 && rm -rf build_amd64
mkdir build_amd64
cd build_amd64
# Unix like system
LIBNAME=libpq.so
if [[ "$OSTYPE" == "darwin"* ]]; then
LIBNAME=libpq.dylib
fi
cmake -DPostgreSQL_TYPE_INCLUDE_DIR=${PWD}/../../postgresql-12.2/build_amd64/packaged/include \
-DPostgreSQL_LIBRARY=${PWD}/../../postgresql-12.2/build_amd64/packaged/lib/${LIBNAME} \
-DPostgreSQL_INCLUDE_DIR=${PWD}/../../postgresql-12.2/build_amd64/packaged/include \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -D CMAKE_BUILD_TYPE=Release -DBUILD_TEST=OFF ..
# multithreaded make
if [ "$(uname)" == "Darwin" ]; then
sysctl -n hw.physicalcpu | xargs -I % make -j%
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
nproc | xargs -I % make -j%
fi
make DESTDIR=./packaged install
# On centos, it is installed to lib64 instead of lib, so create a symbolic link for consistency
test -e packaged/usr/local/lib || ln -s ./lib64/ ./packaged/usr/local/lib
I then pass the exact same connection string to the pqxx::connection constructor as follows:
m_connectionPtr = std::make_unique<pqxx::connection>("host=db-postgresql-nyc1-70444-do-user-4921290-0.b.db.ondigitalocean.com port=25060 dbname=defaultdb user=doadmin password=MY_PASSWORD sslmode=require");
However, doing so spits out the following exception:
terminate called after throwing an instance of 'pqxx::broken_connection'
what(): FATAL: pg_hba.conf rejects connection for host "181.224.248.206", user "doadmin", database "template1", SSL on
Aborted (core dumped)
For what it's worth, I'm able to connect to a PostgreSQL database using my libpqxx logic above when it is running locally on the same machine. I for the life of my can't seem to connect to a remote database though using libpqxx. Any ideas?
Edit:
I don't have access to the pg_hba.conf on the server since it is a managed database hosted by Digital Ocean. However, on the digital ocean console page, it says that the database is open to connections from all IP Addresses.
Edit 2
I now understand the issue. In my executable, I was first connecting to the template1 database, and then making a query to the database to see if the database name provided by the user existed (with libpqxx you can only make database queries once you have established a db connection, and you require a database name in order to create the connection). This approach was not working with hosted database services such as Digital Ocean as they do not allow you to connect to the template1 database. Once I removed that logic from my code, then I was able to connect directly to the specified database correctly.
I know understand what the issue is:
In my executable, I was first connecting to the template1 database, and then making a query to the database to see if the database name provided by the user existed (with libpqxx you can only make database queries once you have established a db connection, and you require a database name in order to create the connection). This approach was not working with hosted database services such as Digital Ocean as they do not allow you to connect to the template1 database. Once I removed that logic from my code, then I was able to connect directly to the specified database correctly.
I try to install semver on my Postgresql 12. I installed postgis successfully and used following command to install pg-semver (semver extension) on my Centos 7 server:
yum install pg-semver
Then i ran
CREATE EXTENSION semver;
I got following error:
couldn't open extension control file
/usr/pgsql-12/share/extension/semver.control : No such file or
directory
I copied all files from "/usr/share/pgsql/extension/" to "/usr/pgsql-12/share/extension". Now I'm getting following error:
ERROR: ERROR: could not access file "semver": No such file or
directory
UPDATE (28.02.2020):
I removed pg-semver because it delivers for PSQL 9.2. I try to now build itself by using the documentation which developer provided.
I downloaded the semver extension from https://github.com/theory/pg-semver/archive/master.zip and then unzipped. After that I run following command:
make
and get:
make: There is nothing to do for the "all" target.
then:
make install
and get:
/bin/sh /usr/lib64/pgsql/pgxs/src/makefiles/../../config/install-sh -c
-m 644 ./semver.control '/usr/share/pgsql/extension/' /bin/sh /usr/lib64/pgsql/pgxs/src/makefiles/../../config/install-sh -c -m 644
./sql/semver--0.20.0.sql ./sql/semver--unpackaged--0.2.1.sql
./sql/semver--0.20.0--0.21.0.sql ./sql/semver--0.12.0--0.13.0.sql
./sql/semver--0.3.0--0.4.0.sql ./sql/semver--0.16.0--0.17.0.sql
./sql/semver--0.13.0--0.15.0.sql ./sql/semver--0.11.0--0.12.0.sql
./sql/semver--0.2.4--0.3.0.sql ./sql/semver--0.2.1--0.2.4.sql
./sql/semver--0.5.0--0.10.0.sql ./sql/semver--0.10.0--0.11.0.sql
./sql/semver.sql ./sql/semver--0.17.0--0.20.0.sql
./sql/semver--0.15.0--0.16.0.sql '/usr/share/pgsql/extension/'
/bin/sh /usr/lib64/pgsql/pgxs/src/makefiles/../../config/install-sh -c
-m 755 src/semver.so '/usr/lib64/pgsql/' /bin/sh /usr/lib64/pgsql/pgxs/src/makefiles/../../config/install-sh -c -m 644
./doc/semver.mmd '/usr/share/doc/pgsql/extension/'
then:
make installcheck
and get:
============== dropping database "contrib_regression" ============== DROP DATABASE
============== creating database "contrib_regression" ============== CREATE DATABASE ALTER DATABASE
============== installing plpgsql ============== CREATE LANGUAGE
============== running regression test queries ============== test base ... FAILED (test process exited with
exit code 3)
--------------- 1 of 1 tests failed.
The differences that caused some tests to fail can be viewed in the
file "/tmp/ttt/pg-semver-master/regression.diffs". A copy of the test
summary that you see above is saved in the file
"/tmp/ttt/pg-semver-master/regression.out".
make: *** [installcheck] Error 1
the content of regression.out:
...... ! ok 278 - minor version check ! ok 279 - Function
get_semver_patch() should exist ! ok 280 - semver ! ok 281 - Function
get_semver_patch() should return integer ! ok 282 - patch version
check ! ok 283 - Function get_semver_prerelease() should exist ! ok
284 - semver ! ok 285 - Function get_semver_prerelease() should return
text ! ok 286 - prerelease label check ! ok 287 - 1.0.0 should be in
range [1.0.0, 2.0.0] ! ok 288 - 1.0.0 should not be in range [1.0.1,
2.0.0] ! ok 289 - 2.0.0 should not be in range [1.0.1, 2.0.0) ! ok 290 - 1.9999.9999 should be in range [1.0.1, 2.0.0) ! ok 291 - 1000.0.0 should be in range [1.0.0,) ! ok 292 - Should be able to work with
arrays of semverranges
--- 1,2 ---- \set ECHO none ! psql:sql/semver.sql:30: ERROR: could not access file "semver": No such file or directory
There is no semver.so in /usr/pgsql-12/lib/, there is a semver.so in /usr/lib64/pgsql/ but it's also for version 9.2 ?
The reason why you are unable to install semver is twofold:
You are getting the error could not access file "semver": No such file or directory because you didn't copy /usr/lib64/pgsql/semver.so to /usr/pgsql-12/lib. However, you can't simply copy that over because of this following second reason:
yum install pg-semver will install semver from the EPEL library, which is the pre-packaged PostgreSQL version 9.2 that is shipped with CentOS 7. You installed PostgreSQL version 12 (either by compiling it yourself or downloading the PGDG repo and installing the postgresql12 package). The semver.so file that is shipped with the EPEL repo is not compatible, as it was compiled against PostgreSQL version 9.2, not version 12. If you attempt to load the EPEL semver.so into your v.12 database, you will see:
postgres=# create extension semver;
ERROR: incompatible library "/usr/pgsql-12/lib/semver.so": version mismatch
DETAIL: Server is version 12, library is version 9.2.
Therefore, the only way for you to install semver is by following the compilation steps detailed in the documentation:
make
make install
make installcheck
psql -c "CREATE EXTENSION semver;"
If you have not done so already (and you installed postgresql 12 via PGDG RPM), you will need to do the following in order to download and compile:
yum -y install postgresql12-devel
yum -y groupinstall "Development Tools"
You may also run into issues with compilation, like: clang: error: unknown argument: '-flto=thin' because the PGDG RPM was compiled with clang -- you can bypass that by doing:
with_llvm=no make -e
with_llvm=no make -e install
with_llvm=no make -e installcheck
psql -c "create extension semver"
Disclosure: I work for EnterpriseDB (EDB)
Follow this guide to install semver:
https://pgxn.org/dist/semver/
What I'm trying to do is to convert this installing script for webodm (https://gist.github.com/lkpanganiban/5226cc8dd59cb39cdc1946259c3fea6e) written in bash to be used in tcsh shell under a freenas jail.
I have now enter at part where I can't find a solution to and my hope is that someone can en light me what to do next.
The line that is triggering the problem is :
su - postgres -c "psql -d webodm_dev -c "\""CREATE EXTENSION postgis;"\"" "
The whole error line :
ERROR: could not load library "/usr/local/lib/postgresql/plpgsql.so": dlopen (/usr/local/lib/postgresql/plpgsql.so) failed: /usr/local/lib/postgresql/plpgsql.so: Undefined symbol "MakeExpandedObjectReadOnly"
pkg info give :
postgis24-2.4.5_1 Geographic objects support for PostgreSQL databases
postgresql95-client-9.5.15_2 PostgreSQL database (client)
postgresql95-contrib-9.5.15_2 The contrib utilities from the PostgreSQL distribution
postgresql95-server-9.5.15_2 PostgreSQL is the most advanced open-source database available anywhere
And yes the file exists:
root#webodm2:~ # ls -l /usr/local/lib/postgresql/plpgsql.so
-rwxr-xr-x 1 root wheel 195119 Feb 7 18:16 /usr/local/lib/postgresql/plpgsql.so
root#webodm2:~ #
So anyone have some idea ?
I faced this issue after the upgrade from postgres 11 to 12, here how to fix it for Linux and Mac (without brew)
$ sudo su postgres
$ /usr/lib/postgresql/12/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/11/main \
--new-datadir=/var/lib/postgresql/12/main \
--old-bindir=/usr/lib/postgresql/11/bin \
--new-bindir=/usr/lib/postgresql/12/bin \
--old-options '-c config_file=/etc/postgresql/11/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
you can add --check to do a dry test upgrade without changing anything in your postgres installation.
for Mac users with brew installation:
after the upgrade run the following command"
$ brew postgresql-upgrade-database
That error message means that you have a plpgsql.so from PostgreSQL 9.5 or earlier and try to use it with PostgreSQL 9.6 or later.
Either you are picking up the wrong library, or you copied files around.
Anyway, the problem has nothing to do with PostGIS.
It might be your database has an outdated version, try to run the checks before running brew postgresql-upgrade-database. OR try to restart your service brew services restart postgres.
psql --version # 11.4 <--- psql cli version
psql -c 'select version();' postgres # 10.2 <--- db version in storage
brew info postgres # check pg info <--- found solution
brew postgresql-upgrade-database # upgrade db version in storage and fixed the issue
I am trying to create an image (.iso) of my installed CentOS 5.11 system, for this i am using the "Mondo Rescue" with the command:
mondoarchive -Oi -9 -L -d /tmp/centos_iso -I / -T /tmp/centos_iso -p centos_image -s 4480m -E "/tmp|/var/spool/squid|/var/log"
The image is generated, and apparently is functional.
To install the iso in other machine i'm using the option "Nuke", in initialization page of "Mondo Rescue", like is represented in below image
When attempting to perform the installation, the following error occurs during the process:
Kernel panic - not syncing: No init found. Try passing init= options to kernel.
Okay, so I was trying to install a combination of the CGI module, DBI module, and DBD::Oracle driver using CPANM on a 64bit Solaris 11 machine with an Oracle11g database.
I installed that latest version of Perl using Perlbrew, updated CPANM, and then did the following...
cpanm -v -f -i CGI
cpanm -v -f -i DBI
And both of those modules installed fine, the DBI did have a small test error (t/zvxnp_85gofer.t) when I tried to install it normally, but the force install seemed to work.
So then I went to try to install the final part that I needed:
cpanm -v -f -i DBD::Oracle
And this was the error that came out towards the end of the installation...
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
LD_RUN_PATH="/opt/oracle/rdbms/lib" gcc -G -L/usr/gnu/lib -fstack-protector Oracle.o dbdimp.o oci8.o -o blib/arch/auto/DBD/Oracle/Oracle.so \
-L/opt/oracle/rdbms/lib/ -lclntsh -lkstat -lnsl -lsocket -lresolv -lgen -ldl -lsched -lrt -R/opt/oracle/rdbms/lib -laio -lposix4 -lkstat -lm -lpthread \
ld: fatal: file /opt/oracle/rdbms/lib//libclntsh.so: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to blib/arch/auto/DBD/Oracle/Oracle.so
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/DBD/Oracle/Oracle.so'
FAIL
! Installing DBD::Oracle failed. See /home/oracle/.cpanm/build.log for details.
I'm guessing just from the wrong ELF class: ELFCLASS64 it has to do with some mismatch between the 64 bit binaries that exist and that this driver requires the 32 bit binaries to install? Some research has indicated that I need to find the lib32 directory to continue the installation, but I can't seem to find it.
I did:
echo $ORACLE_HOME ---> /opt/oracle/rdbms
ls $ORACLE_HOME
That returned the following directories...
apex emcli mgw rdbms
assistants has network relnotes
bin hs nls root.sh
ccr ide oc4j scheduler
cdata install odbc slax
cfgtoollogs install.platform olap sqldeveloper
clone instantclient ons sqlj
config inventory OPatch sqlplus
crs j2ee opmn srvm
csmig javavm oracore sysman
css jdbc oraInst.loc timingframework
ctx jdev ord ucp
cv jdk oui uix
dbs jlib owb utl
dc_ocm ldap owm wwg
deinstall lib64 perl xdk
demo log plsql
diagnostics md precomp
dv mesg racg
So I see a lib64, but no lib or lib32. Has anyone ever had this problem before, found a solution to it, or know how I could continue from here?
I had the same issue. Fixed it by doing ./Configure -es -Dprefix=$HOME/usr/local -Dcc=gcc -Duse64bitall -Dusethreads for perl install
please take a look at 1271236.1 and 883702.1 at oracle.com. It will explain how to get the 32bit libraries for 11i client installation.