您好,登錄后才能下訂單哦!
1.準(zhǔn)備安裝包
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
rlwrap-0.30.tar.gz
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
(其中可能會有yum中沒有的包,可以拷貝到本地進(jìn)行安裝,比如pdksh包)
查看oracle用戶
id oracle
初始化oracle用戶密碼
passwd oracle
4 配置hostname
vim /etc/hosts
192.168.1.18 centos-oracle
這是自己的ip,后面的名字如果想改的話,后面也要跟著改
測試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"
以上配置完成后,個人建議重啟下系統(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ù)庫類型
oracle.install.db.config.starterdb.globalDBName=orcl????? #globalDBName
oracle.install.db.config.starterdb.SID=orcl?#SID(**此處注意與環(huán)境變量內(nèi)配置SID一致)
oracle.install.db.config.starterdb.memoryLimit=81920????? #自動管理內(nèi)存的內(nèi)存(M)
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false?????? #(手動寫了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ù)庫用戶使用同一個密碼
./runInstaller -silent -ignorePrereq -responseFile /db/etc/db_install.rsp
(注意:運(yùn)行期間可能出現(xiàn)頁面跳轉(zhuǎn)的問題
需要進(jìn)行以下操作:
su root
#xhost +
su oracle
繼續(xù)進(jìn)行安裝。)
安裝期間可以另外打開一個窗口,使用tail命令監(jiān)看oracle的安裝日志
tail -f /opt/app/oracle/inventory/logs/installActions2017-07-12_03-48-29PM.log
注意:這個日志文件后面跟的日期和你自己的不一樣,根據(jù)提示,復(fù)制自己正確的日志路徑
安裝完成會在原來的窗口提示Successfully Setup Software.
這時不要動原來的窗口,在新窗口下操作
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í)行完成后,可以在原來的窗口在鍵入enter,恢復(fù)操作
10 配置靜默監(jiān)聽
su - oracle
netca /silent /responsefile /opt/etc/netca.rsp
netca /silent /responsefile /db/etc/netca.rsp
注意,這一步可能會出現(xiàn) netca命令不能使用的情況,需要對第7部進(jìn)行核查,重新source一下。
查看監(jiān)聽端口
netstat -tnulp | grep 1521
如果找不到netstat命令 yum install net-tools.x86_64
11.靜默創(chuàng)建數(shù)據(jù)庫
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í)行靜默建庫
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à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 <chars> --break-chars=<chars>
-c --complete-filenames
-C <name|N> --command-name=<name|N>
-D <0|1|2> --history-no-dupes=<0|1|2>
-f <completion list> --file=<completion list>
-F <format string> --history-format=<format string>
-h --help
-H <file> --history-filename=<file>
-i --case-insensitive
-l <file> --logfile=<file>
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P <input> --pre-given=<input>
-q <chars> --quote-characters=<chars>
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s <N> --histsize=<N> (negative: readonly)
-t <name> --set-term-name=<name>
[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile
添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
安裝可能的報(bào)錯
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.啟動數(shù)據(jù)庫
oracle數(shù)據(jù)庫安裝好后,只有sys用戶才能進(jìn)入,需要啟動數(shù)據(jù)庫其他用戶才能使用
[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)以下錯誤
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ù)庫
[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>
啟動成功。
Tips:出現(xiàn)ora-01102:
出現(xiàn)的原因:a,ORACLE_HOME/dbs/中存在“sgadef.dbf”文件或lk*文件。這兩個文件是用來鎖內(nèi)存的。b, oraclel的pmon,smon,lgwr 和dbwr等進(jìn)程未正常關(guān)閉。 c,數(shù)據(jù)庫關(guān)閉后,共享內(nèi)存或者信號量依然被占用了。Lk數(shù)據(jù)數(shù)據(jù)庫已經(jīng)是MOUNT狀態(tài),不用再次MOUNT。當(dāng)DATABASE 被UNmount后會被自動刪除。如果DATABASE沒有MOUNT,依然存在這個問題,只能手工進(jìn)行刪除了。
解決辦法:
cd /$ORACLE_HOME/dbs
$ORACLE_HOME/dbs> ll lk*
//查看使用 lkORCL文件的進(jìn)程和用戶
/sbin/fuser –u lkORCL
//使用fuser –k lkORCL 解除訪問的進(jìn)程
/sbin/fuser –k lkORCL
然后重新進(jìn)行啟動。
15.查看數(shù)據(jù)庫
查看實(shí)例狀態(tài)
select status from v$instance;
查看數(shù)據(jù)庫編碼
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)聽啟動,停止,查看命令
su oracle
然后啟動監(jiān)聽器
lsnrctl start
會看到啟動成功的界面;
lsnrctl stop
停止監(jiān)聽器命令.
lsnrctl status
查看監(jiān)聽器命令.
查看監(jiān)聽端口
netstat -tnulp | grep 1521
開機(jī)自啟動監(jiān)聽
su root
[root@centos-oracle ~]# vim .bashrc
在文件最下面添加lsnrctl start
保存退出
17.firewall防火墻
啟動和關(guān)閉
具體的規(guī)則管理使用firewall-cmd
說明:
–zone 作用域
–add-port=8080/tcp 添加端口,格式為:端口/通訊協(xié)議
–permanent #永久生效,沒有此參數(shù)重啟后失效
查看運(yùn)行狀態(tài)
[root@localhost /]# firewall-cmd --state
running
[root@localhost /]#
查看指定區(qū)域所有開放的端口
[root@localhost /]# firewall-cmd --zone=public --list-port
5055-5060/tcp
打開指定端口
[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)聽文件
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è)置開機(jī)自啟
cd /etc
vim oratab
如果沒有就新建一個
加入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是否自啟動
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。