Saturday, April 25, 2015

Customizing the Oracle User's Environment


Linux for the Oracle DBA -Customizing the Oracle User's Environment


There are many ways to customize the Oracle user on the system.  I strongly recommend making the changes covered in this section.  Other less common customizations will be examined in Chapter 8, 'Customizing the User Environment'??.
To effectively administer the Oracle installation we that was just made, it is useful to have several environment variables set whenever a command line session is started.  The Oracle provided script oraenv is the best way to set these variables automatically. The oraenv scriptis installed in /usr/local/bin and takes values from the oratab file located in /etc.  The oratab filetypically contains an entry for each database, but in the current configuration, there is no database set up.  To use the oraenv script, set up a dummy entry in the oratab file.
The oratab file can be edited by the oracle user using vi or another text editor.  Each line in the oratab file has three elements separated by colons.  The first element is the SID, the second indicates the Oracle Home directory for that SID, and the third indicates if the database should be started and stopped by the dbstart/dbshut commands.
Edit the oratab file and add the following line:
db_11g:/u01/app/oracle/product/11.1.0/db_1:N
Though a database does not exist by the name db_11g, this entry allows us to setting up the environment for this home without having to set several variables manually.  Make sure the final element is set to N so Oracle does not attempt to start a database that is not there.
With an entry now in the oratab file, use the oraenv command to set up theour environment.  To do that, run .oraenv which causes the oraenv script to be run as part of the current shell rather than as a subprogram.
$ . oraenv

ORACLE_SID = [oracle] ? db_11g
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
 

$ echo $ORACLE_SID

db_11g

$ echo $ORACLE_HOME

/u01/app/oracle/product/11.1.0/db_1

$ echo $PATH
 

/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin:/u01/app/
oracle/product/11.1.0/db_1/bin

Among other things, the oraenv script sets the ORACLE_SID and ORACLE_HOME variables.  The PATH variable is also updated to include the location of the Oracle binaries. Though they could be set manually, the oraenv script is the best way to set these variables.  Since these variables should be set anytime, log in as oracle and can then add the oraenv command to the user's profile.
A user's profile, often referred to as the dot-profile, is a hidden file in their home directory that is executed when a user logs in. Since Linux uses the bash shell by default, the profile file is called .bash_profile.  Using the -a option, it can be seen in an ls listing. 
$ pwd

/home/oracle

$ ls -a

.              .bash_logout   database_11g  .gconfd          .mozilla
..             .bash_profile  .emacs        .gnome2          .viminfo
.bash_history  .bashrc        .gconf        .gnome2_private  .Xauthority

The profile can be edited with vi or another text editor.  To run oraenv when the user
logs in, add the following lines to the .bash_profile file.
ORACLE_SID=db_11g
ORAENV_ASK=NO
. oraenv
This causes the Oracle variables to be set based on the oratab entry for db_11g without any prompting.  If the variable ORAENV_ASK is changed to YES or is not set at all, there is a prompted to enter a SID when logging in.
Conclusion
There are a lot of steps to getting a system ready for Oracle.  System requirements, installed software and many settings must all be correct or Oracle will not function properly.  As these steps are reviewed, it is a good idea to take notes on what things were set to when they were found and what changes were made to prepare for Oracle.  This will make preparing future systems much easier.

Bash_profile Editing

Editing $ su root # vi ~ .bash_profile [I, type, [Esc]:wq!]

When I use dbca command as Oracle 11g user I have the following error message:
BASH: DBCA:  command not found
and when I checked the bash profile I found the following:
    # .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=oracledev-srv.etqint.com; export ORACLE_HOSTNAME
#ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
#ORACLE_BASE=/oracle11gr2/u01/app/oracle; export ORACLE_BASE
#ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
#ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


PATH=$PATH:$HOME/bin
unset USERNAME
cd $ORACLE_BASE
export PATH
Server information: RedHat Linux 6.3, Oracle installed on the server 11g R2 and 12c.
What I did for investigation:
  1. check the bash file and found out they are correct
  2. navigate to bin file and hit dbca but still the same error message
  3. edit the bash file manually in-case I missed something
  4. reboot the server
