centos7 下安装oracle 11g笔记

时间:2023-03-09 08:52:17
centos7 下安装oracle 11g笔记

安装关键步骤:

[sonny@localhost ~]$ su root  #切换到root
Password:
[root@localhost sonny]# groupadd oinstall  #创建用户组oinstall
[root@localhost sonny]# groupadd dba  #创建用户组dba
[root@localhost sonny]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
[root@localhost sonny]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
Changing password for user oracle.
New password:   # 密码
BAD PASSWORD: The password is shorter than characters
Retype new password:   # 确认密码
passwd: all authentication tokens updated successfully.
[root@localhost sonny]# id oracle # 查看新建的oracle用户
uid=(oracle) gid=(dba) groups=(dba)
[root@localhost sonny]# [sonny@localhost ~]$ su root
Password:
[root@localhost sonny]# mkdir -p /data/oracle  #oracle数据库安装目录
[root@localhost sonny]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录
[root@localhost sonny]# mkdir -p /data/database  #oracle数据库软件包解压目录
[root@localhost sonny]# cd /data
[root@localhost data]# ls  #创建完毕检查一下(强迫症)
database oracle oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
[root@localhost data]# chown -R oracle:oinstall /data/oraInventory
[root@localhost data]# chown -R oracle:oinstall /data/database
[root@localhost data]# [sonny@localhost data]$ su root
Password:
[root@localhost data]# cat /proc/version
Linux version 3.10.-.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8. (Red Hat 4.8.-) (GCC) ) # SMP Thu Nov :: UTC
[root@localhost data]# cat /etc/redhat-release  
CentOS Linux release 7.2. (Core)
[root@localhost data]# vi /etc/redhat-release
[root@localhost data]# cat /etc/redhat-release
redhat-
[root@localhost data]# yum install gcc gcc-c++ glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel zlib-devel unzip compat-libcap1 compat-libstdc++- [root@localhost /]# vi /etc/selinux/config
[root@localhost /]# cat /etc/selinux/config # This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此处修改为disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted [root@localhost /]#

终于在vmare的centos7下将oracle11g安装成功了,不容易,将结果记录如下

启动oracle监听及服务的步骤,使用oracle用户登录,执行以下命令

登录到CentOS,切换到oracle用户权限
# su – oracle
接着输入:
$ sqlplus "/as sysdba"
原本的画面会变为
SQL>
接着请输入
SQL> startup
就可以正常的启动数据库了。

检查Oracle DB监听器是否正常

回到终端机模式,输入:
SQL> exit
$ lsnrctl status
检查看看监听器是否有启动
如果没有启动,可以输入:
$ lsnrctl start
启动监听器

使用plsql查看服务器版本信息

centos7 下安装oracle 11g笔记

centos7 下安装oracle 11g笔记

centos7 下安装oracle 11g笔记

centos7 下安装oracle 11g笔记

centos7 下安装oracle 11g笔记

centos7 下安装oracle 11g笔记

CentOS设置Oracle开机自动启动

 在Windows下安装完成Oracle 11gR2后,默认就开机自启动Oracle相关服务,但Linux下安装完后每次都得手动启动和关闭数据库(dbstart | dbshut)、监听器(lsnrctl)、控制台(emtcl)。如何把Oracle添加到Linux系统服务里开机自启动呢?下面以CentOS .3为例详解,其他发行版一样通用!

 、Redhat init简介:
Linux启动时,会运行一个init程序,然后由init来启动后面的任务,包括多用户环境(inittab中设定)和网络等。运行级就是当前程序运行的功能级别,这个级别从1到6,具有不同的功能。这些级别在/etc/inittab(其他发行版这个文件位置不同)中指定,该文件就是init程序寻找的主要文件。最先运行的服务放在/etc/rc.d目录下。
文件以S开头,代表start(启动),后面的数字是启动顺序;文件以K开头,代表kill(结束),同样,后面的数字代表结束顺序。例如:/etc/rc3.d/S55sshd表示它与运行级别3有关,55就是它的启动顺序;/etc/rc3.d/K15nginx表示它与运行级别3有关,15就是它的关闭顺序。
init.d
这个目录中存放了一些服务启动脚本,系统安装时的多个rpm包,这些脚本在执行时可以用来启动,停止和重启这些服务。
rcx.d(x为0~)
这个目录是启动级别的执行程序链接目录,里面的文件都是指向init.d目录中文件的一些软连接。
、修改dbstart和dbshut启动关闭脚本,使其启动数据库的同时也自动启动监听器(即启动数据库时启动监听器,停止数据库时停止监听器):
# vim /u01/app/oracle/product/11.2./db_1/bin/dbstart
找到下面的代码,在实际脚本代码的前面 # First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$
# 将此处的 ORACLE_HOME_LISTNER=$ 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
同样也修改dbshut脚本:
# vim /u01/app/oracle/product/11.2./db_1/bin/dbshut # The this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$
# 将此处的 ORACLE_HOME_LISTNER=$ 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
、新建Oracle服务启动脚本:
# vim /etc/init.d/oracle
新建一个以oracle命名的文件(也可以命名为oracle11g等,自己喜欢啥名改啥名。),并将以下脚本代码复制到文件里(里面的oracle目录路径根据自己的实际安装路径修改): #!/bin/sh
# chkconfig:
# description: Oracle 11g R2 AutoRun Servimces
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2./db_1
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$ stop
$ start
;;
*)
echo $"Usage: `basename $0` {start|stop|reload|reload}"
exit
esac
exit 保存退出!
、赋予启动脚本执行权限并链接好:
# chmod /etc/init.d/oracle # ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle # ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
、把oracle启动脚本添加到系统服务里并设置自启动:
# chkconfig --add oracle # chkconfig --level oracle on
reboot重启系统看看效果吧

Oracle自启动

export NLS_LANG="AMERICAN_AMERICA.UTF8"

参考:

http://www.linuxidc.com/Linux/2016-04/130559p2.htm#0-tsina-1-45959-397232819ff9a47a7b7e80a40613cfe1

http://www.jianshu.com/p/36a78274a00e

http://blog.sina.com.cn/s/blog_4af62a6501018xfj.html