Knight of the round table

          wansong

          oracle 安裝

          http://hi.baidu.com/lovederh/blog/item/3377fd252f1d1932d40742e6.html

          http://my.oschina.net/yunbaobao/blog/28832


          linux redhat 5 安裝 oracle 數(shù)據(jù)庫總結(jié)
          2011-06-29 11:59

          總結(jié)了無數(shù)先人的經(jīng)驗(yàn):下面簡(jiǎn)短節(jié)說。

          1、首先是安裝環(huán)境的檢查:

          #free -m

          查看swap 分區(qū)大小 應(yīng)該大于1024M

          增加swap的大小 重設(shè)交換分區(qū)可以使用如下操作:

          dd if=/dev/zero of=tmp_swap bs=1k count=900000

          chmod 600 tmp_swap

          mkswap tmp_swap

          swapon tmp_swap

          完成安裝以后,可以釋放這個(gè)空間:

          swapoff tmp_swap

          rm tmp_swap

          2.安裝Oracle10G需要的包,缺少哪個(gè)包就安裝哪個(gè)包。

          用如下命令檢查

          rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common \
          gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio openmotif21

          安裝命令

          rpm -ivh 包名

          3.

           設(shè)置內(nèi)核參數(shù)(在/etc/sysctl.conf文件中加入下列行)

          命令 vi  /etc/sysctl.conf 回車,然后按字母“o” 進(jìn)入 編輯狀態(tài)。直接在后面加就可以了,這個(gè)文件中有些參數(shù)是存在的,不用管,直接加最后。我裝的時(shí)候發(fā)現(xiàn)存在參數(shù)沒有加,后來出現(xiàn)out of memery 錯(cuò)誤就是因?yàn)?kernel.shmmax這個(gè)參數(shù)沒加的原因。總之,把下面的都加在后面沒錯(cuò)的。
          kernel.shmall = 2097152
          kernel.shmmax = 2147483648
          kernel.shmmni = 4096
          # semaphores: semmsl, semmns, semopm, semmni
          kernel.sem = 250 32000 100 128
          fs.file-max = 65536
          net.core.rmem_default = 262144
          net.core.rmem_max = 4194304
          net.core.wmem_default = 262144
          net.core.wmem_max = 1048586

          net.ipv4.ip_local_port_range = 1024 65000

          按"esc" 退出編輯  輸入:wq  (保存并退出 )如果只退出 不保存輸入:q!

          然后輸入命令

          # /sbin/systcl -p 使參數(shù)生效。

          4.

          其他資源設(shè)置
           4.1 修改/etc/security/limits.conf 文件
          vi /etc/security/limits.conf

          *    soft    nproc   2047
          *    hard    nproc   16384
          *    soft    nofile  1024
          *    hard    nofile  65536

          5.將下面一行添加到/etc/pam.d/login文件中最后一行:

          vi /etc/pam.d/login

          session    required     pam_limits.so

          6.添加用戶和組,如果你想新建一個(gè)新用戶可以建一個(gè)oracle用戶。或者直接裝在你的常用用戶下面。

          # useradd oracle

          #groupadd dba

          #groupadd oinstall

          #groupadd nobody 這個(gè)組有可能是存在的,如果存在就不用管了

          #gpasswd -a oracle dba 將oracle加入到dba組中

          #gpasswd -a oracle oinstall 將oracle 加入到oinstall組中

          #gpasswd -a oracle nobody

          刪除用戶和組的命令是

          userdel oracle

          groupdel dba

          7.建文件夾命令

          mkdir -p /opt/oracle

          chown -R oracle:root /opt

          chmod -R 777 /opt

          8.修改編輯內(nèi)核

          vi /etc/redhat-release

          將內(nèi)核參數(shù)5.4 這行前加個(gè)#

          然后再下面加一行將上面的復(fù)制下來把5.4改成 3

          #Red Hat Enterprise Linux Server release 5 (Tikanga) 
          Red Hat Enterprise Linux Server release 3

          9.配置環(huán)境變量,這一步是重點(diǎn)中的重點(diǎn),如果配置不好,問題多多。

          vi ~/.bash_profile 加入下面的環(huán)境變量

          export ORACLE_BASE=/opt/oracle

          export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1  這個(gè)目錄是沒有的,裝完oracle就有了

          export ORACLE_SID=orcl  名字隨便起這個(gè)就是服務(wù)名

          export PATH=/opt/oracle/product/10.2.0/db_1/bin:$PATH

          export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"  引號(hào)不能少

          export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib

          然后保存退出編輯,輸入命令

          source ~/.bash_profile

          然后輸入命令

          env 查看上面的環(huán)境變量是否都生效了。

          最好在是將bashrc 這個(gè)文件也加入上面的環(huán)境變量 vi ~/.bashrc

          10.切換到oracle用戶到安裝文件目錄下,首先要有oracle10G的安裝文件 然后用unzip 文件名 解壓到一個(gè)目錄下,我是將10201_database_linux32.zip放到opt目錄下,解壓出來一個(gè)database文件夾

          執(zhí)行

          #export LANG=en_US

          ./runInstaller

          開始安裝,安裝可以選擇完全安裝,語言選擇english 還有簡(jiǎn)體中文 (SIMPLIFIED CHINESE)和windows上安裝是一樣的,就不多說了。

          但是有一個(gè)非常非常重要的,就是在數(shù)據(jù)庫安裝完之后會(huì)彈出一個(gè)框,里面有二個(gè)命令要執(zhí)行切換到root用戶下,

          su root 輸入密碼

          然后將二個(gè)命令執(zhí)行一下,有一個(gè)讓輸入fullpath ,回車就好。

          oracle就裝好了。

          在窗口中執(zhí)行sqlplus可以登陸,Ok。

          11.設(shè)置實(shí)例自啟動(dòng)
          修改/etc/oratab將所需啟動(dòng)的實(shí)例修改為Y
          oracle:/opt/oracle/product/10.2.0/db_1:Y
          12.編寫啟動(dòng)腳本(OPTION)
          為了方便管理,可以寫一個(gè)啟動(dòng)腳本ora10g:
          以root身份進(jìn)入,編寫以下腳本:
          #!/bin/bash
          #
          # chkconfig: 2345 91 19
          # description: starts the oracle listener and instance
          status() {
          pid=`ps -ef | grep ora_pmon | grep -v grep | awk '{print $8}'`
          if [ "X$pid" = "X" ]
          then
          echo "oracle10g is not running."
          exit 1
          else
          echo "oracle10g is running."
          exit 0
          fi
          }
          case "$1" in
          start)
          #startup the listener and instance
          echo -n "oracle begin to startup: "
          su - oracle -c "lsnrctl start"
          su - oracle -c dbstart
          echo "oracle10g started"
          ;;
          stop)
          # stop listener, apache and database
          echo -n "oracle begin to shutdown:"
          su - oracle -c "lsnrctl stop"
          su - oracle -c dbshut
          echo "oracle10g shutdowned"
          ;;
          reload|restart)
          $0 stop
          $0 start
          ;;
          'status')
          status
          ;;
          *)
          echo "Usage: ora10g [start|stop|reload|restart]"
          exit 1
          esac
          exit 0
          存為ora10g后,然后
          chmod a+x ora10g
          ln -s /opt/oracle/product/10.2.0/bin/ora10g /etc/rc.d/init.d/
          即可在以后以root身份運(yùn)行/etc/rc.d/init.d/ora10g start |stop 來管oracle的啟動(dòng)和停止了。
          如果要將這個(gè)腳本加入到系統(tǒng)中使其可開機(jī)運(yùn)行,那么要運(yùn)行以下命令:
          chkconfig --level 345 ora10g on

          或者可在/etc/rc.d/rc.local中加入如下:
          su - oracle -c "lsnrctl start"
          su - oracle -c "dbstart"

          安裝后還有一些配置。網(wǎng)上有好多,下面的僅供參考

          過一會(huì)兒就會(huì)出現(xiàn)Oracle的安裝界面
          注意:
          1、選擇advance install
          2、數(shù)據(jù)庫home設(shè)置為/opt/oracle/product/10g
          3、數(shù)據(jù)庫全局名稱設(shè)置為ge01
          4、數(shù)據(jù)庫字符集選Simplified Chinese ZHS16GBK

          2.其他用默認(rèn)設(shè)置!
          注意:安裝過程中會(huì)提示以root用戶登陸執(zhí)行一些腳本 ,執(zhí)行后再按“ok”按鈕繼續(xù)安裝。

          3、登陸并啟動(dòng)數(shù)據(jù)庫的操作。
          [oracle@oracle oracle]$ lsnrctl start
          [oracle@oracle oracle]$ sqlplus /nolog
          SQL*Plus: Release 9.2.0.0 - Production on Sat Mar 12 22:58:53 2005
          Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
          SQL> connect / as sysdba
          Connected.
          SQL> shutdown immediate 關(guān)閉數(shù)據(jù)庫 (OR "dbshut" command)
          Database closed.
          Database dismounted.
          ORACLE instance shut down.
          SQL> startup; 啟動(dòng)數(shù)據(jù)庫
          ORACLE instance started.
          Total System Global Area 236000356 bytes
          Fixed Size 451684 bytes
          Variable Size 201326592 bytes
          Database Buffers 33554432 bytes
          Redo Buffers 667648 bytes
          Database mounted.
          Database opened.

          4, dbstart腳本修改
          數(shù)據(jù)庫創(chuàng)建完成后,修改vi /etc/oratab,把orcl:/opt/oracle/oracle/product/10g:N那一行最后的N改成Y,
          然后執(zhí)行dbstart啟動(dòng)數(shù)據(jù)庫數(shù)據(jù)庫可能無法啟動(dòng),報(bào)告Can’t find init file …的錯(cuò)誤,需要復(fù)制一個(gè)初始化文件:
          cp /opt/oracle/admin/ge01/pfile/init.ora.* /opt/oracle/product/10.2.0/dbs/initge01.ora
          重新執(zhí)行dbstart就可以了。
          修改vi /opt/oracle/product/10g/bin/dbstart中ORACLE_HOME_LISTNER=/opt/oracle/oracle/product/10g/
          vi /etc/rc.local 加入下面一行 起動(dòng)ORACLE ON system boot
          /opt/oracel/product/10g/bin/dbstart

          5. 編寫啟動(dòng)腳本(OPTION)
          為了方便管理,可以寫一個(gè)啟動(dòng)腳本ora10g:
          以root身份進(jìn)入,編寫以下腳本:
          #!/bin/bash
          #
          # chkconfig: 2345 91 19
          # description: starts the oracle listener and instance
          status() {
          pid=`ps -ef | grep ora_pmon | grep -v grep | awk '{print $8}'`
          if [ "X$pid" = "X" ]
          then
          echo "oracle10g is not running."
          exit 1
          else
          echo "oracle10g is running."
          exit 0
          fi
          }
          case "$1" in
          start)
          #startup the listener and instance
          echo -n "oracle begin to startup: "
          su - oracle -c "lsnrctl start"
          su - oracle -c dbstart
          echo "oracle10g started"
          ;;
          stop)
          # stop listener, apache and database
          echo -n "oracle begin to shutdown:"
          su - oracle -c "lsnrctl stop"
          su - oracle -c dbshut
          echo "oracle10g shutdowned"
          ;;
          reload|restart)
          $0 stop
          $0 start
          ;;
          'status')
          status
          ;;
          *)
          echo "Usage: ora10g [start|stop|reload|restart]"
          exit 1
          esac
          exit 0
          存為ora10g后,然后
          chmod a+x ora10g
          ln -s /opt/oracle/product/10.2.0/bin/ora10g /etc/rc.d/init.d/
          即可在以后以root身份運(yùn)行/etc/rc.d/init.d/ora10g start |stop 來管oracle的啟動(dòng)和停止了。
          如果要將這個(gè)腳本加入到系統(tǒng)中使其可開機(jī)運(yùn)行,那么要運(yùn)行以下命令:
          chkconfig --level 345 ora10g on

          或者可在/etc/rc.d/rc.local中加入如下:
          su - oracle -c "lsnrctl start"
          su - oracle -c "dbstart"

          6, 關(guān)于數(shù)據(jù)庫刪除重新安裝的問題:
          把ORACLE安裝目錄刪除及/etc/ora*.*刪除就行了
          #rm –f /etc/ora*.*

          7.修改Oracle10g數(shù)據(jù)庫字符集
          SQL> connect sys/oracle as sysdba
          SQL> startup mount
          SQL> alter session set sql_trace=true;
          Session altered.
          SQL> alter system enable restricted session;
          System altered.
          SQL> alter system set job_queue_processes=0;
          System altered.
          SQL> alter system set aq_tm_processes=0;
          System altered.
          SQL> alter database open;
          Database altered.
          SQL> set linesize 120;
          SQL> alter database character set zhs16gbk;
          alter database character set zhs16gbk
          *
          ERROR at line 1:
          ORA-12712: new character set must be a superset of old character set
          SQL> ALTER DATABASE character set INTERNAL_USE zhs16gbk; # 使用INTERNAL_USE可以跳過超集的檢查,ALTER DATABASE character set INTERNAL_USE
          Database altered.
          SQL> shutdown immediate;
          Database closed.
          Database dismounted.
          ORACLE instance shut down.
          SQL> STARTUP
          SQL> select name,value$ from props$ where name like '%NLS%';
          NLS_CHARACTERSET
          ZHS16GBK

          8. oracle database備份
          (1)vi bachupDb.sh
          #!/bin/sh
          #oracle用戶下
          #crontab -e 增加 "35 4 * * * /home/oracle/dbbackup/backupDb.sh",保存后自動(dòng)安裝
          #或echo "35 4 * * * /home/oracle/dbbackup/backupDb.sh" > backupDb.cron
          #crontab backupDb.cron
          #############
          #@tip 修改為本機(jī)數(shù)據(jù)庫home目錄
          export ORACLE_HOME=/opt/oracle/product/10g
          export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
          # 注意字符集必須和數(shù)據(jù)庫的字符集一致,以避免字符集轉(zhuǎn)化失敗
          export NLS_LANG=AMERICAN_AMERICA.zhs16gbk
          #@tip 125修改為要備份的oracle的ip地址的最后一段
          dmpfile="`echo ~/`dbbackup/gedb_`date +%w`.dmp"
          logfile="`echo ~/`dbbackup/gedb_`date +%w`.log"

          if [ -w $dmpfile ]
          then
          echo "rm -f $dmpfile"
          rm -f "$dmpfile"
          fi

          #@tip ip地址修改為要備份的oracle的主機(jī)地址
          exp USERID=gedb/gedb@10.248.1.5/ge01 file=$dmpfile log=$logfile owner=gedb grants=y
          (2)copy bachupDb.sh 到slave oracle srever 相應(yīng)目錄,
          chown oracle.oinstall bachupDb.sh
          chmod 744 bachupDb.sh
          vi bachupDb.sh 以符合安裝情況
          (3)以oracle user role
          crontab -e
          35 4 * * * /home/oracle/dbbackup/backupDb.sh

          9. restore oracle backup
          su - oracle
          imp USERID=gedb/gedb file=gedb_6.dmp log=implogfile commit=y grants=y full=y

          posted on 2012-01-13 10:00 w@ns0ng 閱讀(349) 評(píng)論(0)  編輯  收藏 所屬分類: DB-oracle


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 金川县| 南宫市| 高邮市| 怀安县| 醴陵市| 攀枝花市| 从江县| 密山市| 大悟县| 原阳县| 郴州市| 蒙自县| 新疆| 宜君县| 佳木斯市| 龙口市| 扬中市| 栾川县| 赣州市| 福鼎市| 和林格尔县| 百色市| 松江区| 霍邱县| 清苑县| 阳泉市| 横山县| 鹤山市| 天镇县| 北碚区| 常州市| 芦山县| 杭州市| 河源市| 江口县| 确山县| 探索| 哈尔滨市| 奎屯市| 沽源县| 阿拉善盟|