My company has two teams of devs, so I'm supposed to set up two postgresql instances on one machine on two different ports. We had a similar set-up on a test postgres VM but with versions 9.5/9.6. I installed postgres 10 without incident, and am trying to follow the instructions on the postgres10 docs here but when I try to user initdb or pg_ctl I get the following:
postgres#DevPostgres:/usr/local$ whereis pg_ctl
pg_ctl: /usr/share/man/man1/pg_ctl.1.gz
postgres#DevPostgres:/usr/local$ whereis initdb
initdb: /usr/share/man/man1/initdb.1.gz
postgres#DevPostgres:/usr/local$ pg_ctl -D /usr/local/pgsql/data initdb
pg_ctl: command not found
I thought these two programs would have been installed in the first installation, but when I follow the chain of symbolic links to a .gz file and unzip it and try to use it I get the following:
root#DevPostgres:~# /usr/share/postgresql/10/man/man1/initdb.1
/var/lib/postgresql/10-5433/
/usr/share/postgresql/10/man/man1/initdb.1: line 19: \" t
.\" Title: initdb
.\" Author: The PostgreSQL Global Development Group
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 2018
.\" Manual: PostgreSQL 10.3 Documentation
.\" Source: PostgreSQL 10.3
.\" Language: English
.\"
.TH "INITDB" "1" "2018" "PostgreSQL 10.3" "PostgreSQL 10.3 Documentation"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq : No such file or directory
/usr/share/postgresql/10/man/man1/initdb.1: line 20: .": command not found
/usr/share/postgresql/10/man/man1/initdb.1: line 21: .": command not found
/usr/share/postgresql/10/man/man1/initdb.1: line 22: .": command not found
/usr/share/postgresql/10/man/man1/initdb.1: line 23: .": command not found
/usr/share/postgresql/10/man/man1/initdb.1: line 24: .nh: command not found
/usr/share/postgresql/10/man/man1/initdb.1: line 25: syntax error near unexpected token `('
/usr/share/postgresql/10/man/man1/initdb.1: line 25: `.\" disable justification (adjust text to left margin only)'
Any advice would be much appreciated!
Related
Running Ubuntu 17.10 and I am having an issue running Postgres. It was working a couple weeks ago, but now I have this problem.
sudo su postgres psql
/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'
I have no idea what to do, the syntax looks normal.
Try
sudo -u postgres psql
instead.
I actually do not know what your command does. A quick look to man su does not really clarify what su will do with extra arguments but obviously it is not starting psql, it is probably feeding the file contents to the shell.
I'm trying to add extensions for Postgres by writing the following script (setup.sh):
sudo -u postgres psql my_database
CREATE EXTENSION adminpack;
when I do vagrant up, it supposed to run and add extensions automatically by running the script. However, I got the error message that
==> default: ERROR: syntax error at or near "exit"
==> default: LINE 1: exit
==> default: ^
==> default: /tmp/vagrant-shell: line 24: CREATE: command not found
Please note that I have installed all the necessary postgres stuff to run the code above. In addition, when I enter these command manually, it successfully creates the extension. Thanks to whoever that helps.
try:
sudo -u postgres psql my_database -c "CREATE EXTENSION adminpack"
https://www.postgresql.org/docs/current/static/app-psql.html
-c command
--command=command
Specifies that psql is to execute the given command string, command.
also consider using -f sql_file.sql for more complicated scripts, or smth like:
psql <<EOF
\x
SELECT NOW();
SELECT * FROM foo;
EOF
I use postgresql on Debian.
The postgresql service can not start after I edit the config file:
#data_directory = '/var/lib/postgresql/9.4/main' # use data in another directory
data_directory = '/opt/data/postgresql/data'
(yeah,I just use custom directory instead of the default data_directory)
I find the log in /var/log/syslog
Sep 14 10:22:17 thinkserver-ckd postgresql#9.4-main[11324]: Error: could not exec /usr/lib/postgresql/9.4/bin/pg_ctl /usr/lib/postgresql/9.4/bin/pg_ctl start -D /opt/data/postgresql/data -l /var/log/postgresql/postgresql-9.4-main.log -s -o -c config_file="/etc/postgresql/9.4/main/postgresql.conf" :
Sep 14 10:22:17 thinkserver-ckd systemd[1]: postgresql#9.4-main.service: control process exited, code=exited status=1
Sep 14 10:22:17 thinkserver-ckd systemd[1]: Failed to start PostgreSQL Cluster 9.4-main.
Sep 14 10:22:17 thinkserver-ckd systemd[1]: Unit postgresql#9.4-main.service entered failed state.
And nothing in /var/log/postgresql/postgresql-9.4-main.log
Thanks.
I finally got this answer:
What this error means in PostgreSQL?
#langton 's answer.
He said that
you should run pg_upgradecluster or similar, or just create a new cluster with pg_createcluster (these commands are for debian systems - you didn't specify your OS)
So I executed the command:
pg_createcluster -d /opt/data/postgresql/data -l /opt/data/postgresql/log 9.4 ckd
And then :
service postgresql restart
it started!
If downtime is allowed and you already have databases with data in the old cluster location you only need to physically copy the data to the new location.
This is a more or less common operation if you partition is out of space.
# Check that current data directory is the same that
# the one in the postgresql.conf config file
OLD_DATA_DIR=$(sudo -u postgres psql --no-psqlrc --no-align --tuples-only --quiet -c "SHOW data_directory;")
echo "${OLD_DATA_DIR}"
CONFIG_FILE=$(sudo -u postgres psql --no-psqlrc --no-align --tuples-only --quiet -c "SHOW config_file;")
echo "${CONFIG_FILE}"
# Stop PostgreSLQ
systemctl stop postgresql
# Change the data directory in the config
# Better to do it with an editor, instead of sed
NEW_DATA_DIR='/opt/data/postgresql/data'
sed -i "s%data_directory = '${OLD_DATA_DIR}'%data_directory = '${NEW_DATA_DIR}'%" "${CONFIG_FILE}"
# Move/Copy the data for example using rsync
rsync -av --dry-run "${OLD_DATA_DIR}" "${NEW_DATA_DIR}"
# Take care with the classical issues of rsync and end backslashes
rsync -av "${OLD_DATA_DIR}" "${NEW_DATA_DIR}"
# Rename the old dir, just to avoid missunderstandings and set
# check the permissions on the new one
# Start postgres
systemctl start postgresql
# Check that everything goes well and eventually drop the old data
# Make sure that the logs and everything else is where you want.
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.
Using Windows Command line with cygwin, chef and ruby installed. When trying
knife cookbook site install mysql
returns the following error
Begin output of tar zxvf D:/path/to/chef-repo/cookbooks/mysql.tar.gz
STDOUT:
STDERR: tar<child>: Cannot connect to D: resolve failed
gzip: stdin: undexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now</code>
How can I remedy this issue? I can manually unzip using
tar zxvf mysql.tar.gz
but this is less than ideal. I believe this has to do with the colon in filename but how can I change that in the knife or chef preferences?
The reason is that tar interprets colons (:) in file names as meaning it is a file on another machine. You can disable this behavior by using the flag --force-local.
This is from an answer from here.
I don't know a complete answer but have been seeing this on Linux machines lately:
$ date > today
$ tar -czf - today > to:day.tgz
$ tar -tzf to:day.tgz
ssh: connect to host to port 22: Connection refused
tar (child): to\:day.tgz: Cannot open: Input/output error
tar (child): Error is not recoverable: exiting now
gzip: stdin: unexpected end of file
tar: Child returned status 2
tar: Error is not recoverable: exiting now
$ tar -tzf - < to:day.tgz
today
$
It appears that tar wants to do some sort of remote file processing because of the colon in the file name and you can fake it out by using some form of redirection or piping - for both reading and writing a tarball. I would still like to find an option or something to tell tar not to behave this way.
Will the tar command work if ran from cmd? Also what if the output is to a local drive. Something else try this,
tar zxvf "D:/path/to/chef-repo/cookbooks/mysql.tar.gz"