====== Arbeitsumgebung setzen und Einrichten unter Windows und Linux ====== Eine richtige und einfach zu setzende Arbeitsumgebung in der Shell erspart viel Ärger und macht das Arbeiten einfacher. \\ siehe auch\\ * [[dba:dosbox_explorer|Dos Box in Windows im aktuellen Verzeichniss öffenen]] =====Microsoft Windows===== Besonders in einer Cluster Umgebung ist es wichtig auch unter Windows die richtigen Pfade etc. in der PowerShell Shell zu setzen.\\ Das setdb Script setzt den Pfad, das Oracle Home und bei Bedarf die passende SID.\\ Ein komplettes Beispiel für die Umsetzung in der Microsoft PowerShell befindet sich unter http://orapowershell.codeplex.com/ in meinen OpenSource Projekt OraPowerShell. Beispiel für ein DOS cmd Script: @ECHO OFF REM Script to set the environment Variables for the different Oracle Homes REM Master Script - Please change only this version! REM and copy then to all notes or press Key C REM GET IP Address :getIP -- return THIS computers IP address :: -- %~1 - out, IP SETLOCAL set ip= for /f "tokens=2,* delims=:. " %%a in ('"ipconfig|find "IPv4 Address""') do set ip=%%b ( ENDLOCAL & REM RETURN VALUES IF "%~1" NEQ "" (SET %~1=%ip%) ELSE (set ip=%ip%) ) set ORIG_PATH=%PATH:\=#% set ORIG_PATH=%ORIG_PATH:D:#oracle#product#11.2.0.4#dbhome_1#bin;=% set ORIG_PATH=%ORIG_PATH:D:#grid#11.2.0.4#bin;=% set ORIG_PATH=%ORIG_PATH:D;;=% REM INST_ID is the last number of IP Address of this node set INST_ID=%IP:~-1% REM if not use this if's rem IF '%COMPUTERNAME%' EQU 'WINRACDB01' set INST_ID=1 rem IF '%COMPUTERNAME%' NEQ 'WINRACDB01' set INST_ID=%IP:~-1% REM CLS echo +++++++++++--- This computers IP is: %ip% -- Script V2 -- +++++++++++++++++++ REM set DB inviroment choice /C 123C /M "set DB: [1]:GPIDB%INST_ID% - [2]:+ASM%INST_ID% - [3]:CRS" rem echo You choose %errorlevel% IF '%errorlevel%'=='1' GOTO GPIDB IF '%errorlevel%'=='2' GOTO ASM IF '%errorlevel%'=='3' GOTO CRS IF '%errorlevel%'=='4' GOTO COPY_SCRIPTS GOTO end :COPY_SCRIPTS echo copy new Version of db.cmd to all nodes of the GPIDB Environment rem copy setdb to windows3 copy /Y d:\tools\db.cmd \\192.178.0.240\c$\WINDOWS\system32\db.cmd copy /Y d:\tools\db.cmd \\192.178.0.230\c$\WINDOWS\system32\db.cmd copy /Y d:\tools\db.cmd \\192.178.0.220\c$\WINDOWS\system32\db.cmd rem copy sql copy /Y d:\tools\sql\*.sql \\192.178.0.240\D$\tools\sql copy /Y d:\tools\sql\*.sql \\192.178.0.230\D$\tools\sql copy /Y d:\tools\sql\*.sql \\192.178.0.220\D$\tools\sql rem copy setdb copy /Y d:\tools\db.cmd \\192.178.0.230\d$\tools copy /Y d:\tools\db.cmd \\192.178.0.220\d$\tools copy /Y d:\tools\db.cmd \\192.178.0.240\d$\tools :GPIDB ECHO +++++++++++++++--- set GPIDB DB Home ---++++++++++++++++++++++++++++++++ set ORACLE_HOME=D:\oracle\product\11.2.0.4\dbhome_1 set ORACLE_SID=GPIDB%INST_ID% set ORIG_PATH=D:#oracle#product#11.2.0.4#dbhome_1#bin;%ORIG_PATH% color F5 title GPIDB DB Home prompt $P : GPIDB$F GOTO end :ASM ECHO +++++++++++++++--- set ASM DB Home ---++++++++++++++++++++++++++++++++ set ORACLE_HOME=D:\grid\11.2.0.4 set ORACLE_SID=+ASM%INST_ID% set ORIG_PATH=D:#grid#11.2.0.4#bin;%ORIG_PATH% color F1 title Oracle ASM DB Home prompt $P : ASM$F GOTO end :CRS ECHO +++++++++++++++--- set CRS DB Home ---++++++++++++++++++++++++++++++++ set ORACLE_HOME=D:\grid\11.2.0.4 set ORACLE_SID= set ORIG_PATH=D:#grid#11.2.0.4#bin;%ORIG_PATH% color F8 title Oracle CRS DB Home prompt $P : CRS$F GOTO end :end set ORIG_PATH=%ORIG_PATH:#=\% set PATH=%ORIG_PATH% set SQLPATH=D:\tools\sql rem echo %PATH% ECHO SET: ORACLE_HOME :: %ORACLE_HOME% ECHO SET: ORACLE_SID :: %ORACLE_SID% ECHO SET: SQLPATH :: %SQLPATH% ECHO SET: PATH First :: %PATH:~0,29%... ECHO ++++++++++++++++++--- Version 2.0 ---+++++++++++++++++++++++++++++++++++ ===== Linux - Arbeitsumgebung setzen und einrichten ===== In einer Linux Umgebung ist es etwas einfacher, eine shell Funktion wird in der .profile (und/oder in der .bashrc ) definiert\\ Eine automatisierte Version kann hier gefunden werden :[[http://orapowershell.codeplex.com/SourceControl/latest#bash/.profile|.profile]] export ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1 export ORACLE_BASE=/opt/oracle export TNS_ADMIN=/opt/oracle/product/11.2.0/dbhome_1/network/admin export SQLPATH=/home/oracle/sql ORIG_PATH=$PATH # setzen einer DB setdb () { echo "bisherige Oracle_Sid=$ORACLE_SID" a=${1-$ORACLE_SID} if [ -z "$1" ] then echo "zulaessige DB's : 1=EXEC01 2=client 3=: [$ORACLE_SID] >\c" read a a=${a:=$ORACLE_SID} fi A=`echo "$a"|tr "[a-z]" "[A-Z]"` case "$A" in 1 | EXEC01 ) ORACLE_SID=EXEC01 ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1;; 2 | client ) ORACLE_HOME=/opt/oracle/product/11.2.0/client_1 ORACLE_SID=;; *) echo "falsche Eingabe: $a ($A)" ;; esac export ORACLE_SID export ORACLE_HOME export PATH=$ORIG_PATH:$ORACLE_HOME/bin echo "die neue Oracle_Sid=$ORACLE_SID unter dem Home $ORACLE_HOME" } whichdb() { echo "die Oracle_Sid=$ORACLE_SID" }