简单配置oracle11g

Posted Jt00

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单配置oracle11g相关的知识,希望对你有一定的参考价值。

一.配置 Systemd file(开机可以自动oracle,也可以查看启动状态)

a.定义环境变量

[oracle@ol7 ~]$ cat /etc/sysconfig/DB11G.oracledb
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
ORACLE_SID=DB11G
[oracle@ol7 ~]$ cat /usr/lib/systemd/system/DB11G\\@
DB11G@lsnrctl.service DB11G@oracledb.service

b.配置监听服务

[oracle@ol7 ~]$ cat /usr/lib/systemd/system/DB11G\\@lsnrctl.service
# this is an example, modify for free
[Unit]
Description=oracle net listener
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/DB11G.oracledb
ExecStart=/u01/app/oracle/product/11.2.0.4/db_1/bin/lsnrctl start
ExecStop=/u01/app/oracle/product/11.2.0.4/db_1/bin/lsnrctl stop
User=oracle

[Install]
WantedBy=multi-user.target

c.定义数据库服务
[oracle@ol7 ~]$ cat /usr/lib/systemd/system/DB11G\\@oracledb.service
# this is an example, modify for free
[Unit]
Description=oracle net listener
After=network.target lsnrctl.service

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/DB11G.oracledb
ExecStart=/u01/app/oracle/product/11.2.0.4/db_1/bin/dbstart /u01/app/oracle/product/11.2.0.4/db_1
ExecStop=/u01/app/oracle/product/11.2.0.4/db_1/bin/dbshut /u01/app/oracle/product/11.2.0.4/db_1
User=oracle

[Install]
WantedBy=multi-user.target
[oracle@ol7 ~]$ systemctl daemon-reload 
[oracle@ol7 ~]$ systemctl enable DB11G@lsnrctl.service DB11G@oracledb.service

这里要提前规划好相应的分区,规划好了管理才方便

