1、关闭selinux
sed -i 's#SELINUX=.*#SELINUX=disabled#g' /etc/selinux/config
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
getenforce
2、关闭firewalld防火墙服务
systemctl stop firewalld
systemctl disable firewalld
3、安装依赖
yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686 glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcc libgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat unixODBC unixODBC-devel
4、创建用户
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
5、修改内核参数
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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
sysctl -p
注意:服务器内存过大时需要适当修改。参考
https://blog.csdn.net/weixin_42184548/article/details/116386277
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
mkdir -p /home/u01/app /home/u01/oraInventory /home/u01/oradata /home/soft
chown -R oracle:oinstall /home/u01/app /home/u01/oraInventory /home/u01/oradata
chmod -R 775 /home/u01/app /home/u01/oraInventory /home/u01/oradata
vi /etc/oraInst.loc
inventory_loc=/home/u01/oraInventory
inst_group=oinstall
chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc
cd /home/soft
unzip linux.x64_11gR2_database_1of2.zip
chmod 777 /home/soft/database
chown -R oracle.oinstall /home/soft/database
su - oracle
vi .bash_profile
export ORACLE_BASE=/home/u01/app
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_OWNER=oracle
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
source .bash_profile
cp /home/soft/database/response/* /home/u01/app/
chown oracle:oinstall /home/u01/app/*.rsp
chmod 755 /home/u01/app/*.rsp
/home/soft/database/./runInstaller -silent -force -ignorePrereq -responseFile /home/u01/app/db_install.rsp
(Root)
/home/u01/app/product/12.2.0/db_1/root.sh
(oracle)
netca /silent /responsefile /home/u01/app/netca.rsp
dbca -silent -createDatabase -responseFile /home/u01/app/dbca.rsp
dbca -silent -responseFile /home/u01/app/dbca.rsp (11g)
=============
ps -ef | grep oracle //查看服务状态
echo $ORACLE_SID //查看实例
lsnrctl status //查看监听
6、设置自启
sed –i ‘s/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g’ /home/u01/app/product/12.2.0/db_1/bin/dbstart
sed –i ‘s/ORACLE_HOME_LISTNER=$1/ORACLE_HOME_LISTNER=$ORACLE_HOME/g’ /home/u01/app/product/12.2.0/db_1/bin/dbshut
vi /etc/init.d/oracle
#!/bin/sh
#chkconfig:345 99 10
#description:Oracle 11g R2 AutoRun Servimces
#/etc/rc.d/init.d/oracle
#
#Run-level Startup script for the Oracle Instance, Listener, and
#Web Interface
export ORACLE_BASE=/home/u01/app
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
echo "Oracle Start Succesful!OK."
;;
stop)
# Oracle listener and instance shutdown
su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
echo "Oracle Stop Succesful!OK."
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo $"Usage: `basename $0` {start|stop|reload|restart}"
exit 1
esac
exit 0
vi /etc/oratab. #改成Y
/home/u01/app/product/12.2.0/db_1/root.sh
chmod 777 /etc/rc.d/init.d/oracle
/etc/rc.d/init.d/oracle start
chmod 755 /etc/init.d/oracle
chkconfig --level 35 oracle on
chkconfig --add oracle
==================
数据库用户创建与导入
(oracle用户下)
sqlplus / as sysdba
create user opermonitor identified by tecsun123;
grant create session to sisp_public;
grant connect,resource sisp_public;
grant dba to sisp_public;
exit
chown oracle:oinstall /home/u01/app/admin/orcl/dpdump/cantanSql2.dmp
imp opermonitor/tecsun123@127.0.0.1:1521/orcl file=/home/u01/oradata/dump_bak/sisp_public_20210315.dmp full=y ignore=y
在linux上测试连接数据库命令
sqlplus sys/123456@127.0.0.1:1521/orcl
网友评论