biemond / biemond-oradb

Puppet Oracle Database Module
Apache License 2.0
59 stars 113 forks source link

set cwd during asm install #34

Closed cliles closed 9 years ago

cliles commented 9 years ago

It would be helpful to add cwd to the exec for installasm. The root script and the install script will fail if the site's exec default cwd is / since the grid user does not have correct permissions on /.

I set root.sh to use $gridHome and install orracle grid to $gridBase

This is on sol11.2

I have not made it to installing oracle binaries yet, so this could also be the case there.

biemond commented 9 years ago

Hi,

when I look at these statement, I can see they are started by root . So it should work

exec { "run root.sh grid script ${title}":
  timeout   => 0,
  command   => "${gridHome}/root.sh",
  user      => 'root',
  group     => 'root',
  path      => $execPath,
  logoutput => true,
  require   => Exec["install oracle grid ${title}"],
}

if ( $gridType == 'CRS_SWONLY' ) {
  exec { 'Configuring Grid Infrastructure for a Stand-Alone Server':
    command   => "${gridHome}/perl/bin/perl -I${gridHome}/perl/lib -I${gridHome}/crs/install ${gridHome}/crs/install/roothas.pl",
    user      => 'root',
    group     => 'root',
    path      => $execPath,
    logoutput => true,
    require   => Exec["run root.sh grid script ${title}"],
  }
cliles commented 9 years ago

MOS disagrees ;) Doc ID 1114203.1

# cat /u01/app/grid/11.2.0.4/install/root_box-02_2014-11-20_11-51-14.log
Performing root user operation for Oracle 11g 

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /u01/app/grid/11.2.0.4
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...

Creating /var/opt/oracle/oratab file...
Entries will be added to the /var/opt/oracle/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Using configuration parameter file: /u01/app/grid/11.2.0.4/crs/install/crsconfig_params
Creating trace directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
pwd: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
Run root.sh from a directory that has read/execute access to the grid owner 'grid'

As for the call to OUI it would also fail, with pwd errors to stdout, not detect memory/swap space, etc. I was unable to find KB article, but did make the following change.

exec { "install oracle grid ${title}":
      command   => "/bin/sh -c 'unset DISPLAY;${downloadDir}/${file_without_ext}/grid/runInstaller -silent -waitforcompletion -ignoreSysPrereqs -ignorePrereq -responseFile ${downloadDir}/grid_install_${version}.rsp'",
      creates   => $gridHome,
      timeout   => 0,
      returns   => [6,0],
      path      => $execPath,
      user      => $user,
      group     => $group_install,
      logoutput => true,
      cwd       => $gridBase,
      require   => [Oradb::Utils::Dborainst["grid orainst ${version}"],
                    File["${downloadDir}/grid_install_${version}.rsp"]],
    }

YMMV

biemond commented 9 years ago

interesting, probably in linux and solaris 10 you have enough right for / probably the root.sh script will do a user switch.

Maybe when you are done and got it all working on solaris 11 , then you can send me all the changes or send me a pull request and i will merge it .

Thanks

cliles commented 9 years ago

If you leave this open I will make a diff once I have asm and db installed.

biemond commented 9 years ago

Perfect,

also let me know what you do for the all packages, kernel parameters. Plus oradb support for Solaris 11.2 is high on my wishlist.

Thanks for your hard work

biemond commented 9 years ago

Hi,

I made some changes so it will also work for solaris 11.2 , The only thing what not works for me is the db creation in puppet. Somehow in the dbca puppet exec I get an shared memory error. From "su - oracle -c" or in oracle it works

Will do some more testing.

cliles commented 9 years ago

Better late than never.... but I ended up checking my edits against current master, you have already added the same cwds and additional requires as I did. At this point PR is not required.

biemond commented 9 years ago

Cool,

I am moving all the common, linux and solaris data to the oradb internal hiera so this will clean up lots of code. Hope to commit this change today

cliles commented 9 years ago

One thing I did run into was that $userHome in database.pp is not portable. While most sites will use /export/home or /home depending on the OS, there are some sites that will not.

Maybe using oracle_base is a better choice for cwd since the module is creating it and the minimum permissions for the oracle user are present?

biemond commented 9 years ago

Yeah you are right, I changed this from $oracleBase because of a dependency cycle of File [$oracleBase] on the cwd parameter but I solved this by moving all dbstructure's outside the if continue check. I will change it back.

Thanks

cliles commented 9 years ago

I also seem to have some problems with the new dirtree logic in dbcreatefolder. It might be my ancient ruby/puppet versions on my puppet master, but I seem to keep getting an array of Files passed to defined(), which fails as it expects strings or resources. I suspect either my ruby is bugged, or I am getting a nested array.

My oracle base is /u01/app/oracle, I'm getting an array of ['/u01', '/u01/app']. Any ideas?

biemond commented 9 years ago

Indeed ,

in dbstructure, I collect all root folders ( oracle base, download folder and Orainventory ) and remove the duplicates and exclude orable base, oraInventory etc folders. So your example is correct.

https://github.com/biemond/biemond-oradb/blob/master/manifests/utils/dbstructure.pp

add a prefix to it so it also work in combination with a grid, goldengate install where you probably share the /app or /u01/app folder

then in https://github.com/biemond/biemond-oradb/blob/master/manifests/utils/dbcreatefolder.pp remove the prefix and do a check if the folder is already defined.

this is all based on stdlib, I use ensure_resource, delete, prefix and then use regsubst to remove the prefix.

Maybe you can update stdlib or use create_resource instead of ensure_resource. and use the -trace option so we can know where it fails.

Thanks

cliles commented 9 years ago

opatch auto should execute as root, not sure why it's setup to use su. The sun/oracle bundled sparc su doesn't work with the current if block.

I changed db_opatch.rb, line 40 so that the opatch auto command will run as root.

output = `EXPORT ORACLE_HOME=#{oracle_product_home_dir}; #{command}`
biemond commented 9 years ago

thanks,

will change it.

biemond commented 9 years ago

I had to change it to this for linux

 output = `export ORACLE_HOME=#{oracle_product_home_dir}; #{command}`

will this also work for solaris

cliles commented 9 years ago

yes

cliles commented 9 years ago

opatch (maybe only auto?) also has the original issue.

At some point in opatch auto process, opatch will "su - grid" and run the opatch version detection process. This could fail, as I am thinking ruby executes the command relative to where the puppet run is executed.

output = `export ORACLE_HOME=#{oracle_product_home_dir}; cd #{oracle_product_home_dir}; #{command}`
biemond commented 9 years ago

Ok, in the end we will succeed :-)

will change it , so probably we should also do this for the normal opatch

biemond commented 9 years ago

I changed it for opatch and for opatch auto