您好,登錄后才能下訂單哦!
一、安裝Oracle 11G前環境搭建
本次實驗是基于Linux(CentOS6.7_64)下搭建oracle 11g環境,這里選擇CentOS安裝oracle并不是最佳選擇,可以根據需要選擇不同的Linux發行版,如Oracle Linux、SuSE Linux、Red Hat、IBM AIX等。
VM或物理機的配置要求:
在實驗環境安裝oracle11g最少需要2G內存、2個cpu、2G交換分區、磁盤空間不低于20G。
生產環境中,要保證oracle的性能,建議最低配置為8G內存、4個cpu、8G交換分區,如果生產環境比較繁忙,則需要更高的配置。
二、安裝Oracle 11G前準備工作
上傳oracle11g安裝包,解壓
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
配置/etc/hosts文件,添加ip與主機名的解析
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #eth0 10.11.12.88 hm
創建oracle相關用戶和組
[root@hm ~]# groupadd dba [root@hm ~]# groupadd oinstall [root@hm ~]# useradd -g oinstall -G dba -m oracle [root@hm ~]# id oracle uid=500(oracle) gid=501(oinstall) groups=501(oinstall),500(dba)
創建oracle軟件安裝目錄
[root@hm ~]# mkdir /u01/app/oracle -p [root@hm ~]# chown -R oracle. /u01/ [root@hm ~]# chmod 775 -R /u01/ [root@hm ~]# ls -ld /u01/ drwxr-xr-x. 3 oracle oinstall 4096 Oct 14 22:58 /u01/
oracle用戶環境變量設置,su進入oracle用戶下,修改~/.bash_profile文件,添加以下內容
export TMP=/tmp export TMPDIR=$TMP export ORACLE_TERM=xterm export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/db export ORACLE_SID=orcl export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/lib64 if [ $USER = "oracle" ];then if [ $SHELL = "/bin/ksh" ];then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
修改內核參數,打開/etc/sysctl.conf文件,添加以下參數,并修改/etc/security/limits.conf文件
kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500 fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 [root@hm ~]# sysctl -p net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500 fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 在/etc/security/limits.conf文件末尾添加如下內容 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 4096 oracle hard nofile 65536 并同時修改/etc/pam.d/login文件,添加以下內容 session required pam_limits.so
安裝oracle依賴的軟件包
[root@hm ~]# yum install gcc gcc-c++ libaio glibc compat-libstdc++-33 elfutils-libelf-devel libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel glibc-common ksh make sysstat pdksh [root@hm ~]# yum install glibc-2.12-1.192.el6.i686 檢查是否安裝 [root@hm ~]# for i in gcc gcc-c++ libaio glibc compat-libstdc++-33 elfutils-libelf-devel libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel glibc-common ksh make sysstat pdksh;do rpm -q $i;done |
三、安裝oracle11g軟件
解壓oracle11g軟件包
[root@hm oracle]# unzip linux.x64_11gR2_database_1of2.zip
[root@hm oracle]# unzip linux.x64_11gR2_database_2of2.zip
[root@hm oracle]# chown -R oracle. database/ [root@hm oracle]# ls -l database/ total 36 drwxr-xr-x. 12 oracle oinstall 4096 Aug 17 2009 doc drwxr-xr-x. 4 oracle oinstall 4096 Aug 15 2009 install drwxrwxr-x. 2 oracle oinstall 4096 Aug 15 2009 response drwxr-xr-x. 2 oracle oinstall 4096 Aug 15 2009 rpm -rwxr-xr-x. 1 oracle oinstall 3226 Aug 15 2009 runInstaller drwxrwxr-x. 2 oracle oinstall 4096 Aug 15 2009 sshsetup drwxr-xr-x. 14 oracle oinstall 4096 Aug 15 2009 stage -rw-r--r--. 1 oracle oinstall 5402 Aug 18 2009 welcome.html
以orcle用戶登錄圖形界面安裝oracle,也可以使用vnc遠程安裝。這里直接用Xshell遠程調用linux圖形界面進行安裝
[root@hm ~]# su - oracle [oracle@hm ~]$ export DISPLAY=10.11.12.1:0.0 [oracle@hm ~]$ xhost +
進入database目錄,執行runInstalle
[oracle@hm ~]$ cd /usr/local/src/oracle/database/ [oracle@hm database]$ ./runInstaller Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 21645 MB Passed Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-10-15_12-48-55PM. Please wait ...
進入圖形界面安裝
[root@hm ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete. [root@hm ~]# /u01/app/oracle/db/root.sh Running Oracle 11g root.sh script... The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /u01/app/oracle/db Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. Finished product-specific root actions.
啟動監聽
[oracle@hm ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-OCT-2016 23:30:07 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /u01/app/oracle/db/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production Log messages written to /u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 15-OCT-2016 23:30:09 Uptime 0 days 0 hr. 0 min. 1 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) The listener supports no services The command completed successfully
創建數據庫實例,oracle用戶下使用dbca工具創建
[oracle@hm ~]$ dbca
安裝完成檢查,查看oracle進程與監聽狀態
[oracle@hm ~]$ ps -ef | grep ora_ oracle 6636 1 0 23:41 ? 00:00:00 ora_pmon_orcl oracle 6638 1 0 23:41 ? 00:00:04 ora_vktm_orcl oracle 6642 1 0 23:41 ? 00:00:00 ora_gen0_orcl oracle 6644 1 0 23:41 ? 00:00:00 ora_diag_orcl oracle 6646 1 0 23:41 ? 00:00:00 ora_dbrm_orcl oracle 6648 1 0 23:41 ? 00:00:00 ora_psp0_orcl oracle 6650 1 0 23:41 ? 00:00:05 ora_dia0_orcl oracle 6652 1 0 23:41 ? 00:00:00 ora_mman_orcl oracle 6654 1 0 23:41 ? 00:00:00 ora_dbw0_orcl oracle 6656 1 0 23:41 ? 00:00:00 ora_lgwr_orcl oracle 6658 1 0 23:41 ? 00:00:00 ora_ckpt_orcl oracle 6660 1 0 23:41 ? 00:00:00 ora_smon_orcl oracle 6662 1 0 23:41 ? 00:00:00 ora_reco_orcl oracle 6664 1 0 23:41 ? 00:00:02 ora_mmon_orcl oracle 6666 1 0 23:41 ? 00:00:02 ora_mmnl_orcl oracle 6668 1 0 23:41 ? 00:00:00 ora_d000_orcl oracle 6670 1 0 23:41 ? 00:00:00 ora_s000_orcl oracle 6719 1 0 23:41 ? 00:00:00 ora_qmnc_orcl oracle 6739 1 0 23:41 ? 00:00:01 ora_cjq0_orcl oracle 6832 1 0 23:41 ? 00:00:00 ora_q000_orcl oracle 6834 1 0 23:41 ? 00:00:00 ora_q001_orcl oracle 6842 1 0 23:42 ? 00:00:00 ora_smco_orcl oracle 6844 1 0 23:42 ? 00:00:00 ora_w000_orcl oracle 15858 2208 0 23:59 pts/0 00:00:00 grep ora_ [oracle@hm ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-OCT-2016 23:59:58 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 15-OCT-2016 23:30:09 Uptime 0 days 0 hr. 29 min. 50 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/diag/tnslsnr/hm/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hm)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
登錄oracle數據庫,查看數據庫實例狀態、實例名、數據庫文件、日志文件
SQL> select status from v$instance; STATUS ------------ OPEN SQL> select name from v$database; NAME --------- ORCL SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/users01.dbf SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/redo03.log /u01/app/oracle/oradata/orcl/redo02.log /u01/app/oracle/oradata/orcl/redo01.log
查看oracle數據庫版本
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production
關閉與啟動
關閉數據庫實例
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down.
關閉監聽
[oracle@hm ~]$ lsnrctl stop LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-OCT-2016 00:16:41 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) The command completed successfully [oracle@hm ~]$ ps -ef | grep ora_ oracle 16987 2208 0 00:17 pts/0 00:00:00 grep ora_
啟動監聽
[oracle@hm ~]$ lsnrctl start
啟動實例
[oracle@hm ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Sun Oct 16 00:19:39 2016 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL> startup; ORACLE instance started. Total System Global Area 780824576 bytes Fixed Size 2217424 bytes Variable Size 599788080 bytes Database Buffers 171966464 bytes Redo Buffers 6852608 bytes Database mounted. Database opened. SQL> select status from v$instance; STATUS ------------ OPEN
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。