1. 程式人生 > >Oracle 軟體及靜默安裝資料庫

Oracle 軟體及靜默安裝資料庫

/usr/sbin/groupadd -g 501 oinstall && /usr/sbin/groupadd -g 502 dba && /usr/sbin/groupadd -g  503 oper && /usr/sbin/useradd -g oinstall -G dba,oper -d /home/oracle/ -s /bin/bash oracle mkdir -p /data/ora11g/product/11.2.0.4/db_1 && chown -R oracle:oinstall /data/ora11g && chmod -R 775 /data/ora11g && chown -R oracle:oinstall /home/oracle

2.1依賴包檢查安裝
yum –y install binutils compat-libcap1 compat-libstdc++ gcc  gcc-c++ glibc  glibc-devel ksh libgcc libstdc++ libstdc++-devel sysstat libaio libaio-devel elfutils-libelf-devel unixODBC unixoODBC-devel ntpdate lvm2 rsync net-tools unzip
此處要認真確認所需包都已安裝,不然後面可能會報因依賴包缺少的WARNING。

2.2 修改系統引數
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

vi /etc/pam.d/login  最後加上:
#ORACLE SETTING
session required pam_limits.so

vi /etc/sysctl.conf
#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 2073116672
kernel.shmmni = 4096
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

2.3 建立使用者及許可權目錄

/usr/sbin/groupadd –g 501 oinstall && /usr/sbin/groupadd –g 502 dba && /usr/sbin/groupadd –g 503 oper &&/usr/sbin/useradd –g oinstall –G dba,oper –d /home/oracle –s /bin/bash oracle


mkdir –p /data/ora11g/product/11.2.0.4/db_1 && chown –R oracle:oinstall /data/ora11g && chmod –R 775 /data/ora11g && mkdir /home/oracle && chown –R oracle:oinstall /home/oracle
mkdir –p /data/ora11g/oraInventory && chown –R oracle:oinstall /data/ora11g/oraInventory

2.4 配置ORACLE家目錄PROFILE
su – oracle
vi ~/.bash_profile

export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/data/ora11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1
export ORACLE_SID=test
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$ORACLE_HOME/bin:/usr/local/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG="simplified chinese"_china.utf8
2.5 同步時鐘
crontab –l
0 0 * * * /usr/sbin/ntpdate 192.168.1.1

三、 安裝ORACLE 軟體
cd /data/test/software
unzip p13390677_112040_Linux-x86-64_*.zip
關閉防火牆
Systemctl stop firewall
Systemctl disable firewall

使用靜默方式安裝oracle軟體。在response目錄下,有3個標準模板。
dbca.rsp ,  db_install.rsp   netca.rsp
cp response/db_install.rsp  db_install.rsp.bak

vi db_install.rsp


oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=192.168.1.3
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/ora11g/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/data/ora11g/product/11.2.0.4/db_1
ORACLE_BASE=/data/ora11g
oracle.install.db.InstallEdition=EE
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=test
oracle.install.db.config.starterdb.SID=test
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=1536
oracle.install.db.config.starterdb.password.SYS=oracle
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=FILE_SYSTEM_STORAGE
SECURITY_UPDATES_VIA_MYORACLESUPPORT=true

DECLINE_SECURITY_UPDATES=true

最後一條一定要寫true.
開始靜默安裝oralce軟體:
./runInstaller –silent –force –ignoreSysPrereqs –ignorePrereq –responseFile /home/oracle/db_install.rsp

./runInstaller -silent -force -ignoreSysPrereqs -ignorePrereq -responseFile /home/oracle/db_install.rsp

結束之後需要執行2條指令碼,以root身份:
/data/ora11g/oraInventory/orainstRoot.sh
/data/ora11g/product/11.2.0.4/db_1/root.sh


四、 建立資料庫
同樣編輯dbca.rsp 模板:
cd /data/test/software/database/response/
cp dbca.rsp  dbca.rsp.bak

vi dbaca.rsp

RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
GDBNAME = "test"
SID = "test"
SYSPASSWORD = “oracle”
SYSTEMPASSWORD = “oracle”
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL16UTF16"

$ORACLE_HOME/bin/dbca –silent –responseFile /data/test/software/database/dbca.rsp


五、 建立並修改監聽
同樣編輯netca.rsp 模板:
cd /data/test/software/database/response/
cp netca.rsp  netca.rsp.bak

$ORACLE_HOME/bin/netca –silent –responseFile /data/test/software/database/response/netca.rsp


手動修改監聽配置檔案listener.ora 與tnsnames.ora:

cd /data/ora11g/product/11.2.0.4/db_1/network/admin
vi
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.3)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /data/ora11g
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test)
      (ORACLE_HOME = /data/ora11g/product/11.2.0.4/db_1)
      (SID_NAME = test)
    )
  )


Vi tnsnames.ora

test =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.3)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
 )

設定監聽不產生XML日誌

1)To avoid generating or reduce the xml files, please set the following parameter:
In sqlnet.ora

DIAG_ADR_ENABLED=off

In listener.ora

DIAG_ADR_ENABLED_=off

Where the should  be replaced with the actual name of the configured listener(s) in the listener.ora file.  
For example, if the listener name is 'LISTENER_SCAN1', the parameter should be:
DIAG_ADR_ENABLED_LISTENER_SCAN1=OFF
-Reload or restart the TNS Listener for the parameter change to take effect.

設定這兩個引數不會影響到listener.log日誌的產生。
相比直接關閉Listener log的方式,還保留原有日誌的產生.