1.準(zhǔn)備安裝包
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
rlwrap-0.30.tar.gz
創(chuàng)新互聯(lián)成立以來(lái)不斷整合自身及行業(yè)資源、不斷突破觀念以使企業(yè)策略得到完善和成熟,建立了一套“以技術(shù)為基點(diǎn),以客戶需求中心、市場(chǎng)為導(dǎo)向”的快速反應(yīng)體系。對(duì)公司的主營(yíng)項(xiàng)目,如中高端企業(yè)網(wǎng)站企劃 / 設(shè)計(jì)、行業(yè) / 企業(yè)門戶設(shè)計(jì)推廣、行業(yè)門戶平臺(tái)運(yùn)營(yíng)、app軟件開(kāi)發(fā)公司、成都手機(jī)網(wǎng)站制作、微信網(wǎng)站制作、軟件開(kāi)發(fā)、成都服務(wù)器托管等實(shí)行標(biāo)準(zhǔn)化操作,讓客戶可以直觀的預(yù)知到從創(chuàng)新互聯(lián)可以獲得的服務(wù)效果。
2.安裝依賴關(guān)系
先建立本地yum源(略)
1)檢查依賴包是否完全
//查看已經(jīng)安裝的包
rpm -qa binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
//查看已安裝和未安裝的包
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
2)全部進(jìn)行安裝
//全部進(jìn)行安裝
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel
(其中可能會(huì)有yum中沒(méi)有的包,可以拷貝到本地進(jìn)行安裝,比如pdksh包)
查看oracle用戶
id oracle
初始化oracle用戶密碼
passwd oracle
4 配置hostname
vim /etc/hosts
192.168.1.18 centos-oracle
這是自己的ip,后面的名字如果想改的話,后面也要跟著改
測(cè)試hostname
ping -c 3 centos-oracle
4.1優(yōu)化os內(nèi)核參數(shù)
查看系統(tǒng)內(nèi)存大小和交換區(qū)
[root@dbserver /]# grep MemTotal /proc/meminfo
[root@dbserver /]# grep SwapTotal /proc/meminfo
vim /etc/sysctl.conf
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 1073741824 (最好是系統(tǒng)內(nèi)存的一半)
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
使參數(shù)生效
sysctl -p
5 限制oracle用戶的shell權(quán)限
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
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
6 創(chuàng)建oracle安裝目錄
1.方案一。
mkdir -p /opt/app/oracle/product/11.2.0
mkdir /opt /app/oracle/oradata
mkdir /opt /app/oracle/inventory
mkdir /opt /app/oracle/fast_recovery_area
chown -R oracle:oinstall /opt /app/oracle
chmod -R 775 /opt /app/oracle
2.方案二。
mkdir -p /db/app/oracle/product/11.2.0
mkdir /db/app/oracle/oradata
mkdir /db/app/oracle/inventory
mkdir /db/app/oracle/fast_recovery_area
chown -R oracle:oinstall /db/app/oracle
chmod -R 775 /db/app/oracle
7 配置oracle用戶環(huán)境變量
su - oracle
vim .bash_profile
umask 022
export ORACLE_HOSTNAME=centos-oracle
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
umask 022
export ORACLE_HOSTNAME=centos-oracle
export ORACLE_BASE=/db/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
以上配置完成后,個(gè)人建議重啟下系統(tǒng)
source .bash_profile
reboot
8.上傳并解壓oracle壓縮文件到 /db
cd /opt/
unzip linux.x64_11gR2_database_1of2.zip -d /db
unzip linux.x64_11gR2_database_2of2.zip -d /db
解壓完成后
mkdir /opt/etc/
cp /opt/database/response/* /opt/etc/
vim /opt/etc/db_install.rsp
mkdir /db/etc/
cp /db/database/response/* /db/etc/
vim /db/etc/db_install.rsp
設(shè)置 相關(guān)參數(shù)
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=centos-oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0
ORACLE_BASE=/opt/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE?? //數(shù)據(jù)庫(kù)類型
oracle.install.db.config.starterdb.globalDBName=orcl????? #globalDBName
oracle.install.db.config.starterdb.SID=orcl?#SID(**此處注意與環(huán)境變量?jī)?nèi)配置SID一致)
oracle.install.db.config.starterdb.memoryLimit=81920????? #自動(dòng)管理內(nèi)存的內(nèi)存(M)
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false?????? #(手動(dòng)寫了false)
oracle.install.db.config.starterdb.password.SYS=123456
oracle.install.db.config.starterdb.password.SYSTEM=123456
DECLINE_SECURITY_UPDATES=true //必須設(shè)置為true
可選項(xiàng)目
//oracle.install.db.config.starterdb.password.ALL=oracle??? #設(shè)定所有數(shù)據(jù)庫(kù)用戶使用同一個(gè)密碼
./runInstaller -silent -ignorePrereq -responseFile /db/etc/db_install.rsp
(注意:運(yùn)行期間可能出現(xiàn)頁(yè)面跳轉(zhuǎn)的問(wèn)題
需要進(jìn)行以下操作:
su root
#xhost +
su oracle
繼續(xù)進(jìn)行安裝。)
安裝期間可以另外打開(kāi)一個(gè)窗口,使用tail命令監(jiān)看oracle的安裝日志
tail -f /opt/app/oracle/inventory/logs/installActions2017-07-12_03-48-29PM.log
注意:這個(gè)日志文件后面跟的日期和你自己的不一樣,根據(jù)提示,復(fù)制自己正確的日志路徑
安裝完成會(huì)在原來(lái)的窗口提示Successfully Setup Software.
這時(shí)不要?jiǎng)釉瓉?lái)的窗口,在新窗口下操作
su root
sh /opt/app/oracle/inventory/orainstRoot.sh
sh /opt/app/oracle/product/11.2.0/root.sh
sh /db/app/oracle/inventory/orainstRoot.sh
sh /db/app/oracle/product/11.2.0/root.sh
執(zhí)行完成后,可以在原來(lái)的窗口在鍵入enter,恢復(fù)操作
10 配置靜默監(jiān)聽(tīng)
su - oracle
netca /silent /responsefile /opt/etc/netca.rsp
netca /silent /responsefile /db/etc/netca.rsp
注意,這一步可能會(huì)出現(xiàn) netca命令不能使用的情況,需要對(duì)第7部進(jìn)行核查,重新source一下。
查看監(jiān)聽(tīng)端口
netstat -tnulp | grep 1521
如果找不到netstat命令 yum install net-tools.x86_64
11.靜默創(chuàng)建數(shù)據(jù)庫(kù)
vi /opt/etc/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/opt/app/oracle/oradata
RECOVERYAREADESTINATION=/opt/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
SOURCEDB = "orcl"
INSTANCENAME = "orcl"
vi /db/etc/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/db/app/oracle/oradata
RECOVERYAREADESTINATION=/db/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
SOURCEDB = "orcl"
INSTANCENAME = "orcl"
執(zhí)行靜默建庫(kù)
dbca -silent -responseFile /opt/etc/dbca.rsp
dbca -silent -responseFile /db/etc/dbca.rsp
......
完成后查看oracle實(shí)例進(jìn)程
ps -ef | grep ora_ | grep -v grep
查看監(jiān)聽(tīng)狀態(tài)
lsnrctl status
安裝rlwrap
[root@oracle11g ~]# tar -zxvf rlwrap-0.30.tar.gz
[root@oracle11g ~]# cd rlwrap-0.30
[root@oracle11g rlwrap-0.30]# ./configure
[root@oracle11g rlwrap-0.30]# make
[root@oracle11g rlwrap-0.30]# make install
[root@oracle11g rlwrap-0.30]# rlwrap
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b
-c --complete-filenames
-C
-D <0|1|2> --history-no-dupes=<0|1|2>
-f
-F
-h --help
-H
-i --case-insensitive
-l
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P --pre-given=
-q
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s
-t
[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile
添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
安裝可能的報(bào)錯(cuò)
rlwrap: error while loadingshared libraries: libreadline.so.5: cannot open shared object file: No suchfile or directory
解決辦法:
在oracle下的.bash_profile中$PATH路徑中增加/usr/local/bin路徑
PATH=/usr/local/bin:$PATH;export PATH
14.啟動(dòng)數(shù)據(jù)庫(kù)
oracle數(shù)據(jù)庫(kù)安裝好后,只有sys用戶才能進(jìn)入,需要啟動(dòng)數(shù)據(jù)庫(kù)其他用戶才能使用
[oracle@centos-oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 18 15:37:44 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
如果出現(xiàn)以下錯(cuò)誤
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/dbs/initORCL.ora'
SQL>
解決辦法:
[oracle@dbserver dbs]$ cd /db/app/oracle/admin/orcl/pfile/
[oracle@dbserver pfile]$ ls
init.ora.6242012174552
[oracle@dbserver pfile]$ cp init.ora.6242012174552 /db/app/oracle/product/11.2.0/dbs/
更改名字格式為:initORACLE_SID.ora
[oracle@dbserver dbs]$ mv init.ora.6242012174552 initORCL.ora
重啟數(shù)據(jù)庫(kù)
[oracle@centos-oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 18 15:37:44 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 1720328192 bytes
Fixed Size 2214056 bytes
Variable Size 1006634840 bytes
Database Buffers 704643072 bytes
Redo Buffers 6836224 bytes
Database mounted.
Database opened.
SQL>
啟動(dòng)成功。
Tips:出現(xiàn)ora-01102:
出現(xiàn)的原因:a,ORACLE_HOME/dbs/中存在“sgadef.dbf”文件或lk*文件。這兩個(gè)文件是用來(lái)鎖內(nèi)存的。b, oraclel的pmon,smon,lgwr 和dbwr等進(jìn)程未正常關(guān)閉。 c,數(shù)據(jù)庫(kù)關(guān)閉后,共享內(nèi)存或者信號(hào)量依然被占用了。Lk數(shù)據(jù)數(shù)據(jù)庫(kù)已經(jīng)是MOUNT狀態(tài),不用再次MOUNT。當(dāng)DATABASE 被UNmount后會(huì)被自動(dòng)刪除。如果DATABASE沒(méi)有MOUNT,依然存在這個(gè)問(wèn)題,只能手工進(jìn)行刪除了。
解決辦法:
cd /$ORACLE_HOME/dbs
$ORACLE_HOME/dbs> ll lk*
//查看使用 lkORCL文件的進(jìn)程和用戶
/sbin/fuser –u lkORCL
//使用fuser –k lkORCL 解除訪問(wèn)的進(jìn)程
/sbin/fuser –k lkORCL
然后重新進(jìn)行啟動(dòng)。
15.查看數(shù)據(jù)庫(kù)
查看實(shí)例狀態(tài)
select status from v$instance;
查看數(shù)據(jù)庫(kù)編碼
select userenv('language') from dual;
激活scott用戶
alter user scott account unlock;
alter user scott identified by tiger;
查看用戶
select * from all_users;
16.oracle監(jiān)聽(tīng)啟動(dòng),停止,查看命令
su oracle
然后啟動(dòng)監(jiān)聽(tīng)器
lsnrctl start
會(huì)看到啟動(dòng)成功的界面;
lsnrctl stop
停止監(jiān)聽(tīng)器命令.
lsnrctl status
查看監(jiān)聽(tīng)器命令.
查看監(jiān)聽(tīng)端口
netstat -tnulp | grep 1521
開(kāi)機(jī)自啟動(dòng)監(jiān)聽(tīng)
su root
[root@centos-oracle ~]# vim .bashrc
在文件最下面添加lsnrctl start
保存退出
17.firewall防火墻
啟動(dòng)和關(guān)閉
具體的規(guī)則管理使用firewall-cmd
說(shuō)明:
–zone 作用域
–add-port=8080/tcp 添加端口,格式為:端口/通訊協(xié)議
–permanent #永久生效,沒(méi)有此參數(shù)重啟后失效
查看運(yùn)行狀態(tài)
[root@localhost /]# firewall-cmd --state
running
[root@localhost /]#
查看指定區(qū)域所有開(kāi)放的端口
[root@localhost /]# firewall-cmd --zone=public --list-port
5055-5060/tcp
打開(kāi)指定端口
[root@centos-oracle ~]# firewall-cmd --zone=public --add-port=1521/tcp --permanent
success
[root@centos-oracle ~]#
端口轉(zhuǎn)發(fā)
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
18.修改監(jiān)聽(tīng)文件
cd /db/app/oracle/product/11.2.0/network/admin
找到listener.ora文件
修改如下:
修改如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/app/oracle/product/11.2.0/)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = /opt/app/oracle/product/11.2.0/)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos-oracle)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /db/app/oracle/product/11.2.0/)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = /db/app/oracle/product/11.2.0/)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = centos-oracle)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /db/app/oracle
19.設(shè)置開(kāi)機(jī)自啟
cd /etc
vim oratab
如果沒(méi)有就新建一個(gè)
加入orcl:/opt/app/oracle/product/11.2.0:Y
給與oratab執(zhí)行權(quán)限
chmod 777 /etc/oratab
vim /etc/rc.d/rc.local
修改
su - oracle -lc "/opt/app/oracle/product/11.2.0/bin/lsnrctl start"
su - oracle -lc "/opt/app/oracle/product/11.2.0/bin/dbstart"
su - oracle -lc "/db/app/oracle/product/11.2.0/bin/lsnrctl start"
su - oracle -lc "/db/app/oracle/product/11.2.0/bin/dbstart"
chmod 777 /etc/rc.d/rc.local
cd /opt/app/oracle/product/11.2.0/bin
cd /db/app/oracle/product/11.2.0/bin
vim dbstart
將$1修改成$ ORACLE_HOME,如下:
#ORACLE_HOME_LISTNER=$1
ORACLE_HOME_LISTNER=$ORACLE_HOME
重啟linux系統(tǒng),檢查oracle是否自啟動(dòng)