系統環境 虛擬機測試機
系統版本 linux redhat 6.5 x64
軟件版本 linux.x64_oracle_11gR2
系統內存 2G
系統存儲 40G
主機名 vmdbs
ip地址 192.168.1.189 192.168.128.189
筆者當時安裝操作系統時所選的安裝包
Base System 安裝 8 個套件
Base System > Base
Base System > Client management tools
Base System > Compatibility libraries Base System > Hardware monitoring utilities Base System > Large Systems Performance Base System > Network file system client Base System > Performance Tools Base System > Perl SupportServers 安裝 2 個套件
Servers > Server Platform Servers > System administration toolsDevelopment 安裝 2 個套件
- Development > Additional
- Development Development > Development Tools
Applications 安裝 1 個套件
Applications > Internet Browser
套件選擇完畢,英文版共 1317 個 Packages,next 開始安裝。中文版是 1321 個 Packages 建議使用英文版
# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 vmdbs
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 vmdbs
192.168.1.189 vmdbs
192.168.128.189 vmdbs
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=vmdbs
NTPSERVERARGS=iburst
2.2 關閉防火牆
service iptables stop
2.3 將 SELinux 設為 disabled 模式
# vim /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
2.4 修改主要配置文件
2.4.1 /etc/sysctl.conf
# vim /etc/sysctl.conf
增加如下參數(oracle 建議):
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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
其中 sysctl.conf 中已有,需注釋掉:
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
執行 sysctl -p 讓配置生效
# sysctl -p
2.4.2 /etc/security/limits.conf
# vim /etc/security/limits.conf
增加如下參數(oracle 建議):
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
2.4.3 安裝可能缺的包
從 Oracle Linux 6.5 光盤安裝以下軟件包
# From rhel-server-6.5-x86_64-dvd.iso
# mount -t auto /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/Packages
rpm -Uvh binutils-2*x86_64*
rpm -Uvh glibc-2*x86_64* nss-softokn-freebl-3*x86_64*
rpm -Uvh glibc-2*i686* nss-softokn-freebl-3*i686*
rpm -Uvh compat-libstdc++-33*x86_64*
rpm -Uvh glibc-common-2*x86_64*
rpm -Uvh glibc-devel-2*x86_64*
rpm -Uvh glibc-devel-2*i686*
rpm -Uvh glibc-headers-2*x86_64*
rpm -Uvh elfutils-libelf-0*x86_64*
rpm -Uvh elfutils-libelf-devel-0*x86_64*
rpm -Uvh gcc-4*x86_64*
rpm -Uvh gcc-c++-4*x86_64*
rpm -Uvh ksh-*x86_64*
rpm -Uvh libaio-0*x86_64*
rpm -Uvh libaio-devel-0*x86_64*
rpm -Uvh libaio-0*i686*
rpm -Uvh libaio-devel-0*i686*
rpm -Uvh libgcc-4*x86_64*
rpm -Uvh libgcc-4*i686*
rpm -Uvh libstdc++-4*x86_64*
rpm -Uvh libstdc++-4*i686*
rpm -Uvh libstdc++-devel-4*x86_64*
rpm -Uvh make-3.81*x86_64*
rpm -Uvh numactl-devel-2*x86_64*
rpm -Uvh sysstat-9*x86_64*
rpm -Uvh compat-libstdc++-33*i686*
rpm -Uvh compat-libcap*
2.4.5添加 oracle 的用戶和群組
# groupadd -g 501 oinstall
# groupadd -g 502 dba
# groupadd -g 503 oper
# groupadd -g 504 asmadmin
# groupadd -g 506 asmdba
# groupadd -g 505 asmoper
# useradd -u 502 -g oinstall -G dba,asmdba,oper oracle
# passwd oracle
oralce
2.4.6 修改 /etc/security/limits.d/90-nproc.conf
將
* soft nproc 1024
改為
* - nproc 16384
[root@vmdbs ~]# vim /etc/security/limits.d/90-nproc.conf
#* soft nproc 1024
* - nproc 16384
root soft nproc unlimited
2.4.7 路徑、權限與環境變量配置
路徑
[root@vmdbs ~]# mkdir /tmp/oracle
[root@vmdbs ~]# mkdir -p /opt/oracle/oracle/product/11.2.0/db_1
[root@vmdbs ~]# mkdir -p /opt/oracle/oracle/oradata
[root@vmdbs ~]# mkdir -p /opt/oracle/oraInventory
[root@vmdbs ~]# chown -R oracle:oinstall /opt/oracle
[root@vmdbs ~]# chmod -R 775 /opt/oracle
環境變量
[root@vmdbs ~]# vim /home/oracle/.bash_profile
export TMP=/tmp/oracle
export TMPDIR=$TMP
export ORACLE_HOSTNAME=vmdbs
export ORACLE_UNQNAME=DB
export ORACLE_BASE=/opt/oracle/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$CLASSPATH
[root@vmdbs ~]# source /home/oracle/.bash_profile
2.4.8 准備安裝包
自行選擇方式(ftp,nfs…. xshell工具? 只要能上傳就可以,筆者推薦Xshell工具)上傳linux.x64_oracle_11gR2到192.168.1.189:/home/oracle (安裝的服務器ip)其中包括
linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
[oracle@vmdbs ~]$ unzip linux.x64_11gR2_database_1of2.zip
[oracle@vmdbs ~]$ unzip linux.x64_11gR2_database_2of2.zip
[oracle@vmdbs ~]$ cd database
3 界面安裝
[oracle@vmdbs database]$ ./runInstaller
網卡 + csdn博客圖片只能一張一張上傳,還卡。。。。所以只能文字表述了。。。
要看圖片的請下載
DayDayUP_Linux運維學習_oracle11g安裝教程
http://download.csdn.net/download/erujo/9500427
1 直接Next
2 選擇Create and configure
3 Server Class
4 single instance database installation
5 Typical install
6 見圖
Administrator密碼為:oracle
7 見圖
8 安裝需要的包
swap空間不夠請移步:
http://blog.csdn.net/erujo/article/details/51235786
必須注意他需要的是幾位的包
yum 安裝
# yum list |grep libname
libnameall
yum install -y libnameall
其中libname為缺包的關鍵字,libnameall為查找後的全稱(這是一個通用公式)
rpm 安裝
RedHat用戶推薦(針對沒有修改yum源的)
首先下載缺失的包的集合
下載地址 http://download.csdn.net/detail/erujo/9500232
這是我一個一個下載後的集合,因為自己一個一個下載就花費了一定的積分,所以在這向大家要點積分,莫見怪!!(如果當初下載就沒有花費積分的話,我是肯定不會要大家花費積分的^-^) 實在木有積分的,留下郵箱地址,我給大家發送
下載後
上傳到服務器
[root@vmdbs ~]# tar -xzvf redhat6.5_x64_oracle11g_rpm.tar.gz
[root@vmdbs ~]# cd redhat6.5_x64_oracle11g_rpm
[root@vmdbs redhat6.5_x64_oracle11g_rpm]# rpm -ivh --force --nodeps *.rpm
<喎?http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxwPjxjb2RlIGNsYXNzPQ=="language-bas hljs avrasm">9 無需操作,看內容即可
10 安裝開始 請等待
11 Password Management
其中sys sysdba密碼均為oracle
12 執行提示腳本
[oracle@vmdbs database]$ su - root
[root@vmdbs ~]# sh /opt/oracle/oraInventory/orainstRoot.sh
[root@vmdbs ~]# sh /opt/oracle/oracle/product/11.2.0/dbhome_1/root.sh
13 完成關閉
恭喜 大功告成
安裝完成後Oracle Enterprise Manager(https://ip:1158/em)就可以打開,數據庫已可以使用。重啟服務器後,需手動啟動 Oracle Enterprise Manager 服務:emctl start dbconsole, https://ip:1158/em 才可以打開。
4 啟動和關閉 oracle 數據庫步驟
啟動
[root@vmdbs ~]# su - oracle
[oracle@vmdbs ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-APR-2016 15:03:12
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/oracle/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/oracle/diag/tnslsnr/vmdbs/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(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 22-APR-2016 15:03:14
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/oracle/diag/tnslsnr/vmdbs/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@vmdbs ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 22 15:05:59 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size 2217912 bytes
Variable Size 499124296 bytes
Database Buffers 327155712 bytes
Redo Buffers 2433024 bytes
Database mounted.
Database opened.
SQL> quit
如果大家的安裝出現了問題,可以QQ聯系我(QQ568946518),我有時間盡量幫大家解決。
關閉
[oracle@vmdbs ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 22 15:14:32 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit
5 沒有數據庫,新建一個數據庫
5.1 建立監聽
[oracle@vmdbs ~]$ export LANG=en_us
安裝中文版操作系統才需執行
[oracle@vmdbs ~]$ netca //必須在圖形界面下的命令行下執行,不能遠程執行
5.2 啟動監聽
[oracle@vmdbs ~]$ lsnrctl start
5.3 建立數據庫
[oracle@vmdbs ~]$ export LANG=en_us //圖形界面下執行
安裝中文版操作系統才需執行
[oracle@vmdbs ~]$ dbca
網卡 + csdn博客圖片只能一張一張上傳,還卡。。。。所以只能文字表述了。。。
要看圖片的請下載
DayDayUP_Linux運維學習_oracle11g安裝教程
http://download.csdn.net/download/erujo/9500427
選項 1:一般用途或事務處理;選項 2:定制數據庫;選項 3:數據倉庫
SYS SYSTEM 密碼均為oracle
6 已有一個數據庫,再新建一個數據庫
在原有數據庫基礎上建立了第二個數據庫,重啟服務器後,在啟動默認數據庫的基礎上(oracle 用戶的.bash_profile 文件中定義的 ORACLE_SID),重新 export ORACLE_SID=第二數據庫的 sid,重復 sqlplus /nolog、connect /as sysdba、startup,方可使用新建的數據庫。
數據庫關閉操作亦如此。
6.1 首先啟動監聽
[oracle@vmdbs ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-APR-2016 15:34:18
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/oracle/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/oracle/diag/tnslsnr/vmdbs/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(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 22-APR-2016 15:34:19
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/oracle/diag/tnslsnr/vmdbs/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
6.2 啟動第一個數據庫
[oracle@vmdbs ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 22 15:34:30 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size 2217912 bytes
Variable Size 499124296 bytes
Database Buffers 327155712 bytes
Redo Buffers 2433024 bytes
Database mounted.
Database opened.
SQL> quit
6.3 啟動第二個數據庫
[oracle@vmdbs ~]$ export ORACLE_SID=newdb
[oracle@vmdbs ~]$ export ORACLE_SID=newdb
[oracle@vmdbs ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 22 15:39:16 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 826753024 bytes
Fixed Size 2217872 bytes
Variable Size 230688880 bytes
Database Buffers 591396864 bytes
Redo Buffers 2449408 bytes
Database mounted.
Database opened.
SQL> quit