Oracle安装手册
整理:罗代均 luodaijun@vip.163.com
目录
1.Linux常用命令 2
2.安装Oracle 10gR2 3
3.Oracle中文支持问题 5
4.Oracle服务启动关闭 5
5.开机自动启动Oracle 5
6.创建表空间 6
7.创建用户 7
1.Linux常用命令
查看编辑文本文件,用图形化的gedit
gedit /filepath
查看环境变量
env
设置别名
alias 别名='原命令'
如: alias startTomcat='/usr/local/tomcat/bin/startup.sh'
查看当前所在目录
pwd
查看磁盘空间使用情况
df
列出所有文件,包括隐藏文件
ls -l –a
设置所有用户都具有读写权限
chmod 777 /data/www/index.html
递归下级目录
chmod -R 777 /data/www
设置文件为可执行
chmod 755 /home/oracle/startOracle.sh
或者chmod +x /home/oracle/startOracle.sh
改变文件所有者
chown user:usergroup /path
chown -R user:usergroup /path
查看进程,并用正则过滤
ps -ef | grep java
杀死进程
kill -9 pid
pkill -9 process_name
如: pkill -9 java , pkill -9 nginx
动态更新显示文件内容,查看不断变化的文件
tail -f /usr/local/tomcat/log/catalina.out
删除文件及递归删除子目录
rm /filepath
rm -rf /path
查找文件
find /path -name *.swf
I/O重定向
如将查找到的结果输出到abc.txt
find /home/oracle -name *.jsp > abc.txt
压缩解压
(1).tar.gz
解压:tar zxvf abc.tar.gz
压缩:tar czvf abc.tar.gz path
(2).tar
压缩: tar xvf abc.tar path
解压: tar zxvf abc.tar
(3).bz
解压:bzip –d abc.bz
(4).bz2
解压:bzip2 –d abc.bz2
(5).gz
解压:gzip –d abc.gz
(6).tar.bz2
解压:tar jxvf abc.tar.bz2
压缩:tar jcvf abc.tar.bz2 path
2.安装Oracle 10gR2
安装依赖包
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
yum -y install unixODBC unixODBC-devel sysstat libXp libXp-devel libaio-devel
创建用户和组
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -m -g oinstall -g dba oracle
id oracle
passwd oracle
mkdir /oracle
chown -R oracle:oinstall /oracle
chmod -R 775 /oracle
设置环境变量
su – oracle
-----------------~/.bash_profile --------------------------
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=mam
export NLS_LANG='simplified chinese'_china.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin
export LANG=zh_CN.UTF-8
-------------------end--------------------------------------
环境变量生效
source ~/.bash_profile
修改内核参数
su root
------------/etc/sysctl.conf------------------------------
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=4194304
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=262144
-----------------end---------------------------------------
内核参数生效
sysctl –p
------------------/etc/security/limits.conf ---------------
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
--------------end----------------------------------------
注销用oracle用户登录
unzip oraclexxx.zip
export LC_ALL=c
非常重要!! 忽略检查操作系统,不然非oracle认证过的版本都不允许安装
./runInstaller –ignoreSysPrereqs
安装完成的时候,会弹出窗口要求运行如下两个脚本(root权限)
su root
/oracle/oraInventory/orainstRoot.sh
/oracle/product/10.2.0/db_1/root.sh
3.Oracle中文支持问题
强制使用英文界面
export LC_ALL=c
任意支持中文的字体都可以,比如文泉驿字体
这里我使用windows系统带的simsun.ttc
cp simsun.ttc /usr/share/fonts/zh_CN/TrueType/zysong.ttf
cd $ORACLE_HOME/jdk/jre/lib
cp font.properties.zh_CN.Redhat font.properties
cd $ORACLE_HOME/jre/1.4.2/lib/
cp font.properties.zh_CN.Redhat font.properties
cd $ORACLE_HOME/javavm/lib/ojvmfonts/
cp font.properties.zh_CN.Redhat font.properties
4.Oracle服务启动关闭
dbca:数据库创建向导
netca:网络服务配置向导
启动关闭监听器
lsnrctl start
lsnrctl stop
启动关闭oracle服务
进入sqlplus环境: sqlplus /nolog
conn / as sysdba
startup --启动
shutdown --关闭
shutdown immediate –立即关闭
或者: dbstart和dbshut命令
启动管理控制台
emctl start dbconsole
emctl stop dbconsole
启动isqlplus
isqlplusctl start
isqlplusctl stop
5.开机自动启动Oracle
------------------start_oracle.sh------------------------------------
#! /bin/bash
lsnrctl start
sqlplus /nolog <<EOF
conn / as sysdba
startup
EOF
-------------------end----------------------------------------------
设置为可执行文件
chmod 755 start_oracle.sh
-------------------stop_oracle.sh------------------------------------
#! /bin/bash
lsnrctl stop
sqlplus /nolog <<EOF
conn / as sysdba
shutdown immediate
EOF
-------------------end-----------------------------------------------
chmod 755 stop_oracle.sh
添加到 /etc/rc.d/rc.local开机执行
---------------/etc/rc.d/rc.local---------------------------------
su - oracle -c /home/oracle/start_oracle.sh >> /dev/null
----------------end------------------------------------------------
6.创建表空间
建议将表数据、索引、临时文件分别创建表空间,这样只需要重点备份表数据使用的表空间,实际上索引占用的磁盘空间非常的大
设置目录权限
chown oracle:oinstall /oradata/mam
chmod 775 /oradata/mam
------------01_create_tabspace.sql--------------------------------
set echo on
set feedback off
set verify off
define tb_path=/oradata/mam
prompt '开始创建表空间'
create tablespace mam_dat datafile '&tb_path/mam_dat01.dbf' size 10M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED extent management local uniform size 128k online;
create tablespace mam_idx datafile '&tb_path/mam_idx01.dbf' size 10M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED extent management local uniform size 128k online;
create temporary tablespace mam_tmp tempfile '&tb_path/mam_tmp01.dbf' size 10m AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED extent management local uniform size 128k;
prompt '结束'
---------------end------------------------------------------------
7.创建用户
------------------02_create_user.sql------------------------------
prompt 'start create user'
set feedback off
set define off
set echo off
create user mam identified by password
default tablespace mam_dat
temporary tablespace mam_tmp
account unlock;
grant AUDIT ANY to mam with admin option;
grant DROP USER to mam with admin option;
grant ALTER USER to mam with admin option;
grant ANALYZE ANY to mam with admin option;
grant BECOME USER to mam with admin option;
grant CREATE ROLE to mam with admin option;
grant CREATE TYPE to mam with admin option;
grant CREATE USER to mam with admin option;
grant CREATE VIEW to mam with admin option;
grant ALTER SYSTEM to mam with admin option;
grant AUDIT SYSTEM to mam with admin option;
grant CREATE TABLE to mam with admin option;
grant DROP PROFILE to mam with admin option;
grant ALTER PROFILE to mam with admin option;
grant ALTER SESSION to mam with admin option;
grant DROP ANY ROLE to mam with admin option;
grant DROP ANY TYPE to mam with admin option;
grant DROP ANY VIEW to mam with admin option;
grant QUERY REWRITE to mam with admin option;
grant ALTER ANY ROLE to mam with admin option;
grant ALTER ANY TYPE to mam with admin option;
grant ALTER DATABASE to mam with admin option;
grant CREATE CLUSTER to mam with admin option;
grant CREATE LIBRARY to mam with admin option;
grant CREATE PROFILE to mam with admin option;
grant CREATE SESSION to mam with admin option;
grant CREATE SYNONYM to mam with admin option;
grant CREATE TRIGGER to mam with admin option;
grant DROP ANY INDEX to mam with admin option;
grant DROP ANY TABLE to mam with admin option;
grant GRANT ANY ROLE to mam with admin option;
grant LOCK ANY TABLE to mam with admin option;
grant ALTER ANY INDEX to mam with admin option;
grant ALTER ANY TABLE to mam with admin option;
grant CREATE ANY TYPE to mam with admin option;
grant CREATE ANY VIEW to mam with admin option;
grant CREATE SEQUENCE to mam with admin option;
grant CREATE SNAPSHOT to mam with admin option;
grant DROP TABLESPACE to mam with admin option;
grant ALTER TABLESPACE to mam with admin option;
grant BACKUP ANY TABLE to mam with admin option;
grant CREATE ANY INDEX to mam with admin option;
grant CREATE ANY TABLE to mam with admin option;
grant CREATE PROCEDURE to mam with admin option;
grant DELETE ANY TABLE to mam with admin option;
grant DROP ANY CLUSTER to mam with admin option;
grant DROP ANY LIBRARY to mam with admin option;
grant DROP ANY SYNONYM to mam with admin option;
grant DROP ANY TRIGGER to mam with admin option;
grant EXECUTE ANY TYPE to mam with admin option;
grant INSERT ANY TABLE to mam with admin option;
grant SELECT ANY TABLE to mam with admin option;
grant UPDATE ANY TABLE to mam with admin option;
grant ALTER ANY CLUSTER to mam with admin option;
grant ALTER ANY LIBRARY to mam with admin option;
grant ALTER ANY TRIGGER to mam with admin option;
grant COMMENT ANY TABLE to mam with admin option;
grant CREATE TABLESPACE to mam with admin option;
grant DROP ANY SEQUENCE to mam with admin option;
grant DROP ANY SNAPSHOT to mam with admin option;
grant FORCE TRANSACTION to mam with admin option;
grant MANAGE TABLESPACE to mam with admin option;
grant ALTER ANY SEQUENCE to mam with admin option;
grant ALTER ANY SNAPSHOT to mam with admin option;
grant CREATE ANY CLUSTER to mam with admin option;
grant CREATE ANY LIBRARY to mam with admin option;
grant CREATE ANY SYNONYM to mam with admin option;
grant CREATE ANY TRIGGER to mam with admin option;
grant DROP ANY DIRECTORY to mam with admin option;
grant DROP ANY PROCEDURE to mam with admin option;
grant RESTRICTED SESSION to mam with admin option;
grant ALTER ANY PROCEDURE to mam with admin option;
grant ALTER RESOURCE COST to mam with admin option;
grant CREATE ANY SEQUENCE to mam with admin option;
grant CREATE ANY SNAPSHOT to mam with admin option;
grant DROP PUBLIC SYNONYM to mam with admin option;
grant EXECUTE ANY LIBRARY to mam with admin option;
grant GRANT ANY PRIVILEGE to mam with admin option;
grant SELECT ANY SEQUENCE to mam with admin option;
grant CREATE ANY DIRECTORY to mam with admin option;
grant CREATE ANY PROCEDURE to mam with admin option;
grant CREATE DATABASE LINK to mam with admin option;
grant GLOBAL QUERY REWRITE to mam with admin option;
grant UNLIMITED TABLESPACE to mam with admin option;
grant CREATE PUBLIC SYNONYM to mam with admin option;
grant DROP ROLLBACK SEGMENT to mam with admin option;
grant EXECUTE ANY PROCEDURE to mam with admin option;
grant FORCE ANY TRANSACTION to mam with admin option;
grant SELECT ANY DICTIONARY to mam with admin option;
grant ALTER ROLLBACK SEGMENT to mam with admin option;
grant CREATE ROLLBACK SEGMENT to mam with admin option;
grant DROP PUBLIC DATABASE LINK to mam with admin option;
grant CREATE PUBLIC DATABASE LINK to mam with admin option;
exit;
-----------------end---------------------------------------------