Linux下oracle11gR2系统安装到数据库建立配置及最后oracle的dmp文件导入一站式操作记录(转)

上次碰到问题,cursor:mutex
S导致的load过高,有说可以升级到11.2.0.4就能避免这种问题,所以准备重新搭建新版本11.2.0.4。

1、准备安装

简介

安装环境是:azure云 linux centos6.5。

查看当前oracle版本,确定是比较旧的11.2.0.1

之前也在linux下安装过oralce,可每次都是迷迷糊糊的,因为大脑一片空白,网上随便看见一个文档就直接复制,最后搞了乱七八糟,虽然装上了,却乱得很,最近几天因为离职,交接的时候又要安装oracle,发现老遇到错误,导致装不上了,通过这次我好好的研究了下oracle,非要搞清楚它,现在记录下来,希望能给其他网上朋友遇到问题时提供点帮助,该篇文件借鉴大量网友的总结,首先谢谢他们!

1,修改内核

[oracle@hch_test_121_90 ~]$ rlwrap sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 17 15:20:45 2017 Copyright  1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@hch_test_121_90 ~]$ 

安装环境

1.1 修改sysctl.conf文件

上传11.2.0.4的安装包p13390677_112040_Linux-x86-64_1of7.zip、p13390677_112040_Linux-x86-64_2of7.zip到服务器上。Oracle11.2.0.4的安装包下载,请查阅我的blog地址,这上面有下载源:

Linux 服务器: SuSe11-linux      64/32位
Oracle服务器: Oracle11gR2      64/32位
[root@orcltest Downloads]# vim/etc/sysctl.conf# add by tim.mankernel.shmmax = 277495689510912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586fs.file-max = 6815744 # Controls the maximum number of shared memory segments, in pages kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 6000net.ipv4.ip_local_port_range = 9000 65500net.ipv4.tcp_tw_recycle = 0net.ipv4.tcp_tw_reuse = 1net.core.somaxconn = 262144net.core.netdev_max_backlog = 262144net.ipv4.tcp_max_orphans = 262144net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_synack_retries = 2net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_fin_timeout = 1net.ipv4.tcp_keepalive_time = 30net.ipv4.tcp_keepalive_probes = 6net.ipv4.tcp_keepalive_intvl = 5net.ipv4.tcp_timestamps = 0fs.aio-max-nr = 1048576
解压缩: [oracle@hch_test_121_90 oracle]$ unzip p13390677_112040_Linux-x86-64_1of7.zip [oracle@hch_test_121_90 oracle]$ unzip p13390677_112040_Linux-x86-64_2of7.zip 打开启动图像界面 [oracle@hch_test_121_90 oracle]$ cd database/ [oracle@hch_test_121_90 database]$ ./runInstaller Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 6024 MB Passed Checking swap space: must be greater than 150 MB. Actual 1798 MB Passed Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-03-17_03-11-29PM. Please wait ...[oracle@hch_test_121_90 database]$ [oracle@hch_test_121_90 database]$ 

系统要求

1.2 使参数生效

2、开始升级

内存: 必须高于1G的物理内存
交换空间: 一般为内存的2倍,例如:1G的内存可以设置swap 分区为3G大小
硬盘 : 5G以上
[root@orcltest Downloads]# sysctl –p

C:\pic\oracle\100.png,填写邮箱地址,然后下一步

系统配置

2,增加用户和组

选择忽略软件升级,下一步吗,如101.png

一、在root用户下执行以下步骤:

[root@orcltestDownloads]# groupadd oinstall[root@orcltestDownloads]# groupadd dba[root@orcltestDownloads]# groupadd oper[root@orcltestDownloads]# useradd -g oinstall -G dba,oper oracle[root@orcltestDownloads]# passwd oracle

然后选择升级,如下102.png

1)修改用户的SHELL的限制,修改/etc/security/limits.conf文件,输入命令:vi
/etc/security/limits.conf,按i键进入编辑模式,将下列内容加入该文件

3,修改limits.conf限制

然后继续进行,有个INS-35373错误,选择Yes,如下

oracle  soft  nproc    2047

oracle  hard  nproc   16384

oracle  soft  nofile    1024

oracle  hard  nofile 65536

[root@orcltestDownloads]# vim /etc/security/limits.conforacle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024oracle hard nofile 65536

然后选择好语言种类,简体中文、繁体中文、英语、美式英语等,如104.png所示:

编辑完成后按Esc键,输入“:wq”存盘退出.(不配置好的话安装时就会提示什么空间不足,达不到xxx…要求无法安装)

澳门金沙vip,4,修改/etc/pam.d/login

继续下一步,选择企业版,如

2)修改/etc/pam.d/login 文件,输入命令:vi
/etc/pam.d/login,按i键进入编辑模式,将下列内容加入该文件

