Linux系统静默安装oracle数据库
一.安装准备
1.建立用户及组
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
passwd oracle
2.创建目录
mkdir -p /software/app/oracle
mkdir -p /software/app/oraInventory
chown -R oracle:oinstall /software/app/
chmod -R 755 /software/app
3.配置内核参数(操作系统内存16G),加在最后面。
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
4.设置登录限制
cat >> /etc/pam.d/login <<EOF
session required pam_limits.so
EOF
5.设置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
让文件生效source /etc/profile
6.用户资源进行限制
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388688
kernel.shmmax = 34359738367
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
/sbin/sysctl -p
7.检查CentOS依赖包
rpm -Uvh *.rpm --nodeps --force
8.安装缺少的依赖包(此步骤用于能连上外网)
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel l make numactl-devel sysstat unixODBC unixODBC-devel pdksh
9.配置环境变量
su
- oracle
vi .bash_profile
export ORACLE_BASE=/software/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:$PATH
让文件生效source .bash_profile
10.关闭selinux
临时关闭selinux
setenforce 0
永久关闭
vi /etc/selinux/config
设置SELINUX=disabled
11.关闭防火墙
临时关闭防火墙
systemctl stop firewalld
永久关闭防火墙
systemctl disable firewalld
二.安装oracle
1.上传oracle 11g安装文件到服务器并解压
安装包上传到/home目录下,并解压
cd
/home/oracle
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
待解压完毕后会生成文件夹/home/oracle/database,里面是解压后的所有oracle安装文件
chown -R oracle:oinstall /home/oracle/database
编辑静默安装响应文件
切换到oracle用户
su - oracle
复制响应模板并赋权(可以用root)
cp /home/oracle/database/response/db_install.rsp /software/app/oracle
chown oracle:oinstall /software/app/oracle/db_install.rsp
cd /etc/
touch /etc/oraInst.loc
vi /etc/oraInst.loc
inventory_loc=/software/app/oraInventory
inst_group=oinstall
chown oracle:oinstall /etc/oraInst.loc
2.配置安装响应文件db_install.rsp ,找到相应的选项并配置对应的值
cd /software/app/oracle
vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME= localhost.localdomain
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/software/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/software/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/software/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.memoryLimit=81920
oracle.install.db.config.starterdb.password.ALL=oracle
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
根据响应文件安装oracle
cd /home/oracle/database
./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /software/app/oracle/db_install.rsp
(需要在oracle用户下执行)
可以查看日志
/software/app/oraInventory/logs/
3.切换到root用户执行下面两个脚本
/software/app/oraInventory/orainstRoot.sh
/software/app/oracle/product/11.2.0/dbhome_1/root.sh
4.配置建库响应文件,安装数据库
==================
dbca
==================
cp /home/oracle/database/response/dbca.rsp /software/app/oracle
chown oracle:oinstall /software/app/oracle/dbca.rsp
(需要在oracle用户下执行)
su - oracle
cd /software/app/oracle/
vi dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = 11.2.0
OPERATION_TYPE = createDatabase
[CREATEDATABASE]
GDBNAME = orcl
SID = orcl
TEMPLATENAME = General_Purpose.dbc
CHARACTERSET = ZHS16GBK
SYSPASSWORD = oracle
SYSTEMPASSWORD = oracle
SYSMANPASSWORD = oracle
DBSNMPPASSWORD = oracle
执行
dbca -silent -responseFile /software/app/oracle/dbca.rsp (需要在oracle用户下执行)
Look at the log file "/software/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
5配置监听响应文件
==================
netca
==================
cp /home/oracle/database/response/netca.rsp /software/app/oracle
chown oracle:oinstall /software/app/oracle/netca.rsp
su - oracle
netca /silent /responsefile /software/app/oracle/netca.rsp (需要在oracle用户下执行)
成功运行后,在/software/app/oracle/product/11.2.0/dbhome_1/network/admin目录下生成 sqlnet.ora和listener.ora两个文件。
启动监听
lsnrctl start
查看监听状态
lsnrctl status
netstat –tlnp
sqlplus / as sysdba
Startup
[oracle@localhost ~]$ lsnrctl start #开启监听服务
[oracle@localhost ~]$ sqlplus / as sysdba #登入
SQL> shutdown immediate #立即关闭数据库服务(一般是关闭状态)
SQL> startup #开启数据库服务(重要,必输)
SQL> exit #退出
三.创建用户
1.创建表空间
select * from dba_data_files ;
CREATE TABLESPACE FHY DATAFILE '/software/app/oracle/oradata/orcl/FHY.dbf' size 1024m autoextend on next 1024m;
2.创建用户并指定表表空间
create user secondoracle identified by secondoracle DEFAULT TABLESPACE FHY ;
grant create any view, create any table , create any procedure, create any trigger to secondoracle;
grant connect, resource to secondoracle;
grant imp_full_database to secondoracle;
grant read,write on directory DATA_PUMP_DIR to secondoracle;
3.总结
以上创建于2022.11.21
借鉴
https://www.cnblogs.com/lidingyi/p/15136564.html
https://www.yisu.com/zixun/158774.html
标签:数据库,db,install,Linux,oracle,rsp,app,software From: https://www.cnblogs.com/CloudHaiYun/p/16912165.html