Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
0
votes
2
answers
284
views
Command line command to read Oracle Database export Success Message In log File
We have several oracle 19c servers with daily exports. I would like to find a way to run a command to read the export log file to find the success message for the day. e.g. I would like to putty into the linux server have a command I can copy and paste that will read the daily export log file and te...
We have several oracle 19c servers with daily exports. I would like to find a way to run a command to read the export log file to find the success message for the day. e.g. I would like to putty into the linux server have a command I can copy and paste that will read the daily export log file and tell me in one command/output that the export was successful or not? or any better ideas to automate reporting that daily exports are successful on 40+ servers?
crcoder
(1 rep)
Jan 7, 2023, 11:42 PM
• Last activity: May 17, 2025, 07:07 AM
14
votes
3
answers
46706
views
Execute system commands in PostgreSQL
My requirement is to execute a system command like (`ls`) or a C program when a trigger executes. Is there any way to create a trigger function to solve this problem?
My requirement is to execute a system command like (
ls
) or a C program when a trigger executes.
Is there any way to create a trigger function to solve this problem?
mohangraj
(303 rep)
Feb 4, 2016, 06:31 AM
• Last activity: Sep 14, 2024, 03:52 AM
0
votes
0
answers
436
views
How to solve cp: cannot stat 00000002.history: No such file or directory/LOG: invalid primary checkpoint record during PITR?
I have tried to recover a database, using the Point-in-Time Recovery method, through the postgresql.conf file, setting the recovery_target_time parameter at a specific time in past, but I cannot start the cluster and recover the database, I am getting the following output in the log file: 2024-08-08...
I have tried to recover a database, using the Point-in-Time Recovery method, through the postgresql.conf file, setting the recovery_target_time parameter at a specific time in past, but I cannot start the cluster and recover the database, I am getting the following output in the log file:
2024-08-08 09:37:11.429 CEST LOG: database system was interrupted; last known up at 2024-07-13 21:12:24 CEST
cp: cannot stat '/appl/pgsql/15/bkp/WAL/00000002.history': No such file or directory
2024-08-08 09:37:11.443 CEST LOG: starting point-in-time recovery to 2024-07-14 20:00:00+02
2024-08-08 09:37:11.443 CEST LOG: invalid primary checkpoint record
2024-08-08 09:37:11.443 CEST PANIC: could not locate a valid checkpoint record
2024-08-08 09:37:11.556 CEST LOG: startup process (PID 3492124) was terminated by signal 6: Aborted
2024-08-08 09:37:11.556 CEST LOG: aborting startup due to startup process failure
2024-08-08 09:37:11.558 CEST LOG: database system is shut down
I have seen different questions similar to mine, but also different answers, so I am not sure what can be the problem.
What I can imagine is that it must have something to do with the version of the database, which is the 15, I have seen some things related to backup have changed since this version has been released, but I am not sure. Has anyone had this issue before?
Diogo dos Santos
(3 rep)
Aug 9, 2024, 01:28 PM
• Last activity: Aug 10, 2024, 02:35 AM
0
votes
0
answers
50
views
Why does removing `skip-grant-tables` cause resource conflict error for mysqld?
After hours of searching, I have managed to narrow a mysqld issue down to a point, which I cannot find reason for. I am attempting to launch multiple instances of mysqld on my Ubuntu server. When running a single instance, my process is as follows: 1) Run mysqld with an options file containing `skip...
After hours of searching, I have managed to narrow a mysqld issue down to a point, which I cannot find reason for.
I am attempting to launch multiple instances of mysqld on my Ubuntu server. When running a single instance, my process is as follows:
1) Run mysqld with an options file containing
skip-grant-tables
2) Use the mysql client to FLUSH PRIVILEGES;
and allow root
@localhost
to access the server.
3) Kill the mysqld process
4) Remove the line skip-grant-tables
from the options file
5) Relaunch mysqld
when desired
This works without issue. When I attempt to launch a second instance of mysqld, the above steps work fine also - except I cannot include step (4).
If I include skip-grant-tables
in my options file, mysqld launches without issue. If I remove skip-grant-tables
, I get several errors:
2024-04-16T19:31:36.478828Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X Protocol won't be accessible'
2024-04-16T19:31:36.478932Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 failed, bind()
failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx ?'
2024-04-16T19:31:36.478966Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to Mysqlx_bind_address
, X Plugin can't bind to it. Skipping this value.
2024-04-16T19:31:36.479059Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' failed, another process with PID 419201 is using UNIX socket file'
2024-04-16T19:31:36.636815Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-04-16T19:31:36.636894Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-04-16T19:31:36.644131Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2024-04-16T19:31:36.644151Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?
2024-04-16T19:31:36.644169Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-04-16T19:31:38.237950Z 0 [System] [MY-010910] [Server] /rootInstallDir/mysql/bin/mysqld: Shutdown
2024-04-16T19:31:38.237978Z 0 [System] [MY-015016] [Server] MySQL Server - end.
I am using UNIX socket files, not ports, so I'm not sure why ports are being mentioned. Excluding log settings, my options file is:
[mysqld]
socket=/tmp/unique.sock
pid_file=/unique/path.pid
datadir=/unique/path
After many hours searching, advice, guidance or an explanation of what is causing this issue is greatly appreciated.
Update
------
After further testing, I am confident the error is due to the presence of skip-grant-tables
as I execute the following steps:
1) Run mysqld with options file containing skip-grant-tables
. mysqld runs successfully
2) I start a second instance with skip-grant-tables
. mysqld runs successfully
3) I kill the second instance
4) I start a second instance without skip-grant-tables
. mysqld exits soon after starting with the error detailed above.
5) I add skip-grant-tables
to the options file and start a second instance. mysqld runs successfully.
Why will mysqld not start without skip-grant-tables
?
user10709800
(21 rep)
Apr 16, 2024, 08:10 PM
• Last activity: Apr 17, 2024, 08:31 AM
1
votes
1
answers
790
views
Convert column with unix timestamp from UTC to a different time zone
Good afternoon, I have a column within one of my tables that is stamped with a UNIX timestamp. I would like to have the return in my current timezone, PST. I have the following query and the below error is being returned. Any help would be greatly appreciated as I'm not sure if I am missing somethin...
Good afternoon,
I have a column within one of my tables that is stamped with a UNIX timestamp. I would like to have the return in my current timezone, PST. I have the following query and the below error is being returned. Any help would be greatly appreciated as I'm not sure if I am missing something simple, or way off base.
select TO_TIMESTAMP_TZ (('1970-01-01','YYYY-DD-MM;) + NUMTODSINTERVAL (table_name,'SECOND'),'UTC')) at time zone 'PST'
from column_name
ORA-00907:missing right parenthesis
00907.00000 - "missing right parenthesis"
*Cause:
*Action:
Error at Line 16 Column:37.
tdavidson
(13 rep)
Apr 20, 2023, 08:30 PM
• Last activity: Apr 21, 2023, 08:05 AM
1
votes
0
answers
203
views
Critically high website CPU usage very sudden, persistent upon reboots
Quick summary. Wordpress community website, large userbase. Has caching for guests (WP Super Cache). Always operates around load of 1-2, or 5-6 at peak hours CPU. As of 4pm EST on Feb 15, the CPU load shot to 10 and ever since then has had a "resting" load of 7-8 and is at extreme levels during the...
Quick summary. Wordpress community website, large userbase. Has caching for guests (WP Super Cache). Always operates around load of 1-2, or 5-6 at peak hours CPU.
As of 4pm EST on Feb 15, the CPU load shot to 10 and ever since then has had a "resting" load of 7-8 and is at extreme levels during the day usually 12.
**What was tried:**
- Many reboots, it goes right back up to 12.
- Blanked out the website for users, guests were served cache. Load stayed at 8 (weird?...)
- Slow query log is useless, logging many non-normally-slow queries because entire server is slow.
Here is a typical htop snapshot:
The moment it happened:
No plugin/code changes...Why?
---
I sort of feel it's not just slow plugins/frontend queries and such, due to how it immediately jumps to 12 on reboot and how even with the site blanked out (not calling up posts, comments, sidebars, etc) it was still at a very high load.
How can I determine what's going on?


yesbutmaybeno
(111 rep)
Feb 28, 2023, 07:37 PM
0
votes
1
answers
990
views
Help required to find correct MongoDB size
Please help me to find correct MongoDB size. db version v3.4.10 I have also executed below command to check if there are any ghost file. The below command output is zero. lsof | grep deleted | grep mongo | wc -l 1. In db.stats, the data size is showing 1236GB "collections" : 23, "views" : 0, "object...
Please help me to find correct MongoDB size.
db version v3.4.10
I have also executed below command to check if there are any ghost file. The below command output is zero.
lsof | grep deleted | grep mongo | wc -l
1. In db.stats, the data size is showing 1236GB
"collections" : 23,
"views" : 0,
"objects" : 702876605,
"avgObjSize" : 1914.5578033287934,
**"dataSize" : 1253.2788225263357,**
"storageSize" : 374.982120513916,
"numExtents" : 0,
"indexes" : 52,
"indexSize" : 21.016620635986328,
"ok" : 1
2. Disk used is showing as 916GB (/data/mongo/) out of 1.4T
3. In show dbs output, DB size is showing as 396B
admin 0.000GB
local 15.906GB
**abcd 396.008GB**
I need to sync DB from primary site to secondary (replication), How much free space is required on secondary site (915 GB or 1236GB)? Also why it's showing DB size different in point 1,2 & 3? Which value/size is correct DB size?
Thanks in advance.
Sridhar G
(1 rep)
Oct 27, 2022, 10:24 AM
• Last activity: Oct 30, 2022, 03:45 AM
1
votes
3
answers
445
views
count duplicate records and select first 2
I have troubling issue where I want to only select the first 2 chunks of every dbspace created. query used: SELECT a.dbsnum, b.chknum, a.name, b.fname FROM sysdbspaces a, syschunks b where a.dbsnum = b.dbsnum GROUP BY 1,2,3,4 ORDER BY 1,2 Output: dbsnum 1 chknum 1 name rootdbs fname /dev/informix/ro...
I have troubling issue where I want to only select the first 2 chunks of every dbspace created.
query used:
SELECT
a.dbsnum,
b.chknum,
a.name,
b.fname
FROM
sysdbspaces a, syschunks b where a.dbsnum = b.dbsnum
GROUP BY
1,2,3,4
ORDER BY 1,2
Output:
dbsnum 1
chknum 1
name rootdbs
fname /dev/informix/rootdbs01
dbsnum 1
chknum 344
name rootdbs
fname /dev/informix/chunk1081
dbsnum 1
chknum 965
name rootdbs
fname /dev/informix/chunk1280
dbsnum 1
chknum 1099
name rootdbs
fname /dev/informix/chunk1281
What I want is:
dbsnum 1
chknum 1
name rootdbs
fname /dev/informix/rootdbs01
dbsnum 1
chknum 344
name rootdbs
fname /dev/informix/chunk1081
I am trying to put logic together to select the first 2 chunks created for example from each dbspace that exists. rootdbs has a total of 4 chunks I only want the first 2.
I can achieve this using a korn shell script:
for i in
echo "output to pipe cat without headings select unique(dbsnum) from sysdbspaces" | dbaccess sysmaster 2> /dev/null | sed '/^$/d'
do
fname=`echo "output to pipe cat without headings select a.fname from (select
first 2
a.dbsnum,
b.chknum,
a.name,
b.fname
FROM
sysdbspaces a, syschunks b where a.dbsnum = b.dbsnum
AND a.dbsnum = '$i'
--AND a.is_temp = 1
GROUP BY
1,2,3,4
ORDER BY 1,2) a" | dbaccess sysmaster 2> /dev/null | sed '/^$/d'`
echo "$fname"
done
Christopher Karsten
(319 rep)
Feb 9, 2021, 07:36 AM
• Last activity: Aug 3, 2022, 08:52 PM
1
votes
0
answers
605
views
Independently checking if PostgreSQL server and client are installed
How can I independently determine whether the PostgreSQL server and client are installed in the Unix-based system? I believe running `psql --version` checks only for the PostgreSQL client. Is `postgres --version` the way to check for the server installation?
How can I independently determine whether the PostgreSQL server and client are installed in the Unix-based system?
I believe running
psql --version
checks only for the PostgreSQL client.
Is postgres --version
the way to check for the server installation?
weno
(115 rep)
Jan 19, 2022, 12:29 PM
24
votes
1
answers
40641
views
What limits the number of connections?
As per https://devcenter.heroku.com/articles/heroku-postgres-legacy-plans the connection limit is 500 As per https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server "Generally, PostgreSQL on good hardware can support a few hundred connections" What are the determining factors in this limit? #...
As per https://devcenter.heroku.com/articles/heroku-postgres-legacy-plans the connection limit is 500
As per https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server "Generally, PostgreSQL on good hardware can support a few hundred connections"
What are the determining factors in this limit? #CPU cores? RAM? OS?
Neil McGuigan
(8653 rep)
Mar 19, 2015, 09:50 PM
• Last activity: Sep 19, 2021, 10:54 PM
1
votes
1
answers
2550
views
DBA group in Linux
When we need to install Oracle database in Linux then the user should be in dba group. What is this group and why the user should be in this group for installing Oracle database. What happens if the user does not belong to this group? Please help me in understanding this.
When we need to install Oracle database in Linux then the user should be in dba group. What is this group and why the user should be in this group for installing Oracle database. What happens if the user does not belong to this group? Please help me in understanding this.
Learner
(211 rep)
Apr 2, 2013, 10:42 AM
• Last activity: Jul 26, 2021, 03:02 AM
1
votes
1
answers
43
views
Mysql 8 which linux / Unix Distro would have better performance (2021 topic)
I want to setup a mysql 8 with MyRocks engine and **BUILD** from source with my custom parameters. Is there any recommendation on which linux / unix distro would have better performances ? CentOS stream FreeBSD Fedora 34 HARDWARE that I have access to : Premium Intel with NVMe SSD I searched on the...
I want to setup a mysql 8 with MyRocks engine and **BUILD** from source with my custom parameters.
Is there any recommendation on which linux / unix distro would have better performances ?
CentOS stream
FreeBSD
Fedora 34
HARDWARE that I have access to :
Premium Intel with NVMe SSD
I searched on the web for benchmarks but search engines throw anything but that.... :(
If it's the wrong forum to ask this, please tell me where I could ask those questions.
Regards
Jintor
(113 rep)
Jul 19, 2021, 07:11 PM
• Last activity: Jul 19, 2021, 09:03 PM
1
votes
0
answers
27
views
UNIX timestamp using for storing logs
Would it be feasible to use UNIX timestamp as a primary key to store log records/analytics data of users? Will there be inconsistencies if a RDBMS is used to store log data?
Would it be feasible to use UNIX timestamp as a primary key to store log records/analytics data of users?
Will there be inconsistencies if a RDBMS is used to store log data?
Rumesh Madhusanka
(111 rep)
Feb 22, 2021, 05:16 AM
0
votes
1
answers
322
views
How can I list all the tablespaces without getting into each instance?
I got around 98 instances in a single AIX server. I need to list all the tablespaces, their path and usage. Is there a way I can do that without getting into each instance, connecting into the database etc?
I got around 98 instances in a single AIX server. I need to list all the tablespaces, their path and usage. Is there a way I can do that without getting into each instance, connecting into the database etc?
Mike
(1 rep)
Oct 2, 2020, 04:58 PM
• Last activity: Oct 2, 2020, 05:47 PM
0
votes
0
answers
566
views
Import table data using multiple sql file in psql
Local Machine(l1): Windows 10 psql Remote Machine(R1): linux EDB(postgres) On my local I have 1000+ sql script containing insert statement . psql is also installed locally . I need to run this sql script from my local command prompt using psql client . I can connect to remote db as `psql -h hostnme...
Local Machine(l1):
Windows 10
psql
Remote Machine(R1):
linux
EDB(postgres)
On my local I have 1000+ sql script containing insert statement . psql is also installed locally .
I need to run this sql script from my local command prompt using psql client .
I can connect to remote db as
psql -h hostnme -U username -p port DBName
. For single file i know that it can be run like \i f.sql
. I also tried combining all sql file in one file on windows using command copy /b *.sql new.sql
. But the new sql file size is 4 GB . Which is not easy to work with . Is there any way I can run those 1000+ sql script from psql without combining from command prompt ?
user236778
(35 rep)
Jul 6, 2020, 10:55 AM
2
votes
1
answers
205
views
Compute Leap Seconds
I use PostgreSQL 11 and have two columns. One is unix timestamp which is not aware of leap seconds and an utc timestamp which is aware of leap seconds. Is there a way either to find the number of leap seconds between an unix timestamp (without leap Seconds) and an utc timestamp (with leap seconds)?...
I use PostgreSQL 11 and have two columns. One is unix timestamp which is not aware of leap seconds and an utc timestamp which is aware of leap seconds.
Is there a way either to find the number of leap seconds between an unix timestamp (without leap Seconds) and an utc timestamp (with leap seconds)?
Alternatively is there a way to convert an utc timestamp (with leap seconds) into an unix timestamp (without leap seconds)?
nali
(206 rep)
Feb 21, 2019, 10:10 AM
• Last activity: Apr 21, 2020, 12:05 PM
-2
votes
1
answers
2310
views
How to resolve error "SQL0104N" when running "db2 prune logfile prior to" command?
I wrote an script to delete transaction log files in db2. I need to delete all the files prior to the active log file.I wrote this code as .sh file db2 connect to DWHDB db2 get db cfg | grep '/tlogdir/DWHDB/NODE0000/LOGSTREAM0000' db2 get db cfg | grep "First active log file">sample.txt x= awk '{pri...
I wrote an script to delete transaction log files in db2. I need to delete all the files prior to the active log file.I wrote this code as .sh file
db2 connect to DWHDB
db2 get db cfg | grep '/tlogdir/DWHDB/NODE0000/LOGSTREAM0000'
db2 get db cfg | grep "First active log file">sample.txt
x= awk '{print substr($0,60,12)}' sample.txt
db2 prune logfile prior to $x
When I execute above code following error came
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "TO".
Expected tokens may include: "". SQLSTATE=42601
How to fix this issue?
user203085
(1 rep)
Mar 11, 2020, 08:08 AM
• Last activity: Mar 17, 2020, 10:32 AM
2
votes
1
answers
973
views
How to insert multiple IP addresses in a pg_hba.conf file via unix shell script?
I need to write some IP addresses to the pg_hba.conf file of my Postgresql, in order to allow remote access from those IP to my machine. I have the following code in shell script to do that for a single IP address #!/bin/bash ######## PostgreSQL Child Server Host or IP Address serverhost=$1 ########...
I need to write some IP addresses to the pg_hba.conf file of my Postgresql, in order to allow remote access from those IP to my machine.
I have the following code in shell script to do that for a single IP address
#!/bin/bash
######## PostgreSQL Child Server Host or IP Address
serverhost=$1
######## PostgreSQL Child Server pg_hba.conf File Path
pghbapath=$2
######## Shell Script Command to write the data at the end of the pg_hba.conf file
sed -i "$ a host all all $serverhost/32 md5" $pghbapath
An example command to execute the above bash script is
./reset_ip.sh 192.168.10.27 /root/Desktop/BashScripts/pg_hba.conf
The above is working fine, but I have a lot of IP addresses with me. So, instead of manually running the command each and every time for a different IP address, is there a command which can take multiple IP addresses at once and write them to the pg_hba.conf file in one go?
Edit - Thanks a lot for the answer Luuk. I tried it and it worked. Now, suppose if instead of having a text file to hold all the address, I want to write the multiple IP addresses separated by commas in the command line itself, somewhat like
./reset_ip.sh 192.168.10.27,192.168.10.28,192.168.10.29,192.168.10.30 /root/Desktop/BashScripts/pg_hba.conf
Is it possible? What I basically want is to be able to pass multiple values for a single variable via the command prompt.
suvrat
(67 rep)
Nov 2, 2019, 10:13 AM
• Last activity: Nov 4, 2019, 03:04 PM
0
votes
2
answers
75
views
Fetching wrong results on comparing a variable with 0 in unix
I have the following code in unix #!/bin/bash user=$1 username=$user'%' DB_name=$2 userpwd=$4 export PGPASSWORD=$3 psql -h localhost -U postgres -d $DB_name -At -c "SELECT COUNT(*) AS USER_COUNT FROM pg_roles WHERE rolname = '${user}' " \ | while read -a Record ; do USER_COUNT=${Record[0]} echo 'use...
I have the following code in unix
#!/bin/bash
user=$1
username=$user'%'
DB_name=$2
userpwd=$4
export PGPASSWORD=$3
psql -h localhost -U postgres -d $DB_name -At -c "SELECT COUNT(*) AS USER_COUNT FROM pg_roles WHERE rolname = '${user}' " \
| while read -a Record ;
do
USER_COUNT=${Record}
echo 'user USER_COUNT ' $USER_COUNT
done
echo 'count' $count
if [[ $(($USER_COUNT)) -eq 0 ]]
then
echo 'New User ' $user
else
echo 'User Exists ' $user
fi
It basically accepts a given username and checks if it exists in Postgresql.
After we pass the arguments, it checks its count, which will be 1, if the username exists, otherwise 0, and stores it in the variable
USER_COUNT
.
It then compares it with 0.
But the comparison is fetching me wrong results.
Regardless of whether a username exists or not, it only runs the 'True' part of if.
_Edit-1_ The reason I used if [[ $(($USER_COUNT)) -eq 0 ]]
instead of
if [$USER_COUNT -eq 0 ]
, as suggested by Phill, is because I was getting an error message otherwise, saying unary operator expected. I read somewhere that it is because $USER_COUNT
is an unset variable.
_Edit-2_ Thanks for your suggestion Lennart. As suggested by him, I added -x
to my first line and found that even though the value of $USER_COUNT
is 1 when the user exists, and 0 otherwise, but while comparison, i.e in the step
if [[ $(($USER_COUNT)) -eq 0 ]]
, $USER_COUNT
takes the value 0, even if earlier it was 1. Hence, it always evaluates to true.
But I am not sure what to do to resolve the above situation.
_Edit-3_ Thanks a lot Lennart. Your code solved my problem.
suvrat
(67 rep)
Oct 29, 2019, 11:02 AM
• Last activity: Oct 29, 2019, 12:24 PM
1
votes
1
answers
207
views
Sybase query: How can I sort the extraction (by well formed columns)
community I built a *Sybase query* statement in a script (using the isql command/line ) below is the code: My script contains: isql -U databasename_dba -P password <<EOF! select customerid, notional, counterparty2 from table_1 inner join table_2 on id = id2 go quit EOF! I'm getting this: [
-b
isql -U databasename_dba -P password -b <
Lorenzo Castagno
(128 rep)
Jul 26, 2019, 12:58 PM
• Last activity: Jul 26, 2019, 05:27 PM
Showing page 1 of 20 total questions