赞
踩
一、准备工作:
1、CentOS7自行安装(64位),网络自行配置;
2、下载Oracle安装包:linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip ;
3、HostName修改:oracle
hostnamectl set-hostname oracle
二、安装过程
1、配置yum源
- cd /etc
- mv yum.repos.d yum.repos.d.bak
- mkdir yum.repos.d
- wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- yum clean all
- yum makecache
2、安装依赖包:
- yum -y install binutils \
- compat-libstdc++-33 \
- elfutils-libelf \
- elfutils-libelf-devel \
- expat \
- gcc \
- gcc-c++ \
- glibc \
- glibc-common \
- glibc-devel \
- glibc-headers \
- libaio \
- libaio-devel \
- libgcc \
- libstdc++ \
- libstdc++-devel \
- make \
- pdksh \
- sysstat \
- unixODBC \
- unixODBC-devel
3、检查依赖是否安装完整:
- rpm -q \
- binutils \
- compat-libstdc++-33 \
- elfutils-libelf \
- elfutils-libelf-devel \
- expat \
- gcc \
- gcc-c++ \
- glibc \
- glibc-common \
- glibc-devel \
- glibc-headers \
- libaio \
- libaio-devel \
- libgcc \
- libstdc++ \
- libstdc++-devel \
- make \
- pdksh \
- sysstat \
- unixODBC \
- unixODBC-devel | grep "not installed"
4、添加oracle用户组和用户:
- groupadd oinstall
- groupadd dba
- groupadd asmadmin
- groupadd asmdba
- useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
5、添加完成后,查看oracle用户:
id oracle
6、初始化oracle用户的密码:
passwd oracle
以上部分操作截图:
- vi /etc/hosts
- 192.168.199.110 oracle
- # 测试hostname
- ping -c 3 oracle
- # kernel.shmmax 参数设置为物理内存的一半
- vi /etc/sysctl.conf
- ## 内容如下:
- fs.aio-max-nr=1048576
- fs.file-max=6815744
- kernel.shmall=2097152
- kernel.shmmni=4096
- kernel.shmmax = 536870912
- kernel.sem=250 32000 100 128
- net.ipv4.ip_local_port_range=9000 65500
- net.core.rmem_default=262144
- net.core.rmem_max=4194304
- net.core.wmem_default=262144
- net.core.wmem_max=1048586
使参数生效:
sysctl -p
- vi /etc/security/limits.conf
-
- #在末尾添加
- oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 1024
- oracle hard nofile 65536
- oracle soft stack 10240
- oracle hard stack 10240
-
- vi /etc/pam.d/login
-
- session required /lib64/security/pam_limits.so
- session required pam_limits.so
-
- vi /etc/profile
-
- if [ $USER = "oracle" ]; then
- if [ $SHELL = "/bin/ksh" ]; then
- ulimit -p 16384
- ulimit -n 65536
- else
- ulimit -u 16384 -n 65536
- fi
- fi
-
-
- --------------------------------------------------------
- 使之生效:
- source /etc/profile
- mkdir -p /db/app/oracle/product/11.2.0
- mkdir /db/app/oracle/oradata
- mkdir /db/app/oracle/oraInventory
- mkdir /db/app/oracle/fast_recovery_area
- chown -R oracle:oinstall /db/app/oracle
- chmod -R 775 /db/app/oracle
- inventory_loc=/db/app/oracle/oraInventory
- inst_group=oinstall
- chown oracle:oinstall /etc/oraInst.loc
- chmod 664 /etc/oraInst.loc
- su - oracle ## oracle用户登陆
-
- vi .bash_profile
-
- export ORACLE_HOSTNAME=oracle
- export ORACLE_BASE=/db/app/oracle
- export ORACLE_SID=ORCL
- export LC_ALL="en_US"
- export LANG="en_US"
- export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
- export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
-
- ## 以上配置完成后,建议重启系统 或分别执行以下命令:
- source /home/oracle/.bash_profile
- env
- # 上传linux.x64_11gR2_database_*of2.zip文件至/db/目录;
- cd /db/
- ls
- unzip linux.x64_11gR2_database_1of2.zip -d /db
- unzip linux.x64_11gR2_database_2of2.zip -d /db
-
- # 解压完成后:
- # 登录Root,复制授权
- su - root
- mkdir /home/oracle/etc/
- cp /db/database/response/* /home/oracle/etc/
- chmod 777 /home/oracle/etc/*.rsp
-
- # 登录oracle用户:
- su – oracle
- vi /home/oracle/etc/db_install.rsp
- ## 信息如下:
- oracle.install.option=INSTALL_DB_SWONLY
- UNIX_GROUP_NAME=oinstall
- INVENTORY_LOCATION=/db/app/oracle/oraInventory
- SELECTED_LANGUAGES=en,zh_CN
- ORACLE_HOSTNAME=oracle
- ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
- ORACLE_BASE=/db/app/oracle
- oracle.install.db.InstallEdition=EE
- oracle.install.db.isCustomInstall=true
- oracle.install.db.DBA_GROUP=dba
- oracle.install.db.OPER_GROUP=oinstall
- oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
- oracle.install.db.config.starterdb.globalDBName=orcl
- oracle.install.db.config.starterdb.SID=orcl
- oracle.install.db.config.starterdb.memoryLimit=512
- oracle.install.db.config.starterdb.password.ALL=oracle
- DECLINE_SECURITY_UPDATES=true
开始安装:
- su - oracle
-
- ./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp -ignorePrereq
-
- ## 安装期间可以使用tail命令监看oracle的安装日志
-
- tail -f /db/app/oracle/oraInventory/logs/installActions2019-05-25_10-38-29AM.log
安装完成,提示Successfully Setup Software.
使用root用户执行脚本:
- su - root
- /db/app/oracle/product/11.2.0/db_1/root.sh
增加或修改oracle的环境变量:
- su - oracle
-
- vi ~/.bash_profile
-
- export ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
- export TNS_ADMIN=$ORACLE_HOME/network/admin
- export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
- export PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
- export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
- export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
- export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
- export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
- export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
- export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
- export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
- export ORACLE_OWNER=oracle
- export SPFILE_PATH=$ORACLE_HOME/dbs
- export ORA_NLS10=$ORACLE_HOME/nls/data
-
- #生效
- source ~/.bash_profile
配置监听程序:
- [oracle@oracle bin]$ pwd
- /db/app/oracle/product/11.2.0/db_1/bin
- [oracle@oracle bin]$ ./netca /silent /responseFile /home/oracle/etc/netca.rsp
启动监控程序:
- [oracle@oracle bin]$ pwd
- /db/app/oracle/product/11.2.0/db_1/bin
- # 启动监听
- [oracle@oracle bin]$ lsnrctl start
- # 查看监听状态
- [oracle@oracle bin]$ lsnrctl start
-
- LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-MAY-2019 00:13:21
-
- Copyright (c) 1991, 2009, Oracle. All rights reserved.
-
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
- Start Date 25-MAY-2019 00:05:55
- Uptime 0 days 0 hr. 7 min. 32 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /db/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
- Listener Log File /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1522)))
- The listener supports no services
- The command completed successfully
- [oracle@oracle bin]$
静默dbca建库
编辑应答文件:
- [oracle@oracle ~]$ vi /etc/dbca.rsp
- GDBNAME="orcl.oracle"
- SID="orcl"
- SYSPASSWORD = "oracle"
- SYSTEMPASSWORD = "oracle"
- CHARACTERSET="AL32UTF8"
- NATIONALCHARACTERSET="UTF8"
- # 执行:
- $ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
建库:
- [oracle@oracle bin]$ pwd
- /db/app/oracle/product/11.2.0/db_1/bin
- [oracle@oracle bin]$ dbca -silent -responseFile etc/dbca.rsp
至此完成数据库实例的创建。
删除实例:
[oracle@oracle ~]$ dbca -silent -deleteDatabase -sourcedb orcl
设置Oracle开机启动
- 1.su - oracle
- vim $ORACLE_HOME/bin/dbstart
- 编辑dbstart,将ORACLE_HOME_LISTER=$1修改成ORACLE_HOME_LISTER=$ORACLE_HOME
-
- vim /etc/oratab
- 将“orcl:/db/app/oracle/product/11.2.0/db_1/:N”,
-
- 改为“orcl:/db/app/oracle/product/11.2.0/db_1/:Y"
- 2.使用root编辑/etc/rc.d/rc.local启动文件,添加数据库启动脚本dbstart
- su oracle -lc "/db/app/oracle/product/11.2.0/db_1/bin/dbstart"
- su oracle -lc "/db/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
- 3.为文件/etc/rc.d/rc.local添加执行权限:
- chmod +x /etc/rc.d/rc.local
- 4.重启主机,查看数据库和监听是自启动
- 重启主机 : reboot
- 查看监听(oracle用户):lsnrctl status
登录Oracle
- [oracle@oracle bin]$ pwd
- /db/app/oracle/product/11.2.0/db_1/bin
- [oracle@oracle bin]$ ./sqlplus /nolog
- # 进入系统管理用户
- SQL> conn / as sysdba
- Connected to an idle instance.
- # 启动oracle实例
- SQL> startup;
(一)、错误信息:ORA-12162: TNS:net service name is incorrectly specified
- [oracle@oracle bin]$ ./sqlplus / as sysdba
-
- SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:20:45 2019
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
-
- ERROR:
- ORA-12162: TNS:net service name is incorrectly specified
解决方式:
1、系统当前的ORACLE_HOME和ORACLE_SID环境变量:
- [oracle@oracle bin]$ echo $ORACLE_HOME
- /db/app/oracle/product/11.2.0/db_1
- [oracle@oracle bin]$ echo $ORACLE_SID
-
-
- [oracle@oracle bin]$
此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。
2、给出ORACLE_SID,重新尝试登录:
- # 方法(一):
- [oracle@oracle bin]$ export ORACLE_SID=ora11g
- [oracle@oracle bin]$ echo $ORACLE_SID
- ora11g
-
- # 方法(二):
- [oracle@oracle bin]$ vi ~/.bash_profile
- export ORACLE_SID=ora11g
- # 保存退出,使其生效
- [oracle@oracle bin]$ source ~/.bash_profile
-
- # 登录oracle
- [oracle@oracle bin]$ sqlplus /nolog
-
- SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:37:35 2019
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
-
- SQL> conn / as sysdba
- Connected to an idle instance.
( 二)、错误信息:LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'
- SQL> startup
- ORA-01078: failure in processing system parameters
- LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'
解决方法:
1、查看文件:
- cd /db/app/oracle/product/11.2.0/db_1/dbs
- ls
- # 查看initora11g.ora不存在;
2、复制文件及改名
- [root@oracle admin]# cd /db/app/oracle/admin/orcl/pfile/
- [root@oracle pfile]# ls
- init.ora.4242019231824
- [root@oracle pfile]# cp ./init.ora.4242019231824 /db/app/oracle/product/11.2.0/db_1/dbs/
- [root@oracle pfile]# cd /db/app/oracle/product/11.2.0/db_1/dbs/
- [root@oracle dbs]# ls
- hc_ora11g.dat init.ora init.ora.4242019231824 lkORCL orapworcl
- [root@oracle dbs]# mv ./init.ora.4242019231824 initora11g.ora
- [root@oracle dbs]# chmod -R 777 /db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora
3、登录验证startup命令
- [oracle@oracle bin]$ sqlplus "/as sysdba"
-
- SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 01:33:36 2019
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
-
- Connected to an idle instance.
-
- SQL> startup
- ORACLE instance started.
-
- Total System Global Area 1586708480 bytes
- Fixed Size 2213736 bytes
- Variable Size 922749080 bytes
- Database Buffers 654311424 bytes
- Redo Buffers 7434240 bytes
- ORA-00205: error in identifying control file, check alert log for more info
-
- SQL>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。