修改用戶的 SHELL
限制:git
vim /etc/security/limits.conf
添加以下內容:github
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
修改 /etc/pam.d/login
文件sql
vim /etc/pam.d/login
添加以下內容:數據庫
session required /lib/security/pam_limits.so session required pam_limits.so
修改 Linux
內核配置vim
vim /etc/sysctl.conf
添加以下內容:centos
fs.file-max = 6815744 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576
source /etc/sysctl.conf # 使修改當即生效,我當時鍵入以下命令時報沒有找到命令,因此重啓了centos
修改 /etc/profile
文件bash
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
建立用戶和組session
# 建立用戶組 groupadd oinstall groupadd dba # 建立用戶並分配用戶組 # 我安裝時存在 oracle 用戶不在 oinstall 的問題,最好在 /etc/group 中再設置一遍 useradd -g oinstall -g dba -m oracle passwd oracle
建立 Oracle 目錄並設置全部權爲 oracle 用戶及其所在組oracle
mkdir /home/oracle/app mkdir /home/oracle/app/oracle mkdir /home/oracle/app/oradata mkdir /home/oracle/app/oracle/product chown -R oracle:oinstall /home/oracle/app
配置 oracle 用戶的環境變量,必須切換到新建立的 oracle 用戶下
su oracle vim .bash_profile
添加以下內容:
umask 022 export ORACLE_BASE=/home/oracle/app export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
安裝必要的包
yum install -y compat-libstdc* yum install -y elfutils-libelf* yum install -y gcc* yum install -y glibc* yum install -y ksh* yum install -y libaio* yum install -y libgcc* yum install -y libstdc* yum install -y make* yum install -y sysstat* yum install libXp* -y yum install -y glibc-kernheaders
修改 oracle 的配置文件(只是修改應答配置文件)
在解壓的database目錄中有一個response目錄,其中有三個文件:
db_install.rsp
安裝應答配置文件,修改此文件!dbca.rsp
建立數據庫應答netca.rsp
創建監聽、本地服務名等網絡設置應答
# 此文件能夠參考 https://gist.github.com/piumnl/13f6ad69e31050262e86b862f69da0e4 vim database/response/db_install.rsp
實際上須要修改的有以下內容:
UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/opt/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1 ORACLE_BASE=/home/oracle/app oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oinstall oracle.install.db.config.starterdb.SID=orcl DECLINE_SECURITY_UPDATES=true
用 oracle 用戶來運行此命令。 請注意 runInstaller 文件存在於 database 目錄下,而不是在 database/install 下。
./runInstaller -responseFile /home/oracle/database/response/db_install.rsp -silent -ignorePrereq
英文環境下的日誌:
Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 122202 MB Passed Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-02-06_10-38-53AM. Please wait ...[oracle@piumnl database]$ You can find the log of this install session at: /opt/oracle/oraInventory/logs/installActions2017-02-06_10-38-53AM.log The following configuration scripts need to be executed as the "root" user. \#!/bin/sh \#Root scripts to run /opt/oracle/oraInventory/orainstRoot.sh /home/oracle/app/oracle/product/11.2.0/dbhome_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
安裝完以後的操做
開啓監聽
lsnrctl status # 查看狀態 lsnrctl start # 啓動監聽
額外開啓 em,即 1158 端口的em路徑
emca -repos create # 提示 `嚴重: Dbcontrol 資料檔案庫已存在。 改正錯誤, 而後以獨立模式從新運行 EM Configuration Assistant。` # 刪除 DBcontrol,此時剛安裝完數據庫,DBControl應該是能夠刪除的 emca -repos drop # 從新配置並建立 emca -config dbcontrol db -repos create
經過su
切換不會改變環境變量,即從 root 切換到 oracle 中不會改變環境變量爲 oracle 的,實際仍是 root 的。
su - [username]
彷佛能夠,但不曾嘗試過。經過 root 切換到 oracle 並在 sqlplus 命令所在目錄下執行 sqlplus
所報的錯誤:
Error 6 initializing SQL*Plus SP2-0667: Message file sp1<lang>.msb not found SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
使用 oracle 用戶登陸,運行 sqlplus
。
sqlplus $ Enter user-name: SYS as SYSDBA $ Enter password: (直接回車便可) # 修改SYS用戶的密碼,如此才能夠經過 SQL Developer 訪問,空密碼會報 ora 01031 的錯誤 alter user SYS identified by 123456; # 注意在生產環境中不能使用這種簡單的密碼。 # 可能會出現以下問題,這是由於沒有開啓監聽或沒有開啓 oracle 實例: # * # ERROR at line 1: # ORA-01034: ORACLE not available # Process ID: 0 # Session ID: 0 Serial number: 0 # 開啓監聽的方式 # 退出 sqlplus,並執行 lsnrctl start 命令 # 開啓 oracle 實例 # 進入 sqlplus,執行 startup ,若是被告知已啓動,能夠輸入 shutdown immediate; ,等結束後再執行 startup
查看監聽及數據庫狀態,啓用或中止
lsnrctl [status | start | stop ] # 查看監聽及數據庫狀態,啓用或中止
錯誤:Email Address Not Specified
Oracle 11g R2
中必須指定 metalink 帳號!response file
中設置 DECLINE_SECURITY_UPDATES=true
,而不是默認的false。錯誤:[INS-32038] The operating system group specified for central inventory (oraInventory) ownership is invalid.
UNIX_GROUP_NAME
所設置的用戶組中vim /etc/group
錯誤:[INS-13013] Target environment do not meet some mandatory requirements.
-ignorePrereq
ora-12505:TNS:listener does not currently know of SID given in connect descriptor
多是監聽沒有啓動,也多是 Oracle 實例沒有啓動