oracle 12c 安装

来源:互联网 发布:2016年中国m2数据 编辑:程序博客网 时间:2024/06/05 03:49

下载地址:

http://www.oracle.com/cn/products/database/enterprise-edition/overview/index.html#ct02-Download


下面是以手动方式去做好了预安装配置,下面分享下。

1、安装OEL 6.4
安装步骤略,安装后系统情况如下:

[root@khm00 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.4 (Santiago)内存分配情况:[root@12c ~]# grep MemTotal /proc/meminfoMemTotal:        3515540 kBSwap空间大小,Swap空间我设小了,后面在校验的时候会出现提示。[root@12c ~]# grep SwapTotal /proc/meminfoSwapTotal:       3063804 kBtmp临时目录大小:[root@12c ~]# df -h /tmpFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/vg_12c-lv_root                       50G  4.9G   42G  11% /磁盘分配信息:[root@12c ~]# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/vg_12c-lv_root                       50G  5.1G   42G  11% /tmpfs                 1.7G  260K  1.7G   1% /dev/shm/dev/sda1             485M   55M  405M  12% /boot/dev/mapper/vg_12c-lv_home                      6.5G  143M  6.1G   3% /home/dev/sr0              3.5G  3.5G     0 100% /media/OL6.4 x86_64 Disc 1 20130225/dev/sr0              3.5G  3.5G     0 100% /mnt[root@12c ~]# uname -mx86_64

 

2、下载上传介质
从官方网站下载Oracle12c安装介质,并上传到刚刚安装好的OEL 6.4服务器上。
介质如下:
linuxamd64_12c_database_1of2.zip
linuxamd64_12c_database_2of2.zip

另外还上传一个rlwrap-0.37-1.el6.x86_64.rpm,并安装:

[root@12c ~]# rpm -ivh /install/rlwrap-0.37-1.el6.x86_64.rpm 

3、配置/etc/hosts
修改/etc/hosts文件,前两行不懂,添加hostname对应信息。

[root@12c ~]# cat /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.35    12c.luocs.com   12c

4、系统配置
修改/etc/sysctl.conf,添加如下内容:

fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
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

生效:
sysctl -p

修改/etc/security/limits.conf,添加如下内容:

oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    2047
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768

5、配置YUM源并安装所需包
先将默认的yum配置文件删除或者移动,然后创建一个新的

[root@12c ~]# cd /etc/yum.repos.d[root@12c yum.repos.d]# mkdir bk[root@12c yum.repos.d]# mv public-yum-ol6.repo bk/[root@12c yum.repos.d]# vi luocs.repo -- 添加如下内容[Oracle]name=OEL-$releasever - Mediabaseurl=file:///mntgpgcheck=0enabled=1将光驱挂载上[root@12c yum.repos.d]# mount /dev/cdrom /mntmount: block device /dev/sr0 is write-protected, mounting read-only下面就可以Yum方式安装所需包了[root@12c yum.repos.d]# yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC unixODBC-devel pdksh

下面给出官方文档中Linux 6所需要具备的包:

binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (i686)
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (i686)
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (i686)
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6 (i686)
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6 (i686)
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6 (i686)
libXext-1.1 (x86_64)
libXext-1.1 (i686)
libXtst-1.0.99.2 (x86_64)
libXtst-1.0.99.2 (i686)
libX11-1.3 (x86_64)
libX11-1.3 (i686)
libXau-1.0.5 (x86_64)
libXau-1.0.5 (i686)
libxcb-1.5 (x86_64)
libxcb-1.5 (i686)
libXi-1.3 (x86_64)
libXi-1.3 (i686)
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)
加上UnixODBC Driver Manager:
unixODBC-2.2.14-11.el6 (64-bit) or later
unixODBC-devel-2.2.14-11.el6 (64-bit) or later

6、创建用户和组

创建组:[root@12c ~]# /usr/sbin/groupadd -g 54321 oinstall[root@12c ~]# /usr/sbin/groupadd -g 54322 dba[root@12c ~]# /usr/sbin/groupadd -g 54323 oper[root@12c ~]# /usr/sbin/groupadd -g 54324 backupdba[root@12c ~]# /usr/sbin/groupadd -g 54325 dgdba创建用户:[root@12c ~]#  /usr/sbin/useradd -u 54321 -g oinstall -G dba,backupdba,dgdba oracle[root@12c ~]# passwd oracle

