Home Database Mysql Tutorial Oracle 10g 快速手工建库步骤

Oracle 10g 快速手工建库步骤

Jun 07, 2016 pm 04:40 PM

Oracle 10g 快速手工建库步骤记录: 0. 修改环境变量 [oracle@ocm1 ~]$ vi .bash_profile 添加以下内容:export ORACLE_SID=PROD

Oracle 10g 快速手工建库步骤记录:

0. 修改环境变量
 
[oracle@ocm1 ~]$ vi .bash_profile
 
添加以下内容:
export ORACLE_SID=PROD
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
 
1. 修改登录标识符和默认编辑器(非必须)
 
修改$ORACLE_HOME/sqlplus/admin/glogin.sql,在文件末尾添加以下内容:
 
set sqlprompt '_user''@''_connect_identifier> '
define _editor=vi
                                                           
2. 创建初始化参数(用于启动数据库实例)
 
[oracle@ocm1 dbs]$ cat init.ora|grep -v ^$|grep -v ^# > initPROD.ora
[oracle@ocm1 dbs]$ ll
total 32
-rw-r----- 1 oracle oinstall 12920 May  3  2001 initdw.ora
-rw-r----- 1 oracle oinstall  8385 Sep 11  1998 init.ora
-rw-r--r-- 1 oracle oinstall  738 Jan 10 19:18 initPROD.ora
[oracle@ocm1 dbs]$ vi initPROD.ora
db_name=PROD
db_files = 80                                                        # SMALL
db_file_multiblock_read_count = 8                                    # SMALL
#db_block_buffers = 100                                                # SMALL
#shared_pool_size = 3500000                                            # SMALL
log_checkpoint_interval = 10000
processes = 50                                                        # SMALL
parallel_max_servers = 5                                              # SMALL
log_buffer = 32768                                                    # SMALL
max_dump_file_size = 10240      # limit trace file size to 5 Meg each
global_names = FALSE
control_files = (/u01/app/oacle/oradata/PROD/Disk1/control01.ctl, /u01/app/oacle/oradata/PROD/Disk1/control02.ctl,/u01/app/oacle/oradata/PROD/Disk1/control03.ctl)
undo_management=auto
sga_max_size=300M
sga_target=300M
 
注意:红色部分为需要添加或修改的地方
 
3. 创建密码文件
 
[oracle@ocm1 dbs]$ orapwd file=orapwPROD password=oracle entries=5
[oracle@ocm1 dbs]$ ll
total 36
-rw-r----- 1 oracle oinstall 12920 May  3  2001 initdw.ora
-rw-r----- 1 oracle oinstall  8385 Sep 11  1998 init.ora
-rw-r--r-- 1 oracle oinstall  914 Jan 10 19:21 initPROD.ora
-rw-r----- 1 oracle oinstall  2048 Jan 10 19:24 orapwPROD
 
4. 创建相关目录
                                                           
[oracle@ocm1 dbs]$ mkdir /u01/app/oracle/admin/PROD/{a,b,c,u}dump -p
[oracle@ocm1 dbs]$ cd /u01/app/oracle/admin/PROD
[oracle@ocm1 PROD]$ ll
total 16
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 adump
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 bdump
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 cdump
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:23 udump
[oracle@ocm1 PROD]$ cd /u01/app/oracle
[oracle@ocm1 oracle]$ mkdir oradata/PROD/Disk{1,2,3,4,5} -p
[oracle@ocm1 oracle]$ cd oradata/PROD/
[oracle@ocm1 PROD]$ ll
total 20
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk1
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk2
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk3
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk4
drwxr-xr-x 2 oracle oinstall 4096 Jan 10 19:22 Disk5
 
5. 创建spfile
 
[oracle@ocm1 PROD]$ sqlplus / as sysdba
 
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jan 10 19:25:04 2015
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
Connected to an idle instance.
 
SYS@PROD> startup nomount
ORACLE instance started.
 
Total System Global Area  314572800 bytes
Fixed Size                  1219184 bytes
Variable Size              96470416 bytes
Database Buffers          213909504 bytes
Redo Buffers                2973696 bytes
SYS@PROD> create spfile from pfile;
 
File created.
 
创建spfile并用它启动后,,就可以通过alter sysem set xxx来动态修改所需的参数了,主要是可以利用模糊查找得到不熟悉的参数名
 
6. 创建建库脚本crdb.sql
 
Reffer:Administration->Database Administrator's Guide->2 Creating an Oracle Database->Manually Creating an Oracle Database->Step 7: Issue the CREATE DATABASE Statement
 
CREATE DATABASE PROD
  USER SYS IDENTIFIED BY oracle
  USER SYSTEM IDENTIFIED BY oracle
          GROUP 1 ('/u01/app/oracle/oradata/PROD/Disk1/redo01_a.log') SIZE 100M
          GROUP 2 ('/u01/app/oracle/oradata/PROD/Disk1/redo02_a.log') SIZE 100M
          GROUP 3 ('/u01/app/oracle/oradata/PROD/Disk1/redo03_a.log') SIZE 100M
  MAXLOGFILES 5
  MAXLOGMEMBERS 5
  MAXLOGHISTORY 1
  MAXDATAFILES 100
  MAXINSTANCES 1
  CHARACTER SET US7ASCII
  NATIONAL CHARACTER SET AL16UTF16
  DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE
  EXTENT MANAGEMENT LOCAL
  SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE
      SIZE 20M REUSE
      SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
 
可以用%s替换加速修改,注意修改实例名和相应的路径,确保目录都存在
 
6. 开始跑脚本建库(约2分钟)
 
[oracle@ocm1 PROD]$ sqlplus / as sysdba
 
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jan 10 19:51:10 2015
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
 
SYS@PROD> @/home/oracle/crdb.sql
 
Database created.
 
至此,已经基本完成了手工建库的步骤,但是这个库目前还用不了,原因是没有数据字典等系统对象
 
7. 分别运行catalog.sql和catproc.sql脚本(注意先后顺序)
 
SYS@PROD> @?/rdbms/admin/catalog
SYS@PROD> @?/rdbms/admin/catproc
 
SYS@PROD> select count(*) from dba_objects;
 
  COUNT(*)
----------
      9373
 
跑完脚本,才能执行对各个系统表和视图的查询,可以看到,默认手工建库跑完脚本后的系统对象是9373个(10g)
 
还有一种更快的方法,就是设置db_create_file_dest和db_create_online_logfile_dest1,然后直接运行create database xxx;
然后根据需要调整具体的路径或参数
 
友情提醒:
 
建完库之后,记得关闭数据库用tar进行冷备份,主要是PROD和dbs这2个目录,这样就不怕误删除了,用tar的之后千万注意解压和压缩的命令参数不要用错,否则一不小心将当前目录不相关的内容变成备份内容,覆盖了原来的备份内容,那可是非常糟糕的,默认如果生成的tar文件同名,会直接覆盖掉,而不是追加到原压缩文件。

在CentOS 5.5 i386 上安装 Oracle 10G XE 

Linux下Oracle 11G XE 安装笔记 

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

本文永久更新链接地址: 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles