本文共 12321 字,大约阅读时间需要 41 分钟。
操作系统: CentOS Linux release 7.3.1611 (Core)
oracle版本:linux.x64_11gR2
linux.x64_11gR2_database_1of2.ziplinux.x64_11gR2_database_2of2.zipA) 创建用户和组
groupadd oinstall
groupadd dbauseradd -g oinstall -G dba oraclepasswd oracleB) 创建数据库安装目录
mkdir -p /opt/oracle ##$ORACLE_BASE
mkdir -p /opt/oracle/product/112010/db_1 ##$ORACLE_HOMEmkdir /opt/oracle/oradata ##存放数据库目录mkdir /opt/oracle/inventorymkdir /opt/oracle/flash_recovery_areachown -R oracle:oinstall /opt/oraclechmod -R 775 /opt/oracleC) 将oracle使用者加入到sudo群组中
vi /etc/sudoers输入上面的命令后,打开sudoers文件进行编辑,找到root ALL=(ALL) ALL这行,并且在底下再加入以下命令:
oracle ALL=(ALL) ALL1、关闭selinux
vi /etc/selinux/config 修改: SELINUX=disabled2、关闭防火墙
systemctl stop firewalld.service #停止服务|firewallsystemctl disable firewalld.service #禁止firewall开机启动3、修改/etc/hosts文件
vi /etc/hosts10.143.200.188 DATAFS4、修改内核参数
vi /etc/sysctl.conf修改以下内容
kernel.shmall = 2097152kernel.shmmax = 1073741824添加以下内容
fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576#sysctl -p
5、修改用户限制文件
#vi /etc/security/limits.conf
行末添加以下内容oracle soft nproc 2047
oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 102406、关联设置
vi /etc/pam.d/login行末添加以下内容:session required /lib64/security/pam_limits.sosession required pam_limits.so7、修改/etc/profile
#vi /etc/profile添加以下内容:if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifisource /etc/profile
8、Oralce用户修改用户环境变量
#vi /home/oracle/.bash_profile
在最底下加入以下内容#For Oracleexport ORACLE_BASE=/opt/oracle;export ORACLE_HOME=/opt/oracle/product/112010/db_1export ORACLE_SID=orclexport PATH=$PATH:$HOME/bin:$ORACLE_HOME/binexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/libexport LC_ALL="en_US"export LANG="en_US"export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fiumask 022fi
source /home/oracle/.bash_profile
查看命令:# env安装依赖包比较多,最好服务器能够访问外网,这样就简单多了,如果真的无法访问外网只能下载对应的rpm包安装了.
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh libaio.i686 glibc.i686 compat-libstdc++-33.i686 libaio-devel.i686 libgcc.i686 libstdc++.i686 unixODBC.i686 unixODBC-devel.i686
rpm包安装:#rpm -ivh * --force --nodeps
1、安装包解压命令(使用oracle用户解压 )
$unzip linux.x64_11gR2_database_1of2.zip
$unzip linux.x64_11gR2_database_2of2.zip修改目录所属用户chown -R oracle:oinstall database解压完成后会生成database目录,解压后的文件中database/response下有有db_install.rsp、dbca.rsp和netca.rsp三个应答文件,分别数据库安装文件、建立数据库实例和监听配置安装文件,在下面的步骤中会用到这3个文件.
2、编辑数据库安装文件db_install.rsp
vi db_install.rsp20 oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_029 oracle.install.option=INSTALL_DB_SWONLY #安装类型37 ORACLE_HOSTNAME=DATAFS #主机名称42 UNIX_GROUP_NAME=oinstall #安装组47 INVENTORY_LOCATION=/opt/oracle/inventory #INVENTORY目录78 SELECTED_LANGUAGES=en,zh_CN #选择语言83 ORACLE_HOME=/opt/oracle/product/112010/db_1 #oracle_home88 ORACLE_BASE=/opt/oracle #oracle_base99 oracle.install.db.InstallEdition=EE ##oracle版本108 oracle.install.db.isCustomInstall=true142 oracle.install.db.DBA_GROUP=dba #dba用户组147 oracle.install.db.OPER_GROUP=dba #oper用户组160 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #数据库类型165 oracle.install.db.config.starterdb.globalDBName=orcl #globalDBName170 oracle.install.db.config.starterdb.SID=orcl #SID200 oracle.install.db.config.starterdb.memoryLimit=800 #自动管理内存的最小内存(M)233 oracle.install.db.config.starterdb.password.ALL=oracle #设定所有数据库用户使用同一个密码385 DECLINE_SECURITY_UPDATES=true #设置安全更新3、安装数据库软件(使用oracle用户)
#su - oracle进入刚才的database目录./runInstaller -silent -responseFile /ghca/database/response/db_install.rsp -ignorePrereqStarting Oracle Universal Installer...Checking Temp space: must be greater than 120 MB. Actual 13773 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB PassedPreparing to launch Oracle Universal Installer from /tmp/OraInstall2018-09-20_09-16-02PM. Please wait ...接下来就是等待(有点长,不要着急!!!),快的话10分钟左右,慢一点可能需要30分钟左右,要看服务器配置。
安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
可以在以下位置找到本次安装会话的日志。安装失败会打印一下信息[FATAL] [INS-32076] English cannot be removed from the selected languages list.CAUSE: An attempt was made to remove English from the selected languages list.ACTION: Select English as one of the selected product languages.A log of this session is currently saved as: /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.查看log日志信息:
cat /tmp/OraInstall2018-09-20_09-16-02PM/installActions2018-09-20_09-16-02PM.log. Oracle正常安装日志信息:
[oracle@DATAFS database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.CAUSE: The Central Inventory is located in the Oracle base.ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.CAUSE: The Central Inventory is located in the Oracle base.ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.You can find the log of this install session at:/opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.logtail -f /opt/oracle/inventory/logs/installActions2018-09-20_09-47-28PM.log
安装成功的日志如下:
The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root scripts to run/opt/oracle/inventory/orainstRoot.sh
/opt/oracle/product/112010/db_1/root.shTo execute the configuration scripts:4、 安装后操作,按照要求执行脚本
打开新的终端,以root身份登录,执行脚本:#/opt/oracle/inventory/orainstRoot.sh
#/opt/oracle/product/112010/db_1/root.sh[root@DATAFS db_1]# /opt/oracle/inventory/orainstRoot.sh
Changing permissions of /opt/oracle/inventory.Adding read,write permissions for group.Removing read,write,execute permissions for world.Changing groupname of /opt/oracle/inventory to oinstall.
The execution of the script is complete.[root@DATAFS db_1]# /opt/oracle/product/112010/db_1/root.shCheck /opt/oracle/product/112010/db_1/install/root_DATAFS_2018-09-20_22-36-50.log for the output of root script完成后,返回原来的终端按下回车键,等待程序安装完成.
执行命令 : netca /silent /responseFile /ghca/database/response/netca.rsp ###----此处必须写绝对路径
[oracle@DATAFS response]$ netca /silent /responseFile /ghca/database/response/netca.rspParsing command line arguments:
Parameter "silent" = trueParameter "responsefile" = /ghca/database/response/netca.rspDone parsing command line arguments.Oracle Net Services Configuration:Configuring Listener:LISTENERListener configuration complete.Oracle Net Listener Startup:Running Listener Control: /opt/oracle/product/112010/db_1/bin/lsnrctl start LISTENERListener Control complete.Listener started successfully.Profile configuration complete.Oracle Net Services configuration successful. The exit code is 0查看端口是否占用:
[root@DATAFS ~]# ss -tnl|grep 1521LISTEN 0 128 :::1521 :::* [root@DATAFS ~]#查看监听状态:
[oracle@DATAFS response]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-SEP-2018 12:22:08
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DATAFS)(PORT=1521)))
STATUS of the LISTENERAlias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date 21-SEP-2018 12:20:29Uptime 0 days 0 hr. 1 min. 41 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /opt/oracle/product/112010/db_1/network/admin/listener.oraListener Log File /opt/oracle/diag/tnslsnr/DATAFS/listener/alert/log.xmlListening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DATAFS)(PORT=1521)))The listener supports no servicesThe command completed successfully1 修改/ghca/database/response/dbca.rsp响应文件中的重要参数
本次安装过程中设置了下列参数:(注意下面参数视情况而定,不要照抄,原文件都有说明的)
RESPONSEFILE_VERSION ="11.2.0" #不能更改OPERATION_TYPE ="createDatabase"
GDBNAME ="orcl" #数据库的名字
SID ="ORCL" ##对应的实例名字
TEMPLATENAME ="General_Purpose.dbc" ##建库用的模板文件
SYSPASSWORD ="oracle" ##SYS管理员密码
SYSTEMPASSWORD ="oracle" ##SYSTEM管理员密码
SYSMANPASSWORD= "oracle"
DBSNMPPASSWORD= "oracle"
DATAFILEDESTINATION =/opt/oracle/oradata ##数据文件存放目录
RECOVERYAREADESTINATION=/opt/oracle/flash_recovery_area ##恢复数据存放目录
CHARACTERSET ="ZHS16GBK" ##字符集,重要!!!建库后一般不能更改,所以建库前要确定清楚。
TOTALMEMORY ="1638" #1638MB,物理内存2G*80%。
2、 开始安装数据库实例
dbca -silent -responseFile /ghca/database/response/response/dbca.rsp[oracle@DATAFS response]$ dbca -silent -responseFile /ghca/database/response/dbca.rsp Copying database files1% complete3% complete11% complete18% complete26% complete37% completeCreating and starting Oracle instance40% complete45% complete50% complete55% complete56% complete60% complete62% completeCompleting Database Creation66% complete70% complete73% complete85% complete96% complete100% completeLook at the log file "/opt/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.到此数据库实例安装就完成了.
配置监听时,没有使用netca.rsp相应的文件的绝对路径
[oracle@DATAFS response]$ netca /silent /responseFile netca.rspParsing command line arguments:
Parameter "silent" = trueParameter "responsefile" = ./netca.rspOracle Net Configuration Assistant could not find the Response File at the given location.Oracle Net Services configuration failed. The exit code is 1登录数据库 sqlplus / as sysdba
启动:SQL> startup停止:SQL> shutdown immediate;1、管理员用户创建表空间保存数据
create tablespace IDR_TS datafile '/opt/oracle/oradata/orcl/IDR_TS01.dbf' size 1024m;2、创建用户数据操作用户
create user operator identified by "123456"
default tablespace operatortemporary tablespace TEMPprofile DEFAULT quota unlimited on IDR_TS;以下权限是可选的,根据自己需要给用户赋权
grant connect to operator;grant dba to operator;grant javasyspriv to operator;-- Grant/Revoke system privileges grant create any sequence to operator;grant create any table to operator;grant create any view to operator;grant unlimited tablespace to operator;-- Grant/Revoke role privileges grant connect to operator;grant dba to operator;grant exp_full_database to operator;grant imp_full_database to operator;grant javasyspriv to operator;grant resource to operator;-- Grant/Revoke system privileges grant create any sequence to operator;grant alter any table to operator;grant alter any trigger to operator;grant alter session to operator;grant alter system to operator;grant alter tablespace to operator;grant alter user to operator;grant analyze any to operator;grant create any procedure to operator;grant create any synonym to operator;grant create any table to operator;grant create any trigger to operator;grant create cluster to operator;grant create database link to operator;grant create procedure to operator;grant create public synonym to operator;grant create role to operator;grant create sequence to operator;grant create session to operator;grant create synonym to operator;grant create table to operator;grant create any view to operator;grant delete any table to operator;grant drop any index to operator;grant drop any synonym to operator;grant drop any table to operator;grant drop any trigger to operator;grant drop public synonym to operator;grant execute any procedure to operator;grant insert any table to operator;grant lock any table to operator;grant select any table to operator;grant unlimited tablespace to operator;grant update any table to operator;到此就可以使用operator登录进行数据操作了.数据库完整的安装就结束了.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< installation is complete >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
转载于:https://blog.51cto.com/chbinmile/2178414