7、确定防火墙和SELinux是禁用的

[root@12c ~]# iptables -LChain INPUT (policy ACCEPT)target     prot opt source               destination         Chain FORWARD (policy ACCEPT)target     prot opt source               destination         Chain OUTPUT (policy ACCEPT)target     prot opt source               destination  如果防火墙没禁用,那么通过如下方式修改:[root@12c ~]# service iptables stop[root@12c ~]# chkconfig iptables off[root@12c ~]# getenforce Disabled如果SELinux没有被禁止,那就通过如下方式修改:[root@12c ~]# cat /etc/selinux/config -- 改成SELINUX=disabled# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:#     targeted - Targeted processes are protected,#     mls - Multi Level Security protection.SELINUXTYPE=targeted

8、创建安装目录以及授权

[root@12c ~]# mkdir -p /u01/app/oracle/product/12.1.0/db_1[root@12c ~]# chown -R oracle:oinstall /u01[root@12c ~]# chmod -R 775 /u01

 
9、配置oracle环境变量

[oracle@12c ~]$ vi .bash_profile export PATHexport TMP=/tmpexport TMPDIR=$TMP      export ORACLE_HOSTNAME=12c.luocs.comexport ORACLE_UNQNAME=luocs12cexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1export ORACLE_SID=luocs12cexport PATH=/usr/sbin:$PATHexport PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/libexport CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlibalias sqlplus="rlwrap sqlplus"alias rman="rlwrap rman"

 
10、解压介质

[root@12c ~]# chown -R oracle.oinstall /install/[root@12c ~]# su - oracle[oracle@12c ~]$ cd /install/[oracle@12c install]$ unzip linuxamd64_12c_database_1of2.zip [oracle@12c install]$ unzip linuxamd64_12c_database_2of2.zip 解压之后大小为:[oracle@12c install]$ du -sh database/2.6G    database/

11、安装

[oracle@12c database]$ pwd/install/database我打开Xmanager - Passive,设置DISPLAY,调用runInstaller启动OUI[oracle@12c database]$ export DISPLAY=192.168.1.1:0.0[oracle@12c database]$ ./runInstaller 

 
 

 

我首次安装选择了第一项,安装完软件之后接着创建输数据库

注意,Global database name不能以数字开头,需要设置高强度密码,大小写+数字

这里校验的时候提示Swap空间大小不够大,忽略也可完成

[root@12c ~]# /u01/app/oraInventory/orainstRoot.shChanging 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@12c ~]# /u01/app/oracle/product/12.1.0/db_1/root.shPerforming root user operation for Oracle 12c The following environment variables are set as:    ORACLE_OWNER= oracle    ORACLE_HOME=  /u01/app/oracle/product/12.1.0/db_1Enter 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 byDatabase Configuration Assistant when a database is createdFinished running generic part of root script.Now product-specific root actions will be performed.

等软件安装完毕之后紧接着创建数据库

 


12、最后
查看进程,发现进程多了很多,新增进程以后慢慢去了解