[root@orcltestDownloads]# vim /etc/pam.d/loginsession required/lib64/security/pam_limits.so

接下来,开始选择oracle目录了,是选择新建的目录呢还是选择原来的老版本11.2.0.1的目录呢?这里最好选择一个新的目录,因为万一升级失败了,老的oracle版本软件目录没有被覆盖掉,还可以继续使用的,否则升级失败,就基本只有彻底暴力清除所有文件以及注册信息,之后重新安装oracle了。

session     required       /lib/security/pam_limits.so  
session     required       pam_limits.so

5,修改bash_profile文件

我这里就选择一个新的目录11.2.0.4的目录,如106.png、107.png所示

编辑完成后按Esc键,输入“:wq”存盘退出

修改profile:

接下来,继续,选择新的的Inventory
Directory目录,默认的会报错,如108.png所示

3)修改linux内核,修改/etc/sysctl.conf文件

 [root@orcltest Downloads]# vim /etc/profile # add by tim.manif [ $USER = "oracle" ]; thenif [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536else ulimit -u 16384 -n 65536fifi

接下来选择用户组和操作组,如109.png所示:

kernel.shmall = 268435456

fs.file-max=6815744

fs.aio-max-nr=1048576

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range=9000 65500

net.core.rmem_default=4194304

net.core.rmem_max=4194304

net.core.wmem_default=262144

net.core.wmem_max=1048586

修改bash_profile:

接下来,会有checking各种lib包,一些比较偏的,缺少了也没事,直接Ignore忽略掉就ok,如110.png所示:

编辑完成后按Esc键,输入“:wq”存盘退出

[oracle@orcltest ~]$ vim .bash_profileexport EDITOR=viexport ORACLE_SID=doea5dbexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1export INVENTORY_LOCATION=/oraInventoryexport LD_LIBRARY_PATH=$ORACLE_HOME/libexport NLS_LANG="American_america.zhs16gbk"export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/binumask 022

下一步看安装的目录以及基本信息,如111.png所示:

4)要使 /etc/sysctl.conf 更改立即生效,执行以下命令。 输入:sysctl  -p

使bash_profile生效:

然后点击“”Install“”按钮,开始安装,如图112.png

5)编辑 /etc/profile ,输入命令:vi
/etc/profile,按i键进入编辑模式,将下列内容加入该文件

[oracle@orcltest ~]$ source .bash_profile

中级需要执行配置脚本,如图112_1.png

if [ $USER = "oracle" ]; then

if [ $SHELL = "/bin/ksh" ]; then

  ulimit -p 16384

  ulimit -n 65536

else

  ulimit -u 16384 -n 65536

fi

   umask 022

fi

6,创建目录

重新打开xshell,ssh连接到数据库,在命令行去执行命令:

编辑完成后按Esc键,输入“:wq”存盘退出

[root@orcltest~]# mkdir /data/oracle[root@orcltest~]# chown oracle:oinstall /data [root@azure_earth_dbm1_3_112 app]# mkdir /data/oracle[root@azure_earth_dbm1_3_112 app]# mkdir /data/oraInventory[root@azure_earth_dbm1_3_112 app]# cd /oracle/app[root@azure_earth_dbm1_3_112 app]# ln -s /data/oracle oracle[root@azure_earth_dbm1_3_112 app]# ln -s /data/oraInventory oraInventory [root@azure_earth_dbm1_3_112 app]# chown -R oracle.oinstall /data[root@azure_earth_dbm1_3_112 app]# chown -R oracle.oinstall /oracle[root@azure_earth_dbm1_3_112 app]#[root@ azure_earth_dbm1_3_112 oracle]# mkdir -p /oracle/app/oracle[root@ azure_earth_dbm1_3_112 oracle]# chown -R oracle:oinstall /oracle/app/oracle[root@ azure_earth_dbm1_3_112 oracle]# chmod -R 775 /oracle/app/oracle[root@ azure_earth_dbm1_3_112 oracle]#
[root@hch_test_121_90 oracle]# bash -x/oracle/app/oraInventory11.2.0.4/orainstRoot.sh[root@hch_test_121_90 oracle]# bash -x/oracle/app/oracle/product/11.2.0.4/dbhome_1/root.sh

