##創建用戶和組:
[LanRS@localhost ~]$ su root #切換到root
Password:
[root@localhost LanRS]# groupadd oinstall #創建用戶組oinstall
[root@localhost LanRS]# groupadd dba #創建用戶組dba
[root@localhost LanRS]# usermod -g oinstall -G dba aofis #創建aofis用戶,並加入到oinstall和dba用戶組
[root@localhost LanRS]# passwd aofis #設置用戶aofis的登陸密碼
Changing password for user oracle.
New password: # 密碼
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: # 確認密碼
passwd: all authentication tokens updated successfully.
[root@localhost LanRS]# id aofis # 查看新建的aofis用戶
uid=1001(aofis) gid=1002(dba) groups=1002(dba)
[root@localhost LanRS]#
##創建oracle數據庫安裝目錄
[LanRS@localhost ~]$ su root
Password:
[root@localhost LanRS]# mkdir -p /data/oracle #oracle數據庫安裝目錄
[root@localhost LanRS]# mkdir -p /data/oraInventory #oracle數據庫配置文件目錄
[root@localhost LanRS]# mkdir -p /data/database #oracle數據庫軟件包解壓目錄
[root@localhost LanRS]# cd /data
[root@localhost data]# ls #創建完畢檢查一下(強迫症)
database oracle oraInventory
[root@localhost data]# chown -R aofis:oinstall /data/oracle #設置目錄所有者為oinstall用戶組的oracle用戶
[root@localhost data]# chown -R aofis:oinstall /data/oraInventory
[root@localhost data]# chown -R aofis:oinstall /data/database
[root@localhost data]# chmod -R 775 /data/oracle #為oracle目錄設置權限為 rwx rwx r-x
##修改OS系統標識---oracle默認不支持CentOS
修改文件 /etc/Redhat-release 為以下內容:
# vim /etc/redhat-release
# cat /etc/redhat-release
redhat-7
##關閉防火牆:
# systemctl stop firewalld.service
# systemctl disable firewalld.service #禁止使用防火牆(測試機不需要這個東西)
##關閉SELINUX
# vim /etc/selinux/config
用#注釋掉SELINUXTYPE,並修改SELINUX=disabled
#SELINUX這個東西太高森,是高手玩的...
#配置好外網IP,安裝需要的包文件:(命令 yum install -y 文件名)
#The following packages (or later versions) must be installed:
binutils-2.23.52.0.1-12.el7.x86_64
compat-libcap1-1.10-3.el7.x86_64
compat-libstdc++-33-3.2.3-71.el7.i686(.i686包用 yum install -y)
compat-libstdc++-33-3.2.3-71.el7.x86_64
gcc-4.8.2-3.el7.x86_64
gcc-c++-4.8.2-3.el7.x86_64
glibc-2.17-36.el7.i686
glibc-2.17-36.el7.x86_64
glibc-devel-2.17-36.el7.i686
glibc-devel-2.17-36.el7.x86_64
libaio-0.3.109-9.el7.i686
libaio-0.3.109-9.el7.x86_64
libaio-devel-0.3.109-9.el7.i686
libaio-devel-0.3.109-9.el7.x86_64
libgcc-4.8.2-3.el7.i686
libgcc-4.8.2-3.el7.x86_64
libstdc++-4.8.2-3.el7.i686
libstdc++-4.8.2-3.el7.x86_64
libstdc++-devel-4.8.2-3.el7.i686
libstdc++-devel-4.8.2-3.el7.x86_64
libXi-1.7.2-1.el7.i686
libXi-1.7.2-1.el7.x86_64
libXtst-1.2.2-1.el7.i686
libXtst-1.2.2-1.el7.x86_64
make-3.82-19.el7.x86_64
sysstat-10.1.5-1.el7.x86_64
elfutils-libelf-devel-0.163-3.el7.x86_64
unixODBC-devel-2.3.1-11.el7.x86_64
unixODBC-devel-2.3.1-11.el7.i686
unixODBC-2.3.1-11.el7.x86_64
unixODBC-2.3.1-11.el7.i686
pdksh(我安裝的時候安裝了pdksh包,安裝過ksh包需要將其卸載)使用 rpm -ivh命令安裝該包
(ksh)
#修改內核參數
vi /etc/sysctl.conf
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 1572864
kernel.shmmax = 6442450943
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9600 65500
net.core.rmem_default = 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
#使內核生效:
#sysctl -p
#
#對oracle用戶設置限制,提高軟件運行性能
#vi /etc/security/limits.conf
aofis soft nproc 2047
aofis hard nproc 16384
aofis soft nofile 1024
aofis hard nofile 65536
#配置環境變量:
# vi /home/aofis/.bash_profile 添加一下內容:
# export DISPLAY=:0.0
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LANG=C
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
使以上配置生效:
# source /home/aofis/.bash_profile
##安裝unzip:
#yum install -y unzip
##上傳安裝文件到(/home/aofis/Downloads下),解壓
解壓:#unzip 安裝包名 -d /data/database(將安裝包解壓到指定文件夾database下)
#進入安裝文件目錄:
cd /data/database/database
執行安裝文件(./ 安裝文件)中間沒有空格
--PRVF-0002 Could not retrieve local nodename :
--找不到主機名的對應ip。修改/etc/hosts,添加主機名即可(aofis)。
安裝到70%有出現一個錯誤:
Error in invoking target 'agent nmhs' of makefile '/u01/app/oracle/product/11.2.0/db_1/sysman/lib/ins_emagent.mk'
#用vim 進入錯誤提示上面的路徑名文件
轉到:/$(MK_EMAGENT_NMECTL)
保留安裝過程,另外開啟一個終端窗口,將ins_emagent.mk文件中的$(MK_EMAGENT_NMECTL)更改為$(MK_EMAGENT_NMECTL) -lnnz11,然后在安裝過程中點擊Retry即可
安裝完成后:
sys (sys)
system(system )
(tiger)
#########################啟動數據庫############################
#更改/etc/oratab
ORCL:/data/oracle/product/11.2.0/db_1:N --> 改為Y
#創建啟動Oracle的Init腳本:
# vi /etc/rc.d/init.d/oracle
#######################################################################################
#!/bin/sh
#
# chkconfig: 2345 99 99
#
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_HOME_LISTENER=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
#export JAVA_HOME=$ORACLE_HOME/jdk
export PATH=$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin
export ORACLE_SID=orcl
#export ORACLE_TRACE=Y
export PATH=$JAVA_HOME/bin:$ORACLE_HOME/bin:$PATH
# Source function library.
. /etc/rc.d/init.d/functions
# See how we were called.
case "$1" in
start)
echo "1" > /proc/sys/net/ipv4/ip_forward
# Route 80 -> 8888 for XDB
iptables -t nat -A PREROUTING -m tcp -p tcp --dport 80 -j REDIRECT --to-port 8888
iptables -t nat -A PREROUTING -m tcp -p tcp --dport 21 -j REDIRECT --to-port 2121
su aofis -c "$ORACLE_HOME/bin/lsnrctl start"
su aofis -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su aofis -c "echo alter pluggable database all open';'|$ORACLE_HOME/bin/sqlplus / as sysdba"
su aofis -c "/home/oracle/bin/ords.sh start /home/oracle/ords/ords.war"
;;
stop)
su aofis -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su aofis -c "$ORACLE_HOME/bin/lsnrctl stop"
su aofis -c "/home/oracle/bin/ords.sh stop /home/oracle/ords/ords.war"
;;
restart|reload)
su aofis -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su aofis -c "$ORACLE_HOME/bin/lsnrctl stop"
su aofis -c "/home/oracle/bin/ords.sh stop /home/oracle/ords/ords.war"
su aofis -c "$ORACLE_HOME/bin/lsnrctl start"
su aofis -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su aofis -c "echo alter pluggable database all open';'|$ORACLE_HOME/bin/sqlplus / as sysdba"
su aofis -c "/home/oracle/bin/ords.sh start /home/oracle/ords/ords.war"
;;
status)
$ORACLE_HOME/bin/lsnrctl status
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
#######################################################################################
#賦予腳本權限:
# chmod 755 /etc/rc.d/init.d/oracle
#啟動數據庫:service oracle start
#關閉數據庫:service oracle stop
#設置oracle為開機自啟動:
#賦予啟動腳本執行權限並鏈接好:
#chmod 755 /etc/init.d/oracle
#ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle
#ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
把oracle啟動腳本添加到系統服務里並設置自啟動:
#chkconfig --add oracle
#chkconfig --level 2345 oracle on