And still the same error message.

Where is .bash_profile?


I want to put new aliases to my .bash_profile file, but I cannot find this file.
Where is it supposed to be?
shareimprove this question

1  
The title should probably read .bash_profile with the dot. –  H2ONaCl Dec 11 '12 at 8:39

4 Answers

up vote 11 down vote accepted
It's a hidden file, located in your home folder:
~/.bash_profile
(the ~ expands to your home directory. If your username is user, the result would be: /home/user/.bash_profile).
Since it's an hidden file, you have to make it visible. To do it in Nautilus go to the "View" menu and check "Show hidden files" (or press the shortcut Ctrl + H).
If you are using Kubuntu with Dolphin, you have to press Ctrl + . to toggle the visibility of files.
shareimprove this answer

2  
The Keys Ctrl-H toggles the show/hide hidden files also. –  Ice Mar 6 '11 at 17:15
    
sweet didn't know about that ctrl+H –  schwiz Mar 6 '11 at 23:58
~/.bash_profile is not the right place to put aliases and functions. They should go in ~/.bashrc. See http://mywiki.wooledge.org/DotFiles for an explanation.

Oracle Installation Prerequisites

This article describes the installation of Oracle Database 11g Release 2 (11.2.0.4) 64-bit on Oracle Linux 7 (OL7) 64-bit. The article is based on a server installation with a minimum of 2G swap and secure Linux set to permissive. An example of this type of Linux installation can be seen here.

Download Software

Download the Oracle software using one of the two link below. If you have access to My Oracle Support (MOS), then it is better to download the 11.2.0.4 version, since this is the first release of 11.2 that is supported on Oracle Linux 7.

Unpack Files

Unzip the files.
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
You should now have a single directory called "database" containing installation files.

Hosts File

The "/etc/hosts" file must contain a fully qualified name for the server.
<IP-address>  <fully-qualified-machine-name>  <machine-name>
For example.
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.0.215   ol7.localdomain  ol7
Set the correct hostname in the "/etc/hostname" file.
ol7.localdomain

Oracle Installation Prerequisites

Perform either the Automatic Setup or the Manual Setup to complete the basic prerequisites. The Additional Setup is required for all installations.

Automatic Setup

If you plan to use the "oracle-rdbms-server-11gR2-preinstall" package to perform all your prerequisite setup, follow the instructions at http://public-yum.oracle.com to setup the yum repository for OL, then perform the following command.
# yum install oracle-rdbms-server-11gR2-preinstall
All necessary prerequisites will be performed automatically.
It is probably worth doing a full update as well, but this is not strictly speaking necessary.
# yum update

Monday, April 20, 2015

Package java.lang Description

Package java.lang

