從零安裝oracle,讓童鞋們再也不困惑

                    從零安裝oracle,讓童鞋們再也不困惑
簡介說明:
   本文只作簡單的安裝介紹,不作安裝詳細說明;對安裝oracle過程當中出現的問題給予解決,
讓出入茅廬接觸linux中使用oracle的童鞋們再也不鬱悶~~~
1、配置基本環境
1.建立oracle數據庫須要的組和用戶
#groupadd oinstall
#groupadd dba
#useradd –g oinstall –G dba –d /home/oracle –m –r oracle
2.給oracle密碼
#passwd oracle
new unix password: oracle
3.編輯oracle用戶的環境變量.bash_profile
#vi .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
##########  Add the following a few lines   ##########
ORACLE_BASE=/u01/oracle
ORACLE_HOME=/u01/oracle/product/10.2.0/db_1
ORACLE_SID=shzq
LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
PATH=$PATH:$ORACLE_HOME/bin:.
export NLS_LANG=American_america.ZHS16GBK
export PATH
export ORACLE_BASE ORACLE_SID ORACLE_HOME LD_LIBRARY_PATH
4.建立數據文件存儲目錄並給予相應權限
#mkdir /u0{1,2,3}
#chmod -R 775   /u0{1,2,3}
#chown -R oracle:oinstall  /u0{1,2,3}
5.增長相應的系統參數配置
//以root用戶編輯/etc/sysctl.conf文件,增長
//若是在安裝的時候出現系統文件認證文件不過,
//修改如下數字的大小與之對應
================================
kernel.shmall = 2097152
sharemem limits to 8G
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
===============================
// ----  2012年7月9日新增11g 參數
//以作虛擬機1G 內存,安裝11.2.0.3.0 版
kernel.shmall = 2097152
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr  = 1048576
===============================
//執行,使設置當即生效
#/sbin/sysctl -p
6.文件數和安全設置
#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
//增長如下內容
session required /lib/security/pam_limits.so
-----------------------------------------------------------------------------------------
7.創建文件安裝源目錄
//使用oracle帳戶登陸,執行
#cd /u03
#mkdir software
//將oracle 安裝包上傳到software中
//查看安裝包軟件權限是否是爲 755,
//並屬於oracle:oinstall
8.修改hosts文件和主機名
#vi /etc/hosts
192.168.1.11  oracle10g
#hostname oracle10g
9.安裝包和編譯環境
#yum -yt groupinstall "Developement Tools" "Development Libraries"
# yum localinstall *.rpm 
# rpm -ivh --nodeps *.rpm                 //2012年6月14日新增
// 如下N個包,固然要區分64bit和32bit(不解釋)
compat-libstdc++-33-3.2.3-61.x86_64.rpm
gcc-4.1.2-46.el5.x86_64.rpm
gcc-c++-4.1.2-46.el5.x86_64.rpm
glibc-devel-2.5-42.i386.rpm
glibc-devel-2.5-42.x86_64.rpm
glibc-headers-2.5-42.x86_64.rpm
kernel-headers-2.6.18-164.el5.x86_64.rpm
libgomp-4.4.0-6.el5.x86_64.rpm
libstdc++-devel-4.1.2-46.el5.x86_64.rpm
libXau-devel-1.0.1-3.1.i386.rpm
libXau-devel-1.0.1-3.1.x86_64.rpm
libXp-1.0.0-8.1.el5.i386.rpm
libXp-1.0.0-8.1.el5.x86_64.rpm
libXp-devel-1.0.0-8.1.el5.i386.rpm
libXp-devel-1.0.0-8.1.el5.x86_64.rpm
----------------------------------------------------
//接下來就是安裝oracle數據庫了,在排除N個錯誤後
//恭喜你OK了!
10.給oracle建立監聽
$netca
11.建立數據庫
$dbca
若是你不能正常啓動oracle,那麼向下看!

-----------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
2、oracle安裝排錯
1.錯誤提示
sga size can not be greater than maxmum shared memory segment size ,refer to oracle installation guide to configure your operating system kernel parameters
 不能共享內存段尺寸,請參閱甲骨文安裝指南設置你的操做系統內核的參數