[oracle@12c ~]$ ps -ef | grep ora_oracle    6623     1  0 22:21 ?        00:00:00 ora_pmon_luocs12coracle    6625     1  0 22:21 ?        00:00:00 ora_psp0_luocs12coracle    6627     1  2 22:21 ?        00:00:14 ora_vktm_luocs12coracle    6631     1  0 22:21 ?        00:00:00 ora_gen0_luocs12coracle    6633     1  0 22:21 ?        00:00:00 ora_mman_luocs12coracle    6637     1  0 22:21 ?        00:00:00 ora_diag_luocs12coracle    6639     1  0 22:21 ?        00:00:00 ora_dbrm_luocs12coracle    6641     1  0 22:21 ?        00:00:00 ora_dia0_luocs12coracle    6643     1  0 22:21 ?        00:00:01 ora_dbw0_luocs12coracle    6645     1  0 22:21 ?        00:00:00 ora_lgwr_luocs12coracle    6647     1  0 22:21 ?        00:00:01 ora_ckpt_luocs12coracle    6649     1  0 22:21 ?        00:00:01 ora_lg00_luocs12coracle    6651     1  0 22:21 ?        00:00:00 ora_lg01_luocs12coracle    6653     1  0 22:21 ?        00:00:00 ora_smon_luocs12coracle    6655     1  0 22:21 ?        00:00:00 ora_reco_luocs12coracle    6657     1  0 22:21 ?        00:00:00 ora_lreg_luocs12coracle    6659     1  0 22:21 ?        00:00:02 ora_mmon_luocs12coracle    6661     1  0 22:21 ?        00:00:01 ora_mmnl_luocs12coracle    6663     1  0 22:21 ?        00:00:00 ora_d000_luocs12coracle    6665     1  0 22:21 ?        00:00:00 ora_s000_luocs12coracle    6677     1  0 22:21 ?        00:00:00 ora_tmon_luocs12coracle    6679     1  0 22:21 ?        00:00:00 ora_tt00_luocs12coracle    6681     1  0 22:21 ?        00:00:00 ora_smco_luocs12coracle    6683     1  0 22:21 ?        00:00:00 ora_aqpc_luocs12coracle    6687     1  1 22:21 ?        00:00:12 ora_p000_luocs12coracle    6689     1  2 22:21 ?        00:00:15 ora_p001_luocs12coracle    6691     1  0 22:21 ?        00:00:01 ora_p002_luocs12coracle    6693     1  0 22:21 ?        00:00:01 ora_p003_luocs12coracle    6695     1  0 22:21 ?        00:00:03 ora_p004_luocs12coracle    6697     1  0 22:22 ?        00:00:01 ora_p005_luocs12coracle    6699     1  0 22:22 ?        00:00:00 ora_p006_luocs12coracle    6701     1  0 22:22 ?        00:00:00 ora_p007_luocs12coracle    6703     1  0 22:22 ?        00:00:00 ora_p008_luocs12coracle    6705     1  0 22:22 ?        00:00:00 ora_p009_luocs12coracle    6707     1  0 22:22 ?        00:00:00 ora_p00a_luocs12coracle    6709     1  0 22:22 ?        00:00:00 ora_p00b_luocs12coracle    6711     1  0 22:22 ?        00:00:00 ora_p00c_luocs12coracle    6713     1  0 22:22 ?        00:00:00 ora_p00d_luocs12coracle    6715     1  0 22:22 ?        00:00:00 ora_p00e_luocs12coracle    6717     1  0 22:22 ?        00:00:00 ora_p00f_luocs12coracle    6719     1  0 22:22 ?        00:00:01 ora_w000_luocs12coracle    6749     1  1 22:22 ?        00:00:09 ora_cjq0_luocs12coracle    6754     1  0 22:22 ?        00:00:00 ora_p00g_luocs12coracle    6756     1  0 22:22 ?        00:00:00 ora_p00h_luocs12coracle    6758     1  0 22:22 ?        00:00:00 ora_qm02_luocs12coracle    6762     1  0 22:22 ?        00:00:01 ora_q002_luocs12coracle    6764     1  0 22:22 ?        00:00:00 ora_q003_luocs12coracle    6788     1  0 22:23 ?        00:00:00 ora_p00i_luocs12coracle    6790     1  0 22:23 ?        00:00:00 ora_p00j_luocs12coracle    6792     1  0 22:23 ?        00:00:01 ora_w001_luocs12coracle    6855     1  0 22:26 ?        00:00:00 ora_p00k_luocs12coracle    6857     1  0 22:26 ?        00:00:00 ora_p00l_luocs12coracle    6888     1  0 22:30 ?        00:00:00 ora_w002_luocs12c

如下方式可以访问OEM Database Express 12c:
https://192.168.1.35:5500/em/login

