一、背景
最近公司有个项目需要一个oracle测试实例来测试一下数据异构迁移到mysql,然后我就用静默安装试了一下。花了两个小时终于搞完了,感觉还是用图形化安装更好一点。下面列的是我的步骤,但是并没有详细的说明每一步的原理(以后有时间再补充吧)。
安装前:
说明:
内存需大于1G,swap适当调整(和内存差不多也行),
硬盘空间要满足所需软件的大小,要求/tmp 分区不少于 400M ,安装目录大于4G
Linux下安装oracle对内核参数的要求说明:
kernel.shmall为物理内存除以pagesize
kernel.shmmax为物理内存的一半
fs.file-max为512乘以processes(如128个process,则为65536)
环境:
centos 6.5
oracle 11g 11.2.0.1.0
1.yum 安装所需要的依赖包
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel ksh
2.创建用户和组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle #密码暂定为oracle
3.
vim /etc/hosts
vim /etc/selinux/config
setenforce 0
4.调整内核参数
echo "net.core.rmem_default = 262144">>/etc/sysctl.conf
echo "net.core.rmem_max = 16777216">>/etc/sysctl.conf
echo "net.core.wmem_default = 262144">>/etc/sysctl.conf
echo "net.core.wmem_max = 16777216">>/etc/sysctl.conf
echo "fs.file-max=6815744">>/etc/sysctl.conf
echo "fs.aio-max-nr = 1048576">>/etc/sysctl.conf
echo "net.core.netdev_max_backlog=10000">>/etc/sysctl.conf
echo "net.core.somaxconn=4096">>/etc/sysctl.conf
echo "net.ipv4.ip_local_port_range=9000 65500">>/etc/sysctl.conf
echo "net.ipv4.tcp_fin_timeout=5">>/etc/sysctl.conf
echo "net.ipv4.tcp_keepalive_intvl=20">>/etc/sysctl.conf
echo "net.ipv4.tcp_keepalive_probes=3">>/etc/sysctl.conf
echo "net.ipv4.tcp_keepalive_time=60">>/etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog=4096">>/etc/sysctl.conf
echo "net.ipv4.tcp_mem=8388608 12582912 16777216">>/etc/sysctl.conf
echo "net.ipv4.tcp_rmem=8192 87380 16777216">>/etc/sysctl.conf
echo "net.ipv4.tcp_synack_retries=2">>/etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1">>/etc/sysctl.conf
echo "net.ipv4.tcp_tw_recycle=0">>/etc/sysctl.conf
echo "net.ipv4.tcp_tw_reuse=1">>/etc/sysctl.conf
echo "net.ipv4.tcp_wmem=8192 65536 16777216">>/etc/sysctl.conf
echo "net.netfilter.nf_conntrack_max=1200000">>/etc/sysctl.conf
echo "net.nf_conntrack_max=1200000">>/etc/sysctl.conf
echo "vm.extra_free_kbytes=512000">>/etc/sysctl.conf
echo "vm.min_free_kbytes=2097152">>/etc/sysctl.conf
echo "vm.mmap_min_addr=4096">>/etc/sysctl.conf
echo "vm.swappiness=1">>/etc/sysctl.conf
echo "net.ipv4.tcp_max_tw_buckets = 15000">>/etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128">>/etc/sysctl.conf
sysctl -p
5.设置limits
vim /etc/security/limits.d/90-nproc.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 2047
oracle hard nofile 65536
oracle soft stack 10240
6.解压
(解压到了/tmp/下了,解压后的文件为 /tmp/database)
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
7.
mkdir -p /oracle/product/11.2.0.1/db_1
mkdir -p /oradata
mkdir -p /oracle/inventory
mkdir -p /oracle/fast_recovery_area
chown -R oracle:oinstall /oracle
chmod -R 755 /oracle
语句的作用依次为:前面创建的目录主要作用为Oracle家目录、数据文件存放位置,安装日志存放位置,快速恢复区
修改属组,修改权限
8.
su - oracle
vim .bash_profile
ORACLE_BASE=/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.1/db_1
ORACLE_SID=orclwx
ORACLE_TERM=xterm
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_TERM PATH
source .bash_profile
修改/etc/profile文件
[root@oracle ~]# vim /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
[root@oracle4 ~]# source /etc/profile
9.
vim /tmp/database/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/inventory
SELECTED_LANGUAGES=en,zh_TW,zh_CN
ORACLE_HOME=/oracle/product/11.2.0.1/db_1
ORACLE_BASE=/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orclwx
oracle.install.db.config.starterdb.SID=orclwx
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
10.
vim /etc/pam.d/login
64bit server添加以下内容:
session required /lib64/security/pam_limits.so
session required pam_limits.so
11.安装oracle软件(最重要的一步)
su - oracle
cd database
./runInstaller -silent -force -responseFile /tmp/database/response/db_install.rsp
-ignorePrereq
忽略运行先决条件检查。
对该步进行解释:
1.先不加参数 -ignorePrereq 执行runInstaller。如果报错的话,查看日志(至于查看哪个日志?界面会显示出来),然后对该日志文件执行: cat /tmp/OraInstall2019-03-26_07-28-28PM/installActions2019-03-26_07-28-28PM.log |grep -C3 -i Error . 看一下报错,将内核参数报错解决(除缺i386包的错误,其他的错误都解决)。
2.然后再执行,如果只报i386的错了,就可以加上面这个参数忽略他
12.
su - root
bash /oracle/inventory/orainstRoot.sh
bash /oracle/product/11.2.0.1/db_1/root.sh
13.配置监听,网络
su - oracle
/oracle/product/11.2.0.1/db_1/bin/netca /silent /responseFile /tmp/database/response/netca.rsp
14.静默安装数据库
su - oracle
vim dbca.rsp
GDBNAME="orcl.java-linux-test" //78 行 全局数据库的名字=SID+主机域名(这里orcl是oracle的数据库名,后面的主机域名不需要更改)
SID="orcl" //170行 SID
NATIONALCHARACTERSET="UTF8" //
$ORACLE_HOME/bin/dbca -silent -responseFile /tmp/database/response/dbca.rsp -systemPassword oracle
15.登录
su - oracle
sqlplus / as sysdba
16.安装rlwrap
yum install -y rlwrap-0.42-1.el6.x86_64.rpm
17.登录
su - oracle
rlwrap sqlplus / as sysdba
18.增加help
SQL> startup;
SQL> @ ?/\sqlplus/\admin/\help/\hlpbld.sql ?/\sqlplus/\admin/\help/\helpus.sql
报错:
1.Exception in thread "main" java.lang.NoClassDefFoundError
unset DISPLAY
2.[SEVERE] - 未指定电子邮件地址
Response File中必须指定DECLINE_SECURITY_UPDATES=true
3.
libaio-0.3.105 (i386)
glibc-2.3.4-2.41 (i686)
compat-libstdc++-33-3.2.3 (i386)
libaio-devel-0.3.105 (i386)
libgcc-3.4.6 (i386)
libstdc++-3.4.6 (i386)
unixODBC-2.2.11 (i386)
unixODBC-devel-2.2.11 (i386)
pdksh-5.2.14 以上加参数忽略