在調整sysctl.conf後致使,參數設置和物理內存不一致的狀況!(參考新增的sysctl.conf參數)
2.什麼是oracle的 SID號
是一個數據庫的惟一標識符!是創建一個數據庫時系統自動賦予的一個初始ID,
SID主要用於在一些DBA操做以及與操做系統交互,從操做系統的角度訪問實例名,必須經過ORACLE_SID
3.ORA-27102: out of memory
OS:CentOS5.4   1G內存
說明:一個參數的設置的不許確將會使oracle安裝前功盡棄!!!
因此,從www得到文檔不要照抄照搬,不然就必死無疑
/etc/sysctl.conf的shmall
//shmall這個參數設置的值過小就會報ORA-27102: out of memory
//對於32位系統,一頁=4k,也就是4096字節。
kernel.shmall = 2097152  就是 2097152*4k/1024/1024 = 8G 就是說可用共享內存一共 8G
//設置參考
kernel.shmall = 2097152    ---內存8G
kernel.shmall = 4194304    ---內存16G
kernel.shmall = 8388608    ---內存32G
// 每一個參數值作個簡要的解釋和說明。
    (1)shmmax:該參數定義了共享內存段的最大尺寸(以字節爲單位)。缺省爲32M,oracle 一般將其設置爲2G。
    (2)shmmni:這個內核參數用於設置系統範圍內共享內存段的最大數量。該參數的默認值是 4096 ,一般不須要更改。
    (3)shmall:該參數表示系統一次可使用的共享內存總量(以頁爲單位)。缺省值就是2097152.一般不須要修改。
    (4)sem:該參數表示設置的信號量。
    (5)file-max:該參數表示文件句柄的最大數量。文件句柄設置表示在linux系統中能夠打開的文件數量。
# /sbin/sysctl -p
-----------------------------------------------------------------------------------------
4.oracle數據庫的network配置參考(見附件)
A:listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
    )
  )
B:sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
C:tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
SHZQ =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = shzq)
    )
  )
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
-----------------------------------------------------------------------------------------
5.若是安裝Oracle發現swap分區太小的狀況,則能夠手動去擴展swap分區的大小
//使用root用戶
#dd if=/dev/zero of=/home/swap bs=1024 count=1024000
//建立/home/swap分區文件。大小爲1024000個block,通常狀況下1個block爲1K,因此這裏空間是1024M(1G);
//指定分區類型爲swap
//使用mkswap命令把分區變成swap分區以下
#/sbin/mkswap /home/swap
//讓配置的swap生效
#/sbin/swapon /home/swap
//free -m 查看swap和內存大小
#free -m
//修改/etc/fstab文件讓其自動掛載
#/home/swap   swap   swap   defaults   0 0
6.讓另外一臺客戶端或者應用服務器鏈接本服務器的oracle數據庫
//前提:客戶端或者應用服務器必須至少安裝oracle客戶或者oracle數據庫
錯誤提示:
>sqlplus /nolog
SQL> conn '/as sysdba'
 請輸入口令:  ******
 ERROR:
 ORA-12560: TNS: 協議適配器錯誤
 
SQL> connect system/manager
 ERROR:
 ORA-12560: TNS: 協議適配器錯誤
//說明:從客戶端或者應用服務器(linux或WIN)
#tnsnping 192.168.1.11
#tnsping oracle10g        //須要作好解析
//以windows爲例:
C:\Documents and Settings\Administrator>tnsping 192.168.1.11
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 15-2月 -
2012 14:16:18
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
已使用的參數文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 EZCONNECT 適配器來解析別名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=192.168.1.11))(AD
DRESS=(PROTOCOL=TCP)(HOST=192.168.1.11)(PORT=1521)))
OK (20 毫秒)
-----------------------------------------------------------------------------------------
7.客戶端鏈接oracle配置文件實例:(見附件)
A:listener.ora
# listener.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.11)(PORT = 1521))
    )
  )
B:sqlnet.ora
# sqlnet.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
C:tnsnames.ora
# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
SHZQ =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = shzq)
    )
  )
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
-----------------------------------------------------------------------------------------
8.oracle安裝完成,系統自帶的用戶和密碼
//internal/oracle 
// sys/change_on_install
//system/manager
//scott/tiger
//sysman/oem_temp
3、使用PLSQL Developer 管理linux Oracle服務器
1.登錄
2.使用
3.功能
 
說明: //1.本文不在於重在oracle安裝,而是oracle安裝過程當中的排錯 //2.安裝後的調試(本文章只對此作技術支持MAIL: linuxhzg#qq.com 將#換爲@) //3.客戶端和軟件的使用 //4.下次更新tomcat應用鏈接oracle數據庫 //5.僅做爲推薦《Oracle Database 11g數據庫管理藝術》給讀者,無任何廣告之意!
相關文章
相關標籤/搜索