SQL> COL PRODUCT FORMAT A40SQL> COL VERSION FORMAT A15SQL> COL STATUS FORMAT A15 SQL> SELECT * FROM PRODUCT_COMPONENT_VERSION;PRODUCT                                  VERSION         STATUS---------------------------------------- --------------- ---------------NLSRTL                                   12.1.0.1.0      ProductionOracle Database 12c Enterprise Edition   12.1.0.1.0      64bit Productio                                                         nPL/SQL                                   12.1.0.1.0      ProductionTNS for Linux:                           12.1.0.1.0      ProductionSQL> set line 150 pages 9999SQL> select * from v$version;BANNER                                                                               CON_ID-------------------------------------------------------------------------------- ----------Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0PL/SQL Release 12.1.0.1.0 - Production                                                    0CORE    12.1.0.1.0      Production                                                                0TNS for Linux: Version 12.1.0.1.0 - Production                                            0NLSRTL Version 12.1.0.1.0 - Production                                                    0[oracle@12c ~]$ lsnrctl statusLSNRCTL for Linux: Version 12.1.0.1.0 - Production on 26-JUN-2013 22:44:44Copyright (c) 1991, 2013, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 12.1.0.1.0 - ProductionStart Date                26-JUN-2013 22:09:51Uptime                    0 days 0 hr. 34 min. 53 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.oraListener Log File         /u01/app/oracle/diag/tnslsnr/12c/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=12c.luocs.com)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=12c.luocs.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/luocs12c/xdb_wallet))(Presentation=HTTP)(Session=RAW))Services Summary...Service "luocs12c" has 1 instance(s).  Instance "luocs12c", status READY, has 1 handler(s) for this service...Service "luocs12cXDB" has 1 instance(s).  Instance "luocs12c", status READY, has 1 handler(s) for this service...Service "pdbluocs12c" has 1 instance(s).  Instance "luocs12c", status READY, has 1 handler(s) for this service... The command completed successfullyOracle 12C 新特性“可插拔数据库”功能体验            Oracle 12C加入了一个非常有新意的功能“可插拔数据库”特性,实现了数据库(PDB)在“容器”(CDB)上的拔功能,既能提高系统资源的利用率,也简化大面积数据库的管理和迁移工作。
下面我们体验一下可插拔数据库的CDB和PDB的操作:
基本信息:根容器(CDB):CUP可插拔数据库(PDB):TEA
启动根容器:[oracle@eric ~]$ export ORACLE_SID=cup[oracle@eric ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 21 16:00:06 2015Copyright (c) 1982, 2014, Oracle.  All rights reserved.Connected to an idle instance.SQL> startup    -----不会直接启动所有可插拔数据库,如需启动所有可插拔数据库,执行命令:alter pluggable database all openORACLE instance started.Total System Global Area  767557632 bytesFixed Size                  2929112 bytesVariable Size             574623272 bytesDatabase Buffers          184549376 bytesRedo Buffers                5455872 bytesDatabase mounted.Database opened.停止根容器:SQL> shutdown immediate   Database closed.Database dismounted.ORACLE instance shut down.查看是否创建了CDB,如果有显示名字:SQL> select name,cdb from v$database;NAME      CDB--------- ---CUP       YESSQL> show parameter service;NAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------service_names                        string      cup查看容器名字,其中有3个容器:根容器、种子容器和自己创建的容器:SQL> select con_id,name from v$containers;    CON_ID NAME---------- ------------------------------         1 CDB$ROOT                        ---根容器         2 PDB$SEED                        ---种子容器,只可读         3 TEA                             ---自己创建的可插拔数据库


SQL> select file_name from dba_data_files;               
FILE_NAME
--------------------------------------------------------------------------------
/oracle/app/oradata/CUP/datafile/o1_mf_system_bch07kvz_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_sysaux_bch020oo_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_undotbs1_bch0d2on_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_users_bch0d15n_.dbf


SQL> select file_name from cdb_data_files;


FILE_NAME
--------------------------------------------------------------------------------
/oracle/app/oradata/CUP/datafile/o1_mf_system_bch07kvz_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_sysaux_bch020oo_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_undotbs1_bch0d2on_.dbf
/oracle/app/oradata/CUP/datafile/o1_mf_users_bch0d15n_.dbf


创建公共用户:
SQL> create user c##eric  identified by gao;
User created.


SQL> conn  c##eric/gao                 
ERROR:
ORA-01045: user C##ERIC lacks CREATE SESSION privilege; logon denied    ----没有权限,我们可以单独给其赋予权限,也可以给其指定角色。
Warning: You are no longer connected to ORACLE.




SQL> conn / as sysdba
Connected.
SQL> grant dba to c##eric container=all;     ---给其DBA角色,角色范围覆盖所有的容器
Grant succeeded.


SQL> conn c##eric/gao
Connected.               ---连接成功


切换容器:
首先启动自己创建的容器数据库:
SQL> alter pluggable database tea open;   ---首先启动PDB数据库


SQL> alter session set container = tea;

Session altered.


SQL> show con_name           ---查看当前所在的容器名
CON_NAME
------------------------------
TEA




关闭可插拔数据库:
SQL> alter pluggable database tea close immediate;
Pluggable database altered.
0 0
原创粉丝点击