Provides classes that are fundamental to the design of the Java programming language.
See: Description
  • Interface Summary 
    InterfaceDescription
    Appendable
    An object to which char sequences and values can be appended.
    AutoCloseable
    A resource that must be closed when it is no longer needed.
    CharSequence
    CharSequence is a readable sequence of char values.
    Cloneable
    A class implements the Cloneable interface to indicate to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class.
    Comparable<T>
    This interface imposes a total ordering on the objects of each class that implements it.
    Iterable<T>
    Implementing this interface allows an object to be the target of the "foreach" statement.
    Readable
    Readable is a source of characters.
    Runnable
    The Runnable interface should be implemented by any class whose instances are intended to be executed by a thread.
    Thread.UncaughtExceptionHandler
    Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception.
  • Class Summary 
    ClassDescription
    Boolean
    The Boolean class wraps a value of the primitive type boolean in an object.
    Byte
    The Byte class wraps a value of primitive type byte in an object.
    Character
    The Character class wraps a value of the primitive type char in an object.
    Character.Subset
    Instances of this class represent particular subsets of the Unicode character set.
    Character.UnicodeBlock
    A family of character subsets representing the character blocks in the Unicode specification.
    Class<T>
    Instances of the class Class represent classes and interfaces in a running Java application.
    ClassLoader
    A class loader is an object that is responsible for loading classes.
    ClassValue<T>
    Lazily associate a computed value with (potentially) every type.
    Compiler
    The Compiler class is provided to support Java-to-native-code compilers and related services.
    Double
    The Double class wraps a value of the primitive type double in an object.
    Enum<E extends Enum<E>>
    This is the common base class of all Java language enumeration types.
    Float
    The Float class wraps a value of primitive type float in an object.
    InheritableThreadLocal<T>
    This class extends ThreadLocal to provide inheritance of values from parent thread to child thread: when a child thread is created, the child receives initial values for all inheritable thread-local variables for which the parent has values.
    Integer
    The Integer class wraps a value of the primitive type int in an object.
    Long
    The Long class wraps a value of the primitive type long in an object.
    Math
    The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
    Number
    The abstract class Number is the superclass of classes BigDecimalBigIntegerByteDoubleFloat,IntegerLong, and Short.
    Object
    Class Object is the root of the class hierarchy.
    Package
    Package objects contain version information about the implementation and specification of a Java package.
    Process
    The ProcessBuilder.start() and Runtime.exec methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it.
    ProcessBuilder
    This class is used to create operating system processes.
    ProcessBuilder.Redirect
    Represents a source of subprocess input or a destination of subprocess output.
    Runtime
    Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running.
    RuntimePermission
    This class is for runtime permissions.
    SecurityManager
    The security manager is a class that allows applications to implement a security policy.
    Short
    The Short class wraps a value of primitive type short in an object.
    StackTraceElement
    An element in a stack trace, as returned by Throwable.getStackTrace().
    StrictMath
    The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
    String
    The String class represents character strings.
    StringBuffer
    A thread-safe, mutable sequence of characters.
    StringBuilder
    A mutable sequence of characters.
    System
    The System class contains several useful class fields and methods.
    Thread
    thread is a thread of execution in a program.
    ThreadGroup
    A thread group represents a set of threads.
    ThreadLocal<T>
    This class provides thread-local variables.
    Throwable
    The Throwable class is the superclass of all errors and exceptions in the Java language.
    Void
    The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.
  • Enum Summary 
    EnumDescription
    Character.UnicodeScript
    A family of character subsets representing the character scripts defined in the Unicode Standard Annex #24: Script Names.
    ProcessBuilder.Redirect.Type
    The type of a ProcessBuilder.Redirect.
    Thread.State
    A thread state.
  • Exception Summary 
    ExceptionDescription
    ArithmeticException
    Thrown when an exceptional arithmetic condition has occurred.
    ArrayIndexOutOfBoundsException
    Thrown to indicate that an array has been accessed with an illegal index.
    ArrayStoreException
    Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects.
    ClassCastException
    Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.
    ClassNotFoundException
    Thrown when an application tries to load in a class through its string name using: The forName method in class Class.
    CloneNotSupportedException
    Thrown to indicate that the clone method in class Object has been called to clone an object, but that the object's class does not implement the Cloneable interface.
    EnumConstantNotPresentException
    Thrown when an application tries to access an enum constant by name and the enum type contains no constant with the specified name.
    Exception
    The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.
    IllegalAccessException
    An IllegalAccessException is thrown when an application tries to reflectively create an instance (other than an array), set or get a field, or invoke a method, but the currently executing method does not have access to the definition of the specified class, field, method or constructor.
    IllegalArgumentException
    Thrown to indicate that a method has been passed an illegal or inappropriate argument.
    IllegalMonitorStateException
    Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor.
    IllegalStateException
    Signals that a method has been invoked at an illegal or inappropriate time.
    IllegalThreadStateException
    Thrown to indicate that a thread is not in an appropriate state for the requested operation.
    IndexOutOfBoundsException
    Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.
    InstantiationException
    Thrown when an application tries to create an instance of a class using the newInstance method in classClass, but the specified class object cannot be instantiated.
    InterruptedException
    Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.
    NegativeArraySizeException
    Thrown if an application tries to create an array with negative size.
    NoSuchFieldException
    Signals that the class doesn't have a field of a specified name.
    NoSuchMethodException
    Thrown when a particular method cannot be found.
    NullPointerException
    Thrown when an application attempts to use null in a case where an object is required.
    NumberFormatException
    Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.
    ReflectiveOperationException
    Common superclass of exceptions thrown by reflective operations in core reflection.
    RuntimeException
    RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine.
    SecurityException
    Thrown by the security manager to indicate a security violation.
    StringIndexOutOfBoundsException
    Thrown by String methods to indicate that an index is either negative or greater than the size of the string.
    TypeNotPresentException
    Thrown when an application tries to access a type using a string representing the type's name, but no definition for the type with the specified name can be found.
    UnsupportedOperationException
    Thrown to indicate that the requested operation is not supported.
  • Error Summary 
    ErrorDescription
    AbstractMethodError
    Thrown when an application tries to call an abstract method.
    AssertionError
    Thrown to indicate that an assertion has failed.
    BootstrapMethodError
    Thrown to indicate that an invokedynamic instruction has failed to find its bootstrap method, or the bootstrap method has failed to provide a call site with a target of the correct method type.
    ClassCircularityError
    Thrown when the Java Virtual Machine detects a circularity in the superclass hierarchy of a class being loaded.
    ClassFormatError
    Thrown when the Java Virtual Machine attempts to read a class file and determines that the file is malformed or otherwise cannot be interpreted as a class file.
    Error
    An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.
    ExceptionInInitializerError
    Signals that an unexpected exception has occurred in a static initializer.
    IllegalAccessError
    Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
    IncompatibleClassChangeError
    Thrown when an incompatible class change has occurred to some class definition.
    InstantiationError
    Thrown when an application tries to use the Java new construct to instantiate an abstract class or an interface.
    InternalError
    Thrown to indicate some unexpected internal error has occurred in the Java Virtual Machine.
    LinkageError
    Subclasses of LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class.
    NoClassDefFoundError
    Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
    NoSuchFieldError
    Thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field.
    NoSuchMethodError
    Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.
    OutOfMemoryError
    Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.
    StackOverflowError
    Thrown when a stack overflow occurs because an application recurses too deeply.
    ThreadDeath
    An instance of ThreadDeath is thrown in the victim thread when the (deprecated) Thread.stop() method is invoked.
    UnknownError
    Thrown when an unknown but serious exception has occurred in the Java Virtual Machine.
    UnsatisfiedLinkError
    Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declarednative.
    UnsupportedClassVersionError
    Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.
    VerifyError
    Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem.
    VirtualMachineError
    Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.
  • Annotation Types Summary 
    Annotation TypeDescription
    Deprecated
    A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.
    Override
    Indicates that a method declaration is intended to override a method declaration in a supertype.
    SafeVarargs
    A programmer assertion that the body of the annotated method or constructor does not perform potentially unsafe operations on its varargs parameter.
    SuppressWarnings
    Indicates that the named compiler warnings should be suppressed in the annotated element (and in all program elements contained in the annotated element).

Package java.lang Description

Provides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time.Frequently it is necessary to represent a value of primitive type as if it were an object. The wrapper classes BooleanCharacterIntegerLong,Float, and Double serve this purpose. An object of type Double, for example, contains a field whose type is double, representing that value in such a way that a reference to it can be stored in a variable of reference type. These classes also provide a number of methods for converting among primitive values, as well as supporting such standard methods as equals and hashCode. The Void class is a non-instantiable class that holds a reference to a Class object representing the type void.
The class Math provides commonly used mathematical functions such as sine, cosine, and square root. The classes StringStringBuffer, andStringBuilder similarly provide commonly used operations on character strings.
Classes ClassLoaderProcessProcessBuilderRuntimeSecurityManager, and System provide "system operations" that manage the dynamic loading of classes, creation of external processes, host environment inquiries such as the time of day, and enforcement of security policies.
Class Throwable encompasses objects that may be thrown by the throw statement. Subclasses of Throwable represent errors and exceptions.

Character Encodings

The specification of the java.nio.charset.Charset class describes the naming conventions for character encodings as well as the set of standard encodings that must be supported by every implementation of the Java platform.
Since:
JDK1.0