Centos7_Minimal 靜默安裝 Oracle 12c版本
1.檢查系統版本
[root@oracle ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
2.關閉selinux
[root@oracle ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [root@oracle ~]# getenforce Disabled
3.關閉防火墻
[root@oracle ~]# systemctl stop firewalld
4.修改主機名和hosts文件
[root@oracle ~]# cat /etc/hostname oracle [root@oracle ~]# cat /etc/hosts oracle 172.18.135.72
5.升級系統
[root@oracle ~]# yum update -y
6.安裝依賴包和java環境
[root@oracle ~]#yum -y install binutils compat-libstdc++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devel libstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat* unixODBC* wget unzip [root@oracle ~]# yum -y install java-1.8.0-openjdk*
7.創建用戶,組
[root@oracle ~]# groupadd oinstall [root@oracle ~]# groupadd dba [root@oracle ~]# useradd -g oinstall -G dba oracle [root@oracle ~]# passwd oracle 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@oracle ~]# id oracle uid=1004(oracle) gid=1005(oinstall) groups=1005(oinstall),1006(dba)
8.創建軟件安裝目錄,並賦權限
[root@oracle ~]# mkdir -p /opt/oracle $ORACLE_BASE [root@oracle ~]# mkdir -p /opt/oracle/12c $ORACLE_HOME [root@oracle ~]# mkdir /opt/oracle/oradata 數據存放目錄 [root@oracle ~]# mkdir /opt/oracle/inventory 清單目錄 [root@oracle ~]# mkdir /opt/oracle/flash_recovery_area 數據恢復目錄 [root@oracle ~]# chown -R oracle:oinstall /opt/oracle [root@oracle ~]# chmod -R 775 /opt/oracle
9.修改系統參數
[root@oracle ~]# vim /etc/sysctl.conf
fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500
[root@oracle ~]# sysctl -p (啟動生效)
10. 修改用戶限制文件
[root@oracle ~]# vim /etc/security/limits.conf
oracle soft nofile 1024 oracle hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft stack 10240 oracle hard stack 32768
11.關聯設置
[root@oracle ~]# vi /etc/pam.d/login
session required /lib64/security/pam_limits.so session required pam_limits.so
12.設置環境變量
[root@oracle ~]# vim /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
[root@oracle ~]# source /etc/profile (執行)
13.配置oracle用戶環境變量(切換oracle用戶)
[oracle@oracle ~]$ vim .bash_profile
# For Oracle export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/12c export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi
[oracle@oracle ~]$ source .bash_profile
14.官網下載oracle 12c版本安裝包,上傳至/opt/oracle 目錄
[oracle@oracle oracle]$ pwd /opt/oracle [oracle@oracle oracle]$ ls 12c flash_recovery_area inventory linuxamd64_12102_database_1of2.zip linuxamd64_12102_database_2of2.zip oradata
15.接下來用oracle用戶解壓
[oracle@oracle oracle]$ unzip linuxamd64_12102_database_1of2.zip [oracle@oracle oracle]$ unzip linuxamd64_12102_database_2of2.zip
16.解壓完成可以看到目錄/opt/oracle/database/response有3個應答文件,
分別數據庫安裝文件、建立數據庫實例和監聽配置安裝文件
[oracle@oracle oracle]$ ll /opt/oracle/database/response/ total 112 -rwxrwxr-x 1 oracle oinstall 74822 Apr 4 2014 dbca.rsp -rw-rw-r-- 1 oracle oinstall 25036 Jul 7 2014 db_install.rsp -rwxrwxr-x 1 oracle oinstall 6038 Jan 24 2014 netca.rsp [oracle@oracle oracle]$
17.修改數據庫安裝文件db_install.rsp
[oracle@oracle oracle]$ vim /opt/oracle/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY #安裝類型 ORACLE_HOSTNAME=oracle #主機名稱 UNIX_GROUP_NAME=oinstall #安裝組 INVENTORY_LOCATION=/opt/oracle/inventory #清單目錄 SELECTED_LANGUAGES=en,zh_CN #選擇語言 ORACLE_HOME=/opt/oracle/12c/ # oracle_home ORACLE_BASE=/opt/oracle #oracle_base oracle.install.db.InstallEdition=EE #oracle版本 oracle.install.db.DBA_GROUP=dba #dba用戶組 oracle.install.db.OPER_GROUP=oinstall #oper用戶組 oracle.install.db.BACKUPDBA_GROUP=dba oracle.install.db.DGDBA_GROUP=dba oracle.install.db.KMDBA_GROUP=dba oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #數據庫類型 oracle.install.db.config.starterdb.globalDBName=orcl #globalDBName oracle.install.db.config.starterdb.SID=orcl #SID oracle.install.db.config.starterdb.memoryLimit=81920 #自動管理內存的最小內存(M) oracle.install.db.config.starterdb.password.ALL=oracle #設定所有數據庫用戶使用同一個密碼 DECLINE_SECURITY_UPDATES=true #設置安全更新
18.開始安裝,等的時間有點長,可以通過下圖查看後臺日誌安裝進程,tail -f log ,安裝過程有警告可忽略,如下圖即為安裝成功,根據圖示操作
[oracle@oracle ~]$ cd /opt/oracle/database/ [oracle@oracle database]$ ./runInstaller -silent -responseFile /opt/oracle/database/response/db_install.rsp -ignorePrereq
19.切換root用戶執行上圖腳本,然後回到oracle用戶按enter就可以
20.查看默認的監聽文件,並安裝監聽應答文件
[oracle@oracle ~]$ vim /opt/oracle/database/response/netca.rsp
INSTALL_TYPE=""custom""安裝的類型 LISTENER_NUMBER=1監聽器數量 LISTENER_NAMES={"LISTENER"}監聽器的名稱列表 LISTENER_PROTOCOLS={"TCP;1521"}監聽器使用的通訊協議列表 LISTENER_START=""LISTENER""監聽器啟動的名稱
[oracle@oracle ~]$ netca /silent /responseFile /opt/oracle/database/response/netca.rsp
21.上述命令執行成功後,會在/opt/oracle/12c/network/admin中生成listener.ora和sqlnet.ora文件
[oracle@oracle ~]$ ls /opt/oracle/12c/network/admin/
listener.ora samples shrept.lst sqlnet.ora
22.安裝完成後可以查看端口1521是否起來
[oracle@oracle ~]$ netstat -tulnp |grep 1521
23.添加數據庫實例,修改dbca.rsp文件
[oracle@oracle ~]$ vim /opt/oracle/database/response/dbca.rsp
RESPONSEFILE_VERSION = "12.1.0" #默認 OPERATION_TYPE = "createDatabase" #默認 GDBNAME = "orcl" #數據庫名字 SID = "orcl" #對應的實例名 TEMPLATENAME = "General_Purpose.dbc" #默認 SYSPASSWORD = "oracle" #sys密碼 SYSTEMPASSWORD = "oracle" #system密碼 DBSNMPPASSWORD = "oracle" #dbs密碼 DATAFILEDESTINATION =/opt/oracle/oradata #清單目錄 RECOVERYAREADESTINATION=/opt/oracle/flash_recovery_area #恢復數據目錄 CHARACTERSET = "AL32UTF8" #字符集,重要!!!建庫後一般不能更改
24.執行數據庫實例安裝
[oracle@oracle ~]$ cd /opt/oracle/12c/bin/
[oracle@oracle bin]$ dbca -silent -responseFile /opt/oracle/database/response/dbca.rsp
25.查看實例進程,監聽狀態
[oracle@oracle bin]$ ps -ef |grep ora_ |grep -v grep
26.查看實例狀態
[oracle@oracle ~]$ sqlplus / as sysdba
27.oracle的一些命令
開啟racle服務:
$dbstart
$lsnrctl start
$sqlplus / as sysdba
SQL>startup
關閉oracle服務:
$dbshut
$lsnrctl stop
$sqlplus / as sysdba
SQL>shutdown /shutdown immediate
Centos7_Minimal 靜默安裝 Oracle 12c版本