mkdir -p /oracledata/nc/nctables
mkdir -p /oracledata/nc/ncindex
chown -R oracle:oinstall /oracledata/nc/nctables
chown -R oracle:oinstall /oracledata/nc/ncindex/
chmod -R 755 /oracledata/*
mkdir -p /oracletemp/DB11G/dump
chown -R oracle:oinstall /oracletemp/DB11G/dump
chmod -R 755 /oracletemp/DB11G/dump

二.数据库文件

控制文件:

两个互为镜像,分配在不同的磁盘上

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DB11G/control01.ctl
/oraclearch/flash_recovery_area/DB11G/control02.ctl

redo日志:一共四个组,每组两个成员,前期的大小是预估的,后期正常的时候,计算redo大小,再调整。


SQL> select group#, member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------------------------------------
3 /u01/app/oracle/oradata/DB11G/redo03.log
1 /u01/app/oracle/oradata/DB11G/redo01.log
2 /u01/app/oracle/oradata/DB11G/redo02.log
1 /oracle/redo1/redo01a.log
2 /oracle/redo1/redo02a.log
3 /oracle/redo1/redo03a.log
4 /u01/app/oracle/oradata/DB11G/redo04.log
4 /oracle/redo1/redo04a.log
8 rows selected

SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- -------- ---------------- ------------- ----------- ------------ -----------
1 1 361 524288000 512 2 NO CURRENT 22234232 2017/4/24 2 281474976710
2 1 359 524288000 512 2 YES INACTIVE 22205745 2017/4/24 1 22234224 2017/4/24 2
3 1 360 524288000 512 2 YES INACTIVE 22234224 2017/4/24 2 22234232 2017/4/24 2
4 1 358 524288000 512 2 YES INACTIVE 22127329 2017/4/23 2 22205745 2017/4/24 1

SQL>

归档日志 archivelog:

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracletemp/DB11G/archive_log
Oldest online log sequence 358
Next log sequence to archive 361
Current log sequence 361
SQL>

因为是正式的数据库。所以归档位置有两处,一处失败了,备份到另外一处,没有做镜像,因为没多的服务器

log_archive_dest_1 string location=/oraclearch/archive_l
og
log_archive_dest_10 string
log_archive_dest_11 string
log_archive_dest_12 string
log_archive_dest_13 string
log_archive_dest_14 string
log_archive_dest_15 string

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_16 string
log_archive_dest_17 string
log_archive_dest_18 string
log_archive_dest_19 string
log_archive_dest_2 string location=/oracletemp/DB11G/arc
hive_log

管理 undo:

查看用的那个undo表空间:

SQL> select tablespace_name,status,contents from dba_tablespaces;
TABLESPACE_NAME STATUS CONTENTS
------------------------------ --------- ---------
SYSTEM ONLINE PERMANENT
SYSAUX ONLINE PERMANENT
UNDOTBS1 ONLINE UNDO
TEMP ONLINE TEMPORARY
USERS ONLINE PERMANENT
NNC_DATA01 ONLINE PERMANENT
NNC_INDEX01 ONLINE PERMANENT
7 rows selected

SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1

SQL>

undo_retention 内,不可以覆盖(非强制)
SQL> select tablespace_name,status,contents,retention from
2 dba_tablespaces;
TABLESPACE_NAME STATUS CONTENTS RETENTION
------------------------------ --------- --------- -----------
SYSTEM ONLINE PERMANENT NOT APPLY
SYSAUX ONLINE PERMANENT NOT APPLY
UNDOTBS1 ONLINE UNDO NOGUARANTEE
TEMP ONLINE TEMPORARY NOT APPLY
USERS ONLINE PERMANENT NOT APPLY
NNC_DATA01 ONLINE PERMANENT NOT APPLY
NNC_INDEX01 ONLINE PERMANENT NOT APPLY
7 rows selected

自动增长减少ora_015555:过段时间数据库平稳了,再固定空间大小

SQL> select file_name,autoextensible,increment_by from dba_data_files ;
FILE_NAME AUTOEXTENSIBLE INCREMENT_BY
-------------------------------------------------------------------------------- -------------- ------------
/oracledata/DB11G/users01.dbf YES 160
/u01/app/oracle/oradata/DB11G/undotbs01.dbf YES 640
/u01/app/oracle/oradata/DB11G/sysaux01.dbf YES 1280
/u01/app/oracle/oradata/DB11G/system01.dbf YES 1280
/oracledata/nc/nctables/nnc_data01.dbf YES 6400
/oracledata/nc/ncindex/nnc_index01.dbf YES 6400
6 rows selected

项目的基本配置:

create user ***** identified by  *****;
CREATE TABLESPACE NNC_DATA01 DATAFILE \'/u01/tablespace/nnc_data01.db\' SIZE 500M AUTOEXTEND ON NEXT 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K ;
CREATE TABLESPACE NNC_INDEX01 DATAFILE \'/u01/tablespace/nnc_index01.dbf\' SIZE 500M AUTOEXTEND ON NEXT 50M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K ;
select group#,sequence#,status,bytes/1024/1024 from v$log;
select group#,status,type,member from v$logfile;
alter user  ***** default tablespace NNC_DATA01 TEMPORARY TABLESPACE temp;
GRANT connect,dba to zyctdw;
CREATE USER  ***** IDENTIFIED BY  ***** DEFAULT TABLESPACE NNC_DATA01 TEMPORARY TABLESPACE temp;
GRANT connect,dba to  *****;

我以前是负责公司linux运维的,这次是第一次部署公司的数据库,所以有些地方可能不妥。

 ---------------我是有底线的-------------------- 
作者:jt
出处:http://www.cnblogs.com/Jt00/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
如果文中有什么错误,欢迎指出。以免更多的人被误导。

以上是关于简单配置oracle11g的主要内容,如果未能解决你的问题,请参考以下文章

Oracle11g 主机身份证明问题

Oracle 11g Express

安装Oracle 11g 后 服务里没有 OracleDBConsoleorcl 服务

Fedora 安装oracle11g 之最最间接方式

oracle 11g怎样配置才能连接远程数据库

Oracle11g数据库快速安装