本文谢绝转载原文来自

系统属性:

CentOS 6.8_X64,基于桌面,附加开发工具包安装.

Oracle Database 12c R1,12c R1, 11g R2  安装包

Oracle Database 12c R1,12c R1, 11g R2 帮助文档,可下载

Oracle 客户端,开发环境

X86       

X86_64 

上传Oracle11g安装文件到:/usr/local/oracle/

[root@oracle11 home]# mkdir -pv /usr/local/oraclemkdir: created directory `/usr/local/oracle'[root@oracle11 oracle]# ll /usr/local/oracle/total 2985244-rw-r--r--. 1 root root 1239269270 Aug 28 20:23 linux.x64_11gR2_database_1of2.zip-rw-r--r--. 1 root root 1111416131 Aug 28 20:24 linux.x64_11gR2_database_2of2.zip[root@oracle11 oracle]#

准备oracle的安装目标目录[重要]

[root@oracle11 oracle]# mkdir –p /opt/oracle

创建oracle相关用户和用户组

[root@oracle11 oracle]# groupadd dba[root@oracle11 oracle]# groupadd oinstall[root@oracle11 oracle]# useradd -g oinstall -G dba oracle[root@oracle11 oracle]# passwd oracleChanging password for user oracle.New password: oracleRetype new password:oracle passwd: all authentication tokens updated successfully.[root@oracle11 oracle]# chown -R oracle:oinstall /opt/oracle[root@oracle11 oracle]# ll /opt/oracle -ddrwxr-xr-x. 2 oracle oinstall 4096 Aug 28 20:27 /opt/oracle

检查安装ORACLE依赖的RPM软件包

[root@oracle11 oracle]# mkdir /mnt/cdrom[root@oracle11 oracle]# mount /dev/cdrom  /mnt/cdrom/[root@oracle11 Packages]# cd /mnt/cdrom/Packages[root@oracle11 Packages]# rpm -ivh kernel-headers-2.6.18-164.el5.i386.rpm[root@oracle11 Packages]# rpm -ivh glibc-headers-2.5-42.i386.rpm[root@oracle11 Packages]# rpm -ivh glibc-devel-2.5-42.i386.rpm[root@oracle11 Packages]# rpm -ivh libgomp-4.4.0-6.el5.i386.rpm|[root@oracle11 Packages]# rpm -ivh sysstat-7.0.2-3.el5.i386.rpm[root@oracle11 Packages]# rpm -ivh libaio-devel-0.3.106-3.2.i386.rpm[root@oracle11 Packages]# rpm -ivh libstdc++-devel-4.1.2-46.el5.i386.rpm[root@oracle11 Packages]# rpm -ivh unixODBC-2.2.11-7.1.i386.rpm[root@oracle11 Packages]# rpm -ivh unixODBC-devel-2.2.11-7.1.i386.rpm[root@oracle11 Packages]# rpm -ivh gcc-4.1.2-46.el5.i386.rpm[root@oracle11 Packages]# rpm -ivh gcc-c++-4.1.2-46.el5.i386.rpm[root@oracle11 Packages]# rpm -ivh elfutils-libelf-devel-0.137-3.el5.i386.rpm [root@oracle11 Packages]# rpm -ivh elfutils-libelf-devel-static-0.137-3.el5.i386.rpm|如果找不到elfutils-libelf-devel-static, yum install elfutils-libelf-devel-static如果找不到libgomp ,yum install libgomp

设置linux内核参数

[root@oracle11 Packages]# vim /etc/sysctl.conf 在最后面添加#kernel.shmall = 4294967296#kernel.shmall = 2097152kernel.shmmax = 2147483648kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.core.rmem_default = 4194304net.core.rmem_max = 4194304net.core.wmem_default = 262144fs.file-max = 6815744net.ipv4.ip_local_port_range = 9000 65500net.core.wmem_max = 1048576fs.aio-max-nr = 1048576[root@oracle11 Packages]# vim /etc/security/limits.conf 在最后面添加oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536[root@oracle11 Packages]# vim /etc/profile在最后面添加 if [ $USER = "oracle" ]; then    if [ $SHELL = "/bin/bash" ]; then        ulimit -p 16384        ulimit -n 65536    else        ulimit -u 16384 -n 65536    fifi

重新启动系统,开始安装过程

[root@oracle11 ~]# reboot[root@oracle11 ~]# chown -R oracle: /usr/local/oracle/[root@oracle11 ~]# su oracle[oracle@oracle11 oracle]$ cd /usr/local/oracle/[oracle@oracle11 oracle]$ unzip linux.x64_11gR2_database_1of2.zip [oracle@oracle11 oracle]$ unzip linux.x64_11gR2_database_2of2.zip [oracle@oracle11 oracle]$ cd database/[oracle@oracle11 database]$ ./runInstaller 开始加载图形安装程序.......................

高清大图:

在这里,会自动找到我为oracle分配的安装路径

提示找不到依赖库,其实我们都全部安装了,

# rpm -q 包名,是可以查出来我已经安装了的

漫长的等待...................

安装完成:

oracle安装的位置:/opt/oracle/

oracle11g的位置:/opt/oracle/app/product/11.2.0/dbhome_1/

设置ORACLE环境变量

[oracle@oracle11 ~]$ cat /home/oracle/.bashrc 添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/app/product/11.2.0/dbhome_1/lib/PATH=$PATH:/opt/oracle/app/product/11.2.0/dbhome_1/bin/export ORACLE_HOME=/opt/oracle/app/product/11.2.0/dbhome_1/export ORACLE_SID=orclexport ORACLE_BASE=/home/oracle/oracle

