一、查看操作系统
查看系统默认安装的yum
rpm -qa|grep yum
binutils-2.23.52.0.1-12.el7.x86_64
binutils-2.20.51.0.2-5.46.el6.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libcap1-1.10-1.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-4.4.7-18.el6.x86_64
gcc-c++-4.8.2-3.el7.x86_64
gcc-c++-4.4.7-18.el6.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-2.12-1.209.el6.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
glibc-devel-2.12-1.209.el6.x86_64
ksh
ksh-20120801-33.el6.x86_64
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-0.3.107-10.el6.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libaio-devel-0.3.107-10.el6.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libgcc-4.4.7-18.el6.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-4.4.7-18.el6.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libstdc++-devel-4.4.7-18.el6.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXi-1.7.8-1.el6.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
libXtst-1.2.3-1.el6.x86_64
make-3.82-19.el7.x86_64
make-3.81-23.el6.x86_64
sysstat-10.1.5-1.el7.x86_64
sysstat-9.0.4-33.el6.x86_64
unixODBC-2.3.1-6.el7.x86_64 or later
unixODBC-2.2.14-14.el6.x86_64
unixODBC-2.3.1-6.el7.i686 or later
unixODBC-devel-2.3.1-6.el7.x86_64 or later
unixODBC-devel-2.2.14-14.el6.x86_64
unixODBC-devel-2.3.1-6.el7.i686 or later
注:i686和x86_64都需要安装
用yum进行安装
yum -y install binutils
compat-libcap1
compat-libstdc++-33
compat-libstdc++-33*i686
compat-libstdc++-33*.devel
compat-libstdc++-33
compat-libstdc++-33*.devel
gcc
gcc-c++
glibc
glibc*.i686
glibc-devel
glibc-devel*.i686
ksh
libaio
libaio*.i686
libaio-devel
libaio-devel*.devel
libgcc libgcc*.i686
libstdc++
libstdc++*.i686
libstdc++-devel
libstdc++-devel*.devel
libXi libXi*.i686
libXtst
libXtst*.i686
make
sysstat
unixODBC
unixODBC*.i686
unixODBC-devel
unixODBC-devel*.i686
检测31个RPM包是否都被安装
[root@docker ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
binutils-2.23.52.0.1-55.el7.x86_64
compat-libcap1-1.10-7.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.x86_64
compat-libstdc++-33-3.2.3-72.el7.i686
gcc-4.8.5-4.el7.x86_64
gcc-c++-4.8.5-4.el7.x86_64
glibc-2.17-106.el7_2.8.x86_64
glibc-2.17-106.el7_2.8.i686
glibc-devel-2.17-106.el7_2.8.x86_64
glibc-devel-2.17-106.el7_2.8.i686
ksh-20120801-22.el7_1.3.x86_64
libaio-0.3.109-13.el7.x86_64
libaio-0.3.109-13.el7.i686
libaio-devel-0.3.109-13.el7.x86_64
libaio-devel-0.3.109-13.el7.i686
libgcc-4.8.5-4.el7.x86_64
libgcc-4.8.5-4.el7.i686
libstdc++-4.8.5-4.el7.x86_64
libstdc++-4.8.5-4.el7.i686
libstdc++-devel-4.8.5-4.el7.x86_64
libstdc++-devel-4.8.5-4.el7.i686
libXi-1.7.2-2.1.el7.x86_64
libXi-1.7.4-2.el7.i686
libXtst-1.2.2-2.1.el7.x86_64
libXtst-1.2.2-2.1.el7.i686
make-3.82-21.el7.x86_64
sysstat-10.1.5-7.el7.x86_64
unixODBC-2.3.1-11.el7.x86_64
unixODBC-2.3.1-11.el7.i686
unixODBC-devel-2.3.1-11.el7.x86_64
unixODBC-devel-2.3.1-11.el7.i686
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
Passwd oracle
[root@docker ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
[root@docker ~]# vim /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
#
# Use '/sbin/sysctl -a' to list all possible parameters.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
#Disable netfilter on bridges.
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
#net.bridge.bridge-nf-call-arptables = 0
#Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
#Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
#Controls the maximum shared segment size, in bytes
#kernel.shmmax = 68719476736
#Controls the maximum number of shared memory segments, in pages
#kernel.shmall = 4294967296
#sysctl -a | grep range
获取net.ipv4.ip_local_port_range 值的方式sysctl -a | grep range
net.ipv4.ip_local_port_range = 9000 65500
即file-max是设置系统所有进程一共可以打开的文件数量 。同时一些程序可以通过setrlimit调用,设置每个进程的限制。如果得到大量使用完文件句柄的错误信息,是应该增加这个值。 也就是说,这项参数是系统级别的。 echo 6553560 > /proc/sys/fs/file-max 或修改 /etc/sysctl.conf, 加入 fs.file-max = 6553560 重启生效
fs.file-max = 6815744
shmall 是全部允许使用的共享内存大小,shmmax 是单个段允许使用的大小。这两个可以设置为内存的 90%。例如 16G 内存,16*1024*1024*1024*90% = 15461882265,shmall 的大小为 15461882265/4k(getconf PAGESIZE可得到) = 3774873
kernel.shmall = 3538944
kernel.shmmax = 14495514624
#kernel.shmmax = 3779571221
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
表示接收套接字缓冲区大小的缺省值(以字节为单位)
net.core.rmem_default = 262144
表示发送套接字缓冲区大小的缺省值(以字节为单位)
net.core.wmem_default = 262144
表示接收套接字缓冲区大小的最大值(以字节为单位)
net.core.rmem_max = 4194304
表示发送套接字缓冲区大小的最大值(以字节为单位)
net.core.wmem_max = 1048576
指的是 同时可以拥有的的异步IO请求数目。值出现在 /etc/sysctl.conf 文件中,推荐值是:1048576 其实它等于 1024*1024 也就是 1024K 个
fs.aio-max-nr = 1048576
/sbin/sysctl –p /etc/sysctl.conf
vim /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#
#
#Where:
#
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
oracle soft nproc 12000
oracle hard nproc 16384
oracle soft nofile 12000
oracle hard nofile 65536
#在末尾添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
#%PAM-1.0
auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include system-auth
session required pam_limits.so
-session optional pam_ck_connector.so
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi
HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
unset i
unset -f pathmunge
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 /home/oracle/app/oracle/product/11.2.0/dbhome_1
chown –R /home/oracle
chmod –R 775 /home/oracle
[oracle@docker ~]$ vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin
export PATH
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_HOME
ORACLE_HOME_LISTNER=$ORACLE_HOME/network/admin
export ORACLE_HOME_LISTNER
source ~/.bash_profile
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
安装包存放目录:/opt/install_oralce
注:两个文件必须在相同的目录下解压
mkdir etc(在/home/oracle目录下执行)
cp /opt/install_oralce/database/response/* /home/oracle/etc/
ls etc
dbca.rsp db_install.rsp netca.rsp
su - root
chmod 700 /home/oracle/etc/*.rsp
su - oracle
修改安装Oracle软件的响应文件/home/oracle/etc/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY // 安装类型
ORACLE_HOSTNAME=ora61 // 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall // 安装组
INVENTORY_LOCATION= /home/oracle/oraInventory //INVENTORY目录(不填就是默认值)
SELECTED_LANGUAGES= en,zh_CN // 选择语言
ORACLE_HOME= /home/oracle/app/oracle/product/11.2.0/dbhome_1 //oracle_home
ORACLE_BASE= /home/oracle/app/oracle //oracle_base
oracle.install.db.InstallEdition=EE // oracle版本
oracle.install.db.isCustomInstall=false //自定义安装,否,使用默认组件
oracle.install.db.DBA_GROUP=dba / / dba用户组
oracle.install.db.OPER_GROUP=oinstall // oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl //globalDBName
oracle.install.db.config.starterdb.SID=orcl //SID(这儿确定了之后最好不要改动,会很麻烦)
oracle.install.db.config.starterdb.memoryLimit=81920 //自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //(手动写了false)
DECLINE_SECURITY_UPDATES=true //设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)
[oracle@docker database]$ ./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp
tail -f /u01/app/oraInventory/logs/installActions2016-08-31_06-56-29PM.log
/u01/app/oracle/product/11.2.0/db_1
在输出的文字里提供日志在哪儿
出现类似如下提示表示安装完成:
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
su - root
/home/oracle/app/oracle/oraInventory /orainstRoot.sh
/home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/bin
#export PATH
PATH=$PATH:$HOME/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin
export PATH
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
export ORACLE_HOME
export ORACLE_SID=orcl
ORACLE_HOME_LISTNER=$ORACLE_HOME/network/admin
export ORACLE_HOME_LISTNER
export ORACLE_BASE=/home/oracle/app/oracle
export ROACLE_PID=orcl
export LD_LIBRARY_PATH=$/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib
export PATH=$PATH:$ORACLE_HOME/bin
export LANG="en_US.UTF-8"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
#TNS_ADMIN is: null
#export $TNS_ADMIN=$ORACLE_HOME/network/admin
umask 022
export ORACLE_BASE=/home/oracle/app/oracle
[oracle@docker ~]$ netca /silent /responsefile /home/oracle/etc/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@docker ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2016 11:23:31
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=docker)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 01-SEP-2016 11:23:31
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=docker)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@docker ~]$ dbca -silent -responseFile etc/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
[oracle@docker ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/orcl11g.
Database Information:
Global Database Name:orcl11g.us.oracle.com
System Identifier(SID):dbsrv2
至此完成数据库实例的创建。