[root@hch_test_121_90 oracle]# bash -x /oracle/app/oraInventory11.2.0.4/orainstRoot.sh + AWK=/bin/awk + CHMOD=/bin/chmod + CHGRP=/bin/chgrp + CP=/bin/cp + ECHO=/bin/echo + MKDIR=/bin/mkdir ++ /usr/bin/id ++ /bin/awk '-F(' '{print $1}' ++ /bin/awk -F= '{print $2}' + RUID=0 + '[' 0 '!=' 0 ']' + '[' -d /etc ']' + /bin/chmod 755 /etc + '[' -f /oracle/app/oraInventory11.2.0.4/oraInst.loc ']' + /bin/cp /oracle/app/oraInventory11.2.0.4/oraInst.loc /etc/oraInst.loc + /bin/chmod 644 /etc/oraInst.loc + /bin/echo 'Changing permissions of /oracle/app/oraInventory11.2.0.4. Adding read,write permissions for group. Removing read,write,execute permissions for world. ' Changing permissions of /oracle/app/oraInventory11.2.0.4. Adding read,write permissions for group. Removing read,write,execute permissions for world. + /bin/chmod -R g+rw,o-rwx /oracle/app/oraInventory11.2.0.4 + '[' 0 '!=' 0 ']' + /bin/echo 'Changing groupname of /oracle/app/oraInventory11.2.0.4 to oinstall.' Changing groupname of /oracle/app/oraInventory11.2.0.4 to oinstall. + /bin/chgrp -R oinstall /oracle/app/oraInventory11.2.0.4 + '[' 0 '!=' 0 ']' + /bin/echo 'The execution of the script is complete.' The execution of the script is complete. [root@hch_test_121_90 oracle]# [root@hch_test_121_90 oracle]# [root@hch_test_121_90 ~]# sh /oracle/app/oracle/product/11.2.0.4/dbhome_1/root.sh Performing root user operation for Oracle 11g The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /oracle/app/oracle/product/11.2.0.4/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: /oracle/app/oracle/product/11.2.0.4/dbhome_1/bin The contents of "dbhome" have not changed. No need to overwrite. The contents of "oraenv" have not changed. No need to overwrite. The contents of "coraenv" have not changed. No need to overwrite. Entries will be added to the /etc/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. Finished product-specific root actions. [root@hch_test_121_90 ~]# 

6)创建相关用户和组,作为软件安装和支持组的拥有者

7,安装rpms包

之后回到vnc远程的窗口,点击界面的OK,会提示安装Oracle Net Configuration
Assistant: Welcome操作:

创建用户,输入命令:

groupadd  oinstall  
groupadd  dba

(创建用户和组)

创建Oracle用户和密码,输入命令:(赋予权限)

useradd -d /home/oracle  -g  oinstall -G  dba  -m  oracle

passwd oracle

然后会让你输入密码,密码任意输入2次,但必须保持一致,回车确认

Rpm包安装:rpm -ivh *–force –nodeps

接下来会配置网络,如下113.png、114.png

7)创建数据库软件目录和数据文件存放目录,目录的位置,根据自己的情况来定,注意磁盘空间即可,这里我把其放到oracle用户下,例如:

Rpms安装有时候不一定保证有效,可以再用yum安装:

设置sys密码,如115.png所示

输入命令:

mkdir -p /u01/app/oracle

mkdir -p /opt/oracle

# 采用yum安装,如下:yum install -y binutils*yum install -y compat-libstdc*yum install -y elfutils-libelf*yum install -y gcc*yum install -y glibc*yum install -y ksh*yum install -y libaio*yum install -y libgcc*yum install -y libstdc*yum install -y make*yum install -y sysstat* yum install libXp* -yyum install -y glibc-kernheaders # 检查下lib是否安装齐全:[root@powerlong4 ~]# rpm -q --queryformat %-{name}-%{version}-%{release}-%{arch}"\n" \ compat-libstdc++-33 glibc-kernheaders glibc-headers libaio libgcc glibc-devel xorg-x11-deprecated-libs

看到这里,问题来了,中间没有数据库让你选择去升级,问题在哪里呢,在/etc/oratab没有配置,所以赶紧去配置:

8)更改目录属主为Oracle用户所有,输入命令:

如果缺少,就继续安装缺失的组件包。

[root@hch_test_121_90 ~]# more /etc/oratab # # This file is used by ORACLE utilities. It is created by root.sh # and updated by either Database Configuration Assistant while creating # a database or ASM Configuration Assistant while creating ASM instance. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:: # # The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # powerdes:/hom/oracle/app/oracle/product/11.2.0/dbhome_1:Y [root@hch_test_121_90 ~]# 

chown   –R   oracle:oinstall /u01/app

chown   -R    oracle:oinstall /opt/oracle

chmod  755  -R /u01/app

chmod  755  -R /opt/oracle

8,安装vnc

配置完后,前面的步骤重新来一遍,到此就会有下面的出现的database选择项让我们选择,如116.png、117.png、118.png所示:

二、在oracle用户下执行以下步骤:

vnc安装参考://www.jb51.net/article/110095.htm

接下来,选择升级时区以及备份数据库,如119.png所示:

9)配置oracle用户的环境变量,首先,切换到新创建的oracle用户下