查看pro*C/C++编译器情况:

[oracle@oracle11 ~]$ procPro*C/C++: Release 11.2.0.1.0 - Production on Sun Aug 28 23:31:48 2016Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.System default option values taken from: /opt/oracle/app/product/11.2.0/dbhome_1/precomp/admin/pcscfg.cfgOption Name    Current Value  Description-------------------------------------------------------------------------------auto_connect   no             Allow automatic connection to ops$ accountchar_map       charz          Mapping of character arrays and stringsclose_on_commitno             Close all cursors on COMMITcmax           100            CMAX Value for connection poolcmin           2              CMIN Value for connection poolcincr          1              CINCR Value for connection poolctimeout       0              CTIMEOUT Value for connection poolcnowait        0              CNOWAIT Value for connection poolcommon_parser  no             Parse using Common SQL Front Endcode           kr_c           The type of code to be generatedcomp_charset   multi_byte     The character set type the C compiler supportsconfig         default        Override system configuration file with anothercpool          no             Support connection poolingcpp_suffix     *none*         Override the default C++ filename suffixdb2_array      no             Support DB2 array insert/select syntaxdbms           native         v6/v7/v8 compatibility modedef_sqlcode    no             Generate '#define SQLCODE sqlca.sqlcode' macrodefine         __x86_64__     Define a preprocessor symbol               *none*                                                           duration       transaction    Set pin duration for objects in the cachedynamic        oracle         Specify Oracle or ANSI Dynamic SQL Semanticserrors         yes            Whether error messages are sent to the terminalerrtype        *none*         Name of the list file for intype file errorsevents         no             Support publish-subscribe event notificationsfips           none           FIPS flagging of ANSI noncompliant usageheader         *none*         Specify file extension for Precompiled Headershold_cursor    no             Control holding of cursors in the cursor cacheimplicit_svpt  no             Implicit savepoint prior to buffered insertiname          *none*         The name of the input fileinclude        *none*         Directory paths for included filesintype         *none*         The name of the input file for type informationlines          no             Add #line directives to the generated codelname          *none*         Override default list file nameltype          short          The amount of data generated in the list filemaxliteral     1024           Maximum length of a generated string literalmaxopencursors 10             Maximum number of cached open cursorsmax_row_insert 0              Maximum number of rows to buffer on insertmode           oracle         Code conformance to Oracle or ANSI rulesnative_types   no             Support for native float/doublenls_char       *none*         Specify National Language character variablesnls_local      no             Control how NLS character semantics are doneobjects        yes            Support object typesoname          *none*         The name of the output fileoraca          no             Control the use of the ORACAoutline        no             Category in which Outlines are created                               [yes/no/
]outlnprefix    *none*         Outline name prefixpagelen        80             The page length of the list fileparse          full           Control which non-SQL code is parsedprefetch       1              Number of rows pre-fetched at cursor OPEN timerelease_cursor no             Control release of cursors from cursor cacherunoutline     no             If yes, create Outlines in the Databaseselect_error   yes            Control flagging of select errorssqlcheck       syntax         Amount of compile-time SQL checkingstmt_cache     0              Size of statement cachesys_include    /usr/lib64/gcc/Directory where system header files are found               /usr/lib64/gcc/x86_64-suse-linux/4.1.0/include                                  /usr/lib/gcc/x86_64-redhat-linux/4.1.1/include                                  /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/include                              /usr/include                                                                    $ORACLE_HOME/precomp/public                                      threads        no             Indicates a multi-threaded applicationtype_code      oracle         Use Oracle or ANSI type codes for Dynamic SQLunsafe_null    no             Allow a NULL fetch without indicator variableuserid         *none*         A username/password [@dbname] connect stringutf16_charset  nchar_charset  The character set form used by UTF16 variablesvarchar        no             Allow the use of implicit varchar structuresversion        recent         Which version of an object is to be returnedPCC-F-02135, CMD-LINE:  User asked for help[oracle@oracle11 ~]$

监听服务启动/关闭

[oracle@oracle11 ~]$ lsnrctl start/stop

数据库服务的启动/关闭

[oracle@oracle11 root]$ sqlplus /nologSQL> conn /as sysdbaSQL> startup  开启SQL> shutdown immediate 关闭SQL> conn scott 切换到scott用户SQL> conn scott/password 切换到scott用户

如果数据库服务启动时报错

SQL> startupORA-00845: MEMORY_TARGET not supported on this system[临时解决办法][root@oracle11 ~]# mount -o remount,size=4G /dev/shm[永久解决方法][root@oracle11 ~]# vim /etc/fstabtmpfs                   /dev/shm                tmpfs   defaults,size=4096M 0 0[root@oracle11 ~]# reboot

sqlplus操作,增删改查:

 SQLplus连接远程数据库 sqlplus username/password@OracleIP/OracleSID sqlplus username/password@OracleIP:Port/OracleSID sqlplus sys/123@OracleIP:Port/OracleSID as sysdba  [oracle@oracle11 ~]$ sqlplus Enter user-name: scottEnter password: tigerChanging password for scottNew password: hahaRetype new password:haha SQL> select * from tab;     TNAME			       TABTYPE	CLUSTERID------------------------------ ------- ----------BONUS			       TABLEDEPT			       TABLEEMP			       TABLESALGRADE		       TABLE

ed命令的使用

SQL> ed

Wrote file afiedt.buf

20

写好按q

[root@oracle11 ~]# vim /home/oracle/afiedt.buf