Tuesday, 27 August 2019

Oracle Primavera P6, forgotten password and locked accounts

Had a situation where we had forgotten the admin password on one of our EPPM instances and the account had been locked out due to too many login attempts.

If you have another admin account then you can login as that user and reset the password or unlock the account using the admin front-end. If you don't then read on...

Fix locked account

Unlocking the account was achieved by doing the following.

  1. Login to the P6 apps server.
  2. Run adminpv.cmd from P6_HOME\p6.
  3. Login as privuser.
  4. Navigate to Configuration->Custom->Primavera P6 Configuration->Database.
  5. Right-click on Instance and select Reset login failures.

Fix lost password

Login to the database either as admuser or sys and run the following update statement.
update admuser.users set passwd = null where user_name = 'admin';
commit;
You can now login as admin, leaving the password blank.

Now that we were logged in to P6 we were able to reset the admin password.

Monday, 19 August 2019

Check Java Security file for running java versions

I had an issue where a number of Java processes were taking a long time to start up.
I had read somewhere that altering the java.security file to use /dev/./urandom instead of /dev/random or /dev/urandom could speed things up.

So as is my way, I wrote a script to chech this setting for me.
for x in $(for i in $(pgrep -x -U $(id -ur) java); do readlink /proc/$i/exe; done | sort -u); do
  fn=${x/bin\/java/}
  echo $fn
  grep "^securerandom.source" ${fn}jre/lib/security/java.security
done
Breaking this down, firstly I wanted to find out the executable use by all of my running Java processes.
pgrep -x -U $(id -ur) java
This returns a list of process ID's for any java processes running as my user.

I then use readlink to get to the actual executable for each process.
readlink /proc/$i/exe
For example if I had a prcess id of 42474 and ran the above readlink e.g. readlink /proc/42474/exe I'd get something like the following.
/proc/42474/exe -> /u01/app/oracle/prod/jdk1.8/bin/java
I then ran the list through sort -u to produce a unique (-u) list of executables.

After I have my unique list of java executable I just grep the java.security file for a line that begins with securerandom.source. The ${x/bin\/java/} takes the full path provided in the loop and replaces the bin/java with nothing.
/u01/app/oracle/prod/jdk1.7/bin/java
securerandom.source=/dev/random
/u01/app/oracle/prod/jdk1.8/bin/java
securerandom.source=/dev/./urandom

Thursday, 1 August 2019

Heredoc for DOS/Powershell (multiple commands to SQL*Plus)

Hi, I do this all the time in Linux, sending multiple commands to a programme...
sqlplus / as sysdba <<!
shutdown immediate
startup
@?/rdbms/admin/utlrp
!
It's called heredoc but trying to do the same in DOS was slightly different and took a while to figure out...
( echo shutdown immediate
echo startup
echo @?/rdbms/admin/utlrp
) | sqlplus / as sysdba
To explain the () allows me to enter a number of lines before executing them and returning me to the command prompt.

I need these new lines as SQL*Plus expects them as delimiters to seperate commands.

So the above commands echo's a number of commands and pipes the results to SQL*Plus.

To embed brackets you need to escape the bracket using ^^^( and ^^^) like this...
( echo shutdown immediate
echo Starting database ^^^(normally^^^)
echo startup
echo @?/rdbms/admin/utlrp
) | sqlplus / as sysdba
To do the same in PowerShell do the following...
@' echo shutdown immediate
echo startup
echo @?/rdbms/admin/utlrp
'@ | sqlplus / as sysdba
The closing '@ must be at the beginning of the line with no preceeding spaces, otherwise it will fail.

Oracle CPU downloader

Every quarter I have to go through and download numerous patches for the Oracle CPU (Critical Patch Update). You have to view the CPU docume...