声明:本文中所描述的系统命令,未经特殊标示,均为ldquo;#rdquo;代表root权限,ldquo;$rdquo;代表oracle权限。 一、安装系统
声明:本文中所描述的系统命令,未经特殊标示,均为“#”代表root权限,“$”代表Oracle权限。
一、安装系统
首先安装Linux系统,根据Oracle官方文档的建议,在机器内存小于1G的情况下,swap分区大小应该设置为内存的2倍大,若内存大于2G则swap分区设置为与内存大小一样。
其实Linux系统的swap分区大小设置是很有讲究的,如果哪位读者有兴趣,可以参考我的另外一篇文章——《如何合理设置Linux系统的swap分区大小》。
在系统安装的过程中,一定选择安装所有开发包,建议不要安装SELinux或者安装后在系统中禁止SELinux运行,否则会出现一些莫名其妙的问题。
为防止Oracle安装过程中出现乱码,建议使用英文作为系统语言,进行Oracle的安装工作
二、安装Oracle前的系统准备工作
1.检查需要的软件包
可以使用rpm -qa|grep 软件包关键词命令进行检测,一般情况下会需要手动安装如下的软件包:
From RedHat AS5 Disk 1(32 Bit)
# rpm -Uvh setarch-2*
# rpm -Uvh make-3*
# rpm -Uvh glibc-2*
# rpm -Uvh libaio-0*
From RedHat AS5 Disk 2(32 Bit)
# rpm -Uvh compat-libstdc -33-3*
# rpm -Uvh compat-gcc-34-3*
# rpm -Uvh compat-gcc-34-c -3*
# rpm -Uvh gcc-4*
# rpm -Uvh libXp-1*
From RedHat AS5 Disk 3(32 Bit)
# rpm -Uvh openmotif-2*
# rpm -Uvh compat-db-4*
如果使用DVD安装介质的话,会很方便。
2.修改Linux发行版本信息
由于Oracle 10g发行的时候,RedHat Enterprise Linux 5没有发行,所以Oracle 10g并没有对RedHat Enterprise Linux 5确认支持,我们有两种方法可以让Oracle 10g支持RedHat Enterprise Linux 5。
方法一:
我们需要手工修改Linux的发行注记,让Oracle 10g支持RedHat Enterprise Linux 5。
编辑/etc/redhat-release文件
# vi /etc/redhat-release
将其中的内容Red Hat Enterprise Linux Server release 5 (Tikanga)修改为Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
方法二:
还有文章说修改Oracle安装包中install/oraparam.ini文件的内容,也可以让Oracle 10g支持RedHat Enterprise Linux 5,修改方法如下:
# vi install/oraparam.ini
在其中的Certified Versions段落增加redhat-5
#[Certified Versions]
Linux=redhat-3,SUSE-9,redhat-4,redhat-5,UnitedLinux-1.0,asianux-1,asianux-2]
再添加
[Linux-redhat-5.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
经我测试,发现方法二在安装之前的系统检测过程可以通过,但是在安装过程中的系统支持检测无法通过,不知道是不是我设置的有问题,希望有高手可以给我点提示。
3.修改系统内核参数
# vi /etc/sysctl.conf
kernel.shmall = 2097152 // 该参数表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改kernel.shmmax = 2147483648 // 该参数定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,对于oracle来说,该缺省值太低了,通常将其设置为2G
kernel.shmmni = 4096 // 这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改
kernel.sem = 250 32000 100 128 // 表示设置的信号量
fs.file-max = 65536 // 表示文件句柄的最大数量。文件句柄设置表示在linux系统中可以打开的文件数量
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144 // 默认的接收窗口大小
net.core.rmem_max=262144 // 接收窗口的最大大小
net.core.wmem_default=262144 // 默认的发送窗口大小
net.core.wmem_max=262144 // 发送窗口的最大大小
修改好内核参数后,执行如下命令使新的设置生效
# /sbin/sysctl -p
4.创建Oracle用户、组、安装目录
在这里我只讨论单主机环境,不考虑RAC环境的配置,在以后我会专门写一篇如何配置Oracle RAC环境的文章。
(1) 创建Oracle用户组
# groupadd oinstall
# groupadd dba
(2) 创建Oracle用户
# useradd -m -g oinstall -G dba oracle
(3) 设置Oracle用户口令
# passwd oracle
(4) 创建Oracle安装目录以及数据存放目录
# mkdir -p /DBSoftware/app/oracle
# mkdir -p /DBData/oradata
(5) 修改目录权限
# chown -R oracle:oinstall /DBSoftware/app/oracle/ /DBData/oradata/
# chmod -R 755 /DBSoftware/app/oracle/ /DBData/oradata/
5.添加以下内容到/etc/security/limits.conf
# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
6.添加以下内容到/etc/pam.d/login
# vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
7.添加以下内容到/etc/profile
# vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
8.配置Linux主机
检查/etc/hosts文件中是否有localhost的记录(指向127.0.0.1即可),若没有的话,在后面配置Oracle监听的时候会出现一些问题,导致无法启动监听,在此手工添加此记录即可。
9.配置oracle用户环境变量
# su - oracle
$ vi ~/.bash_profile
增加如下内容:
export ORACLE_BASE=/DBSoftware/app/oracle // 上面创建的Oracle安装文件夹
export ORACLE_SID=orcl
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBARY_PATH=$ORACLE_HOME/lib
export PATH
umask 022
保存后使用如下命令,使设置生效:
$ source ~/.bash_profile
三、安装Oracle,并进行相关设置
1.解压缩安装文件
Oracle的安装包有这样几种格式:
(1) zip
这种格式最好解压缩,直接使用命令unzip 文件名即可
(2) cpio.gz
这种格式有这样几种解压缩方式
a. # zcat XXXX.cpio.gz | cpio -idmv
b. # gunzip XXXX.cpio.gz解压出XXXX.cpio文件然后再 # cpio -idvm < XXXX.cpio
解压缩完成后,设置oracle帐户可以操作安装文件所在的目录
chown -R oracle:oinstall 安装文件所在目录
2. 用oracle帐户进入安装文件所在目录,执行如下命令即可看到安装界面:
$ ./runInstaller
如果无法看到安装界面,请使用root帐户执行如下命令后再运行安装程序:
# export DISPLAY=:0.0
# xhost +
$ ./runInstaller
出现安装界面后,根据界面提示进行相关的设置,我的建议是在安装过程中不创建数据库,只安装程序,,监听和创建数据库等安装完成后再进行相关的操作。
安装过程中,需要使用root权限执行两个脚本。
3. 安装完成后,将/etc/redhat-release文件中的内容修改回Red Hat Enterprise Linux Server release 5 (Tikanga)
4.创建监听以及创建数据库
(1) 创建监听程序
使用Oracle提供的NET CONFIGURATION ASSISTANT创建TNS监听
$ netca
基本上就是一直Next就可以了,当然你也可以在这期间修改TNS的监听端口号
TNS监听创建完成后可以使用如下命令进行检查:
# netstat -atln 检查监听端口是否打开
$ lsnrctl status 检查TNS监听状态
确认监听已经成功启动后,即可执行Database Configure Assistant进行数据库的创建,执行命令如下:
$ dbca
在创建数据库的过程中,建议将数据库的字符集设置为Unicode UTF-8,防止出现乱码。

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

MySQL is not a programming language, but its query language SQL has the characteristics of a programming language: 1. SQL supports conditional judgment, loops and variable operations; 2. Through stored procedures, triggers and functions, users can perform complex logical operations in the database.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools