目 录CONTENT

文章目录

Oracle 11gR2 静默安装

ZERO
2022-07-20 / 0 评论 / 0 点赞 / 73 阅读 / 0 字

1、关闭SELINUX

sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config

2、添加主机名与IP对应记录

echo “ip hostname” >> /etc/hosts

3、安装依赖包

yum install -y binutils compat-libcap1 compat-libstdc++-33   gcc gcc-c++  glibc glibc-devel  ksh libgcc  libstdc++  libstdc++-devel libaio  libaio-devel  make sysstat unixODBC  unixODBC-devel  libXext

yum install -y compat-libstdc++-33*.i686  glibc*.i686 glibc-devel*.i686 libgcc*.i686 libstdc++*.i686 libstdc++-devel*.i686 libaio*.i686 libaio-devel*.i686 unixODBC*.i686 unixODBC-devel*.i686

4、创建组和用户

groupadd -g 200 oinstall
groupadd -g 201 dba
useradd -u 440 -g oinstall -G dba oracle
passwd oracle

5、修改内核参数

# vim /etc/sysctl.conf               #在末尾添加
net.ipv4.ip_local_port_range= 9000 65500 
fs.file-max = 6815744 
kernel.shmall = 10523004 
kernel.shmmax = 6465333657 
kernel.shmmni = 4096 
kernel.sem = 250 32000 100128 
net.core.rmem_default=262144 
net.core.wmem_default=262144 
net.core.rmem_max=4194304 
net.core.wmem_max=1048576 
fs.aio-max-nr = 1048576

# vim /etc/pam.d/login
session  required  pam_namespace.so     #在下一行添加
session  required  pam_limits.so

6、修改系统资源限制

# vim /etc/security/limits.conf
oracle  soft  nproc  2047 
oracle  hard  nproc  16384 
oracle  soft  nofile  1024 
oracle  hard  nofile  65536

7、创建安装目录并设置权限

mkdir -p /oracle/11g/db_base
mkdir -p /oracle/11g/oraInventory
chown -R oracle:oinstall /oracle
chmod -R 775 /oracle

8、设置Oracle环境变量

# 切换到oracle用户
su - oracle

# 设置环境变量
# vim .bash_profile
export ORACLE_BASE=/oracle/11g/db_base
export ORACLE_HOME=$ORACLE_BASE/db_home
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin

9、修改响应文件

# vim /opt/database/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=boydzero.com  # 可为空
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle/11g/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/oracle/11g/db_base/db_home
ORACLE_BASE=/oracle/11g/db_base
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl.boydzero.com
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.password.ALL=pwd
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
DECLINE_SECURITY_UPDATES=true

10、执行安装

./runInstaller -silent  -force -ignorePrereq  -responseFile /opt/database/response/db_install.rsp
# 绝对路径

11、监听设置

cd /oracle/11g/db_base/db_home/bin
netca /silent /responseFile /opt/database/response/netca.rsp

12、建库

# vim /opt/database/response/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
GDBNAME = "orcl.boydzero.com"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "pwd"
SYSTEMPASSWORD = "pwd"
CHARACTERSET = "AL32UTF8"

# 建库
dbca -silent -responseFile /opt/database/response/dbca.rsp

13、创建表空间及用户

# 创建表空间
create tablespace zero datafile '/oracle/11g/db_base/oradata/orcl/zero.dbf' size 2048M autoextend on;

# 创建用户
create user zero identified by 1 default tablespace zero;

# 授权
grant connect,resource,dba to zero;

14、其他命令

# 修改密码
sqlplus / as sysdba
alter user sys identified by 1;

# 查看数据库实例名
select instance_name from v$instance;

# 查看db_name
show parameter db_name;

# 查看service_name
show parameter service_name

# 修改service_name,还要修改下 listener.ora、tnsnames.ora
alter system set service_names='orcl';

# 查看Oracle版本
select version from v$instance;

# 查看global_name,global_name=db_name.db_domain
select * from global_name;

# 修改global_name,去掉global_name里的domain信息
update global_name set global_name = 'orcl'
commit;

# 查看db_domain
show parameter db_domain;

# 修改db_domain,去掉db_domain
alter system set db_domain='' scope=spfile;
shutdown immediate
startup

# 连接数据库 
sqlplus /nolog
conn sys/1@orcl as sysdba

# sqlplus连接远程数据库
sqlplus username/passwrod@IP:PORT/service_name

# 看用户建立的表
# 当前用户的表
select table_name from user_tables;  

#所有用户的表 
select table_name from all_tables;

# 包括系统表 
select table_name from dba_tables; 

# 可以查询出所有的用户表索引
select * from user_indexes
0

评论区