参考 https://blog.csdn.net/weixin_43315211/article/details/90256603
oracle版本:oracle 12c
1、查看防火墙状态:
service iptable status
service iptables stop
2、关闭selinux
vi /etc/selinux/config
SELINUX=disabled
3、安装依赖
有网环境:
yum -y install binutils compat-libcap1 compat-libstdc++-33
compat-libstdc++-33.i686 gcc gcc-c++ glibc glibc.i686
glibc-devel glibc-devel.i686 ksh libgcc libgcc.i686
libstdc++ libstdc++.i686 libstdc++-devel libstdc++-devel.i686
libaio libaio.i686 libaio-devel libaio-devel.i686 libXext
libXext.i686 libX11 libX11.i686 libxcb libxcb.i686 libXi libXi.i686 make sysstat
4、创建运行oracle数据库的用户组和系统用户
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba -m oracle
passwd oracle
>>123456
>>123456 //输入两次密码,设置生效
5、修改内核参数,vi /etc/sysctl.conf,添加:
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4098955264
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 = 1048576
sysctl -p
6、修改用户限制
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
oracle hard stack 10240
vi /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
7、修改环境变量
vi /etc/profile
if [ "$USER" = "oracle" ]; then
if [ "$SHELL" = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536a
else
ulimit -u 16384 -n 65536
fi
fi
source /etc/profile
8、创建安装及数据目录
mkdir -p /usr/local/oraInventory
mkdir -p /usr/local/oracle/product/12.1.0/db_1
chown -R oracle:oinstall /usr/local/oracle
chown -R oracle:oinstall /usr/local/oraInventory
chmod -R 775 /usr/local/oracle
9、切换用户,修改配置文件
su - oracle
vi ~/.bash_profle
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
source ~/.bash_profle
10、解压安装文件,并修改参数配置
unzip linuxx64_12201_database.zip
cp -R /usr/local/oracle/database/response /usr/local/oracle/
cd /usr/local/oracle/response/
vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/usr/local/oraInventory
ORACLE_HOME=/usr/local/oracle/product/12.1.0/db_1
ORACLE_BASE=/usr/local/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oinstall
oracle.install.db.OSBACKUPDBA_GROUP=oinstall
oracle.install.db.OSDGDBA_GROUP=oinstall
oracle.install.db.OSKMDBA_GROUP=oinstall
oracle.install.db.OSRACDBA_GROUP=oinstall
oracle.install.db.config.starterdb.password.SYS=JLwg!2016
oracle.install.db.config.starterdb.password.SYSTEM=JLwg!2016
DECLINE_SECURITY_UPDATES=true
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
11、安装数据库
cd /usr/local/oracle/database
./runInstaller -silent -responseFile /usr/local/oracle/response/db_install.rsp
12、切换root用户执行以下脚本
./usr/local/oraInventory/orainstRoot.sh
./usr/local/oracle/product/11.2.0/db_1/root.sh
13、启动监听
su - oracle
netca /silent /responsefile /usr/local/oracle/response/netca.rsp
ll $ORACLE_HOME/network/admin/*.ora
lsnrctl start
14、创建静默库
vi /usr/local/oracle/dbca.rsp
gdbName=orcl
sid=orcl
templateName=/usr/local/oracle/product/11.2.0/db_1/assistants/dbca/templates/General_Purpose.dbc
characterSet=AL32UTF8
sysPassword=1qazQAZ1
pdbAdminPassword=1qazQAZ1
systemPassword=1qazQAZ1
createAsContainerDatabase=true
automaticMemoryManagement=false
dbca -silent -createDatabase -responseFile /usr/local/oracle/dbca.rsp -ignorePreReqs
15、查看进程端口
ps -ef | grep oracle | grep -v grep |wc -l
lsnrctl status
16、oracle启动
sqlplus / as sysdba
创建用户及密码:
create user C##test identified by passwd;
修改用户及密码:
alter user C##test identified by password;
修改用户权限:
alter user C##test account unlock;
grant create session to C##test;
grant dba to C##test;
GRANT CREATE USER,DROP USER,ALTER USER,CREATE ANY VIEW,DROP ANYVIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE, DBA,
CONNECT,RESOURCE,CREATE SESSION TO C##test;
connect C##test/password;
17、oracle12_C重启服务
su - oracle
sqlplus / as sysdba
startup;
exit;
lsnrctl start 如果无法成功启动监听,则强制注册服务:
sqlplus / as sysdba
alter system register;
exit;
lsnrctl status 成功则服务已启动。