Linux oraenv Tips
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. Also see my notes on oratab.
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.
Calling the oraenv File
The oraenv scriptshould be
called from a user's .bash_profile
to make these configuration changes. It is typically installed in
the /usr/local/bin directory and as long as that is included in
the PATH variable, it can be called with the following syntax.
. oraenv
If the ORACLE_SIDvariable
is set before the oraenv script is run, the value of ORACLE_SID is
given as a default when the user is prompted to enter a SID.
Additionally, if the ORAENV_ASK variable is set to NO before
oraenv is called, then oraenv does not prompt for a SID to be
entered; instead, the value from ORACLE_SID is used. Below is a
script showing oraenv being called without being prompted to enter
a SID.
export
ORACLE_SID=TEST
export ORAENV_ASK=NO
. oraenv
These are both valid methods for calling the oraenv
script. Which one you choose will depend on if you wish a user to
be prompted to give a SID when they log in.
Adding Custom Code to the oraenv File
Sometimes it is necessary to have product-specific environment
settings for a product associated with a given Oracle database.
The end of the oraenv script
has a special section to accommodate this kind of setting.
Custom settings can be added to the oraenv script after the
comment reading 'Install any 'custom'?? code here'. The oraenv
script is a Bourne shell script - most common shell scripting
syntax will work. Here is a short example of custom code added to
the oraenv script:
...
#
# Install any "custom" code here
#
TEMP_DIR=/tmp
export TEMP_DIR
case $ORACLE_SID in
TEST)
SCRIPT_DIR=/u01/app/laftdba/test
export SCRIPT_DIR
;;
PROD)
SCRIPT_DIR=/u01/app/laftdba/prod
export SCRIPT_DIR
;;
*)
unset SCRIPT_DIR;
;;
esac
In the example above, the first two lines setting
and exporting the variable TEMP_DIR are run for any database. The
case statement then executes additional code based on the setting
of ORACLE_SID. case statements will be explained further in the
section on shell scripting.
Oracle-Specific Environment
Settings
Oracle provides the oraenv script to set up most environment
variables necessary for Oracle administration. The oraenv script
sets the ORACLE_HOME, ORACLE_BASE and LD_LIBRARY_PATH variables
and updates the PATH variable with Oracle specific values.
WARNING: When |
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.
The next chapter, we will start to explore the many things we
that can be done to further customize and tune the Linux system.
Linux oraenv Tips的更多相关文章
- linux指令tips
1.调用命令使用应用名称免路径. 例如在路径 /usr/local/mobile/php538 建立了php应用,在调用php命令的时候,我们需要加路径访问 如 /usr/local/mobile ...
- 01 Linux入门介绍
一.Linux 初步介绍 Linux的优点 免费的,开源的 支持多线程,多用户 安全性好 对内存和文件管理优越 系统稳定 消耗资源少 Linux的缺点 操作相对困难 一些专业软件以及游戏支持度不足 L ...
- Linux转发性能评估与优化-转发瓶颈分析与解决方式(补遗)
补遗 关于网络接收的软中断负载均衡,已经有了成熟的方案,可是该方案并不特别适合数据包转发,它对server的小包处理非常好.这就是RPS.我针对RPS做了一个patch.提升了其转发效率. 下面是我转 ...
- Linux入门介绍
Linux入门介绍 一.Linux 初步介绍 Linux的优点 免费的,开源的 支持多线程,多用户 安全性好 对内存和文件管理优越 系统稳定 消耗资源少 Linux的缺点 操作相对困难 一些专业软件以 ...
- Linux转发性能评估与优化(转发瓶颈分析与解决方式)
线速问题 非常多人对这个线速概念存在误解. 觉得所谓线速能力就是路由器/交换机就像一根网线一样. 而这,是不可能的.应该考虑到的一个概念就是延迟. 数据包进入路由器或者交换机,存在一个核心延迟操作,这 ...
- Linux 驱动开发
linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...
- TCP的TIME_WAIT快速回收与重用
声明一点: Linux中是无法修改tcp的TIME_WAIT值的,除非重新编译,起码我是没有找到怎么改.值得注意的是,net.ipv4.tcp_fin_timeout这个参数是FIN_WAIT_2的值 ...
- 玩转渗透神器Kali:Kali Linux作为主系统使用的正确姿势TIPS
Kali Linux 前身是著名渗透测试系统BackTrack ,是一个基于 Debian 的 Linux 发行版,包含很多安全和取证方面的相关工具. 本文假设你在新装好的kali linux环境下… ...
- 10 Interesting Linux Command Line Tricks and Tips Worth Knowing
I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...
随机推荐
- Zookeeper 3.4 官方文档翻译
说明 个人英语水平非常一般,理解可能有偏差,假设有翻译不恰当之处,请看官指点. 1.简单介绍 分布式系统就像动物园.当中每台server就像一仅仅动物,Zookeeper就像动物园管理员,协调.服务于 ...
- js中字符串的拼接的另一种方法
// 按一定长度截断字符串,并使用 + 运算符进行连接. // 分隔字符串尽量按语义进行,如不要在一个完整的名词中间断开. // 特别的,对于HTML片段的拼接,通过缩进,保持和HTML相同的结构. ...
- DBscan算法及其Python实现
DBSCAN简介: 1.简介 DBSCAN 算法是一种基于密度的空间聚类算法.该算法利用基于密度的聚类的概念,即要求聚类空间中的一定区域内所包含对象(点或其它空间对象)的数目不小于某一给定阀值.DBS ...
- win64 qt与fortran (codeblocks) 混合编程
本教程主要解说用fortran生成dll供qt调用(win64) 本教程须要的软件及文件可从以下的连接下载: http://pan.baidu.com/s/1c04jziC fortran我用的软件是 ...
- Java基础学习之final和多态及类型转换
finalkeyword: finalkeyword是终于的意思,能够修饰类,成员变量,成员方法. • 修饰类,类不能被继承 • 修饰变量,变量就变成了常量,仅仅能被赋值一次. • ...
- 第一个get请求的爬虫程序
一:urllib库: urllib是Python自带的一个用于爬虫的库,器主要作用就是可以通过代码模拟浏览器发送请求.其被用到子模块在Python3中的urllib.request和urllib.pa ...
- 检查 统计 异常 通信 time_wait
[root@hadoop1 conf]# netstat -n | grep -v 127.0.0.1 | grep -v :3306 | grep TIME_WAIT | sort -k 5n | ...
- 较大主干网的ISP通常控制信道利用率不超过50%
信道利用率 网络利用率 加权平均值
- HttpsURLConnection 安全传输(HTTPS--Secure Hypertext Transfer Protocol-安全超文本传输协议)
HttpsURLConnection 扩展 HttpURLConnection,支持各种特定于 https 功能.此类使用 HostnameVerifier 和 SSLSocketFactory.为这 ...
- Oracle - 创建表视图等 - DDL
解锁scott: sqlplus / as sysdba; alter user scott account unlock; alter user scott identified by tiger; ...