Centos6.7安裝oracle11gR2及配置開機啓動、新建表空間和用戶、導入數據

 

Centos6.7安裝oracle11gR2及配置開機啓動、新建表空間和用戶、導入數據


目錄(?)[+]

版本:

Centos6.7(桌面版);oracle11gR2(兩個壓縮包);jdk1.7


1. 軟件準備:

0. Centos系統要求:
1)內存(RAM) 2GB+
2)虛擬內存 swap 建議:內存爲 2GB~16GB 時swap大小爲內存的大小;內存超過 16GB 時swap保持16GB

1. Centos6.7桌面版安裝好後,默認已經安裝了openjdk,所以需要自己再安裝個oracle,比如下面的:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. java version "1.7.0_55"  
  2. Java(TM) SE Runtime Environment (build 1.7.0_55-b13)  
  3. Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)  

2. Centos6.7桌面版安裝好後,配置yum源,直接使用的是安裝盤iso掛載:
/etc/yum.repos.d/CentOS-Media.repo:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. [c6-media]  
  2. name=CentOS-$releasever - Media  
  3. baseurl=file:///media/CentOS_6.7_Final  
  4. gpgcheck=0  
  5. enabled=1  
  6. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  
3. 下載oracle11g的安裝文件,並拷貝到/opt目錄下面:
解壓縮後生成database文件夾,解壓縮命令: unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_1of2.zip ;  (unzip 是centos系統自帶的);

4. 安裝需要的編譯軟件gcc
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. yum install gcc -y  

5. 安裝org,這個不一定需要,不過我安裝了(應該不需要安裝):
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. yum install xorg-x11-app* -y  

2. 安裝oracle

1. 新建oracle用戶及組
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. groupadd oracle  
  2. useradd -g oracle -s /bin/bash oracle -m  

2. 新建oracle安裝目錄並指定oracle權限
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. mkdir /usr/oracle  
  2. chmod -R oracle:oracle /usr/oracle  

3. 進入/opt/database目錄執行:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. su oracle  
  2. ./runInstaller  

4. 出現NoClassDefFoundError的錯誤

1)退出oracle用戶;返回root用戶
2)分別執行:
     DISPLAY=:0.0
     export DISPLAY
     xhost +
3) 進入oracle用戶: su oracle
4) 執行     
      DISPLAY=:0.0
     export DISPLAY
5) 然後再次執行安裝命令 ./runInstaller 即可;

5. 安裝過程中出現錯誤,經查看後,如果沒有影響,可以選擇Continue;

6. 安裝好後,oracle應該是已經啓動了的,可以直接使用連接工具連接,檢驗是否可以連接;(在安裝的過程的最後兩步會有需要使用root權限執行的腳本,需要使用root執行);

3.配置oracle開機啓動

使用root用戶進行下面的操作
1. 配置/etc/oratab 
修改最後的N爲Y,如下:

2. 添加文件:vim /etc/rc.d/init.d/oracle

[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. #!/bin/bash  
  2. # description: Startup Script for Oracle Databases  
  3. # /etc/init.d/oracle  
  4. export ORACLE_SID=orcl.centos.com  
  5. export ORACLE_BASE=/usr/oracle  
  6. export ORACLE_HOME=/usr/oracle/app/oracle/product/11.2.0/dbhome_1  
  7. export PATH=$PATH:$ORACLE_HOME/bin  
  8. case "$1" in  
  9. start)  
  10. su oracle -c $ORACLE_HOME/bin/dbstart  
  11. touch /var/lock/oracle  
  12. echo "OK"  
  13. ;;  
  14. stop)  
  15. echo -n "Shutdown Oracle: "  
  16. su oracle -c $ORACLE_HOME/bin/dbshut  
  17. rm -f /var/lock/oracle  
  18. echo "OK"  
  19. ;;  
  20. *)  
  21. echo "Usage: 'basename $0' start|stop"  
  22. exit 1  
  23. esac  
  24. exit 0  

注意修改ORACLE_SID 以及 oracle_base 、oracle_home的路徑

修改權限: chmod 777 /etc/rc.d/init.d/oracle

3. 添加oracle服務
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. chkconfig --add /etc/rc.d/init.d/oracle   
  2. chkconfig oracle on  

4. 開機重啓,再次使用客戶端連接oracle查看是否開機啓動;

4. 新建表空間及用戶

1. 新建表空間,比如我要建立的表空間是test_my
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1.      create tablespace test_my    
  2.      datafile '/home/app/oracle/oradata/oracle11g/test_my01.dbf' size 800M    
  3.      autoextend on    
  4.     next 50M    
  5. maxsize unlimited  

2. 因爲有時數據過大,需要添加文件,可以使用:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. alter tablespace test_my add    
  2. datafile '/home/app/oracle/oradata/oracle11g/test_my02.dbf' size 800M    
  3.  autoextend on next 50M    
  4.   
  5. axsize 1000M;   

3. 新建用戶,例如test_user:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. create user test_user identified by test_user default tablespace test_my;  

4. 爲test_user 授權dba權限
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. grant  dba to test_user;  

5. 導入/導出數據

導出:(user代表用戶,password代碼密碼,ip即oracle服務器ip,database即oracle的SID,file可以自己指定路徑)
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. Exp user/password@ip:1521/database file=/opt/test.dmp  
導入:
[html] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. imp user/password@ip:1521/database file =/opt/test.dmp fromuser=test_user touser=test_user ignore=y  



分享,成長,快樂

腳踏實地,專注

轉載請註明blog地址:http://blog.csdn.net/fansy1990

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章