前言相信大家第一次接觸Oracle,大都是在windows上安裝,比較方便快捷,基本上是一直下一步就可以安裝成功。然而企業(yè)級(jí)的數(shù)據(jù)庫(kù),基本上都是安裝在Linux服務(wù)器上,安全且高效。 沒接觸Linux的朋友不用害怕,跟著本篇文章一步步操作,安裝Oracle如喝水般簡(jiǎn)單且標(biāo)準(zhǔn)。 下面我就來手把手教大家如何在Linux上安裝Oracle數(shù)據(jù)庫(kù)。 一、前期準(zhǔn)備1、虛擬機(jī)安裝包
2、Oracle軟件安裝包
?? 注意: Oracle 官方網(wǎng)站目前只能下載最新版 19C 和 21C,需要其他版本 Oracle 安裝包可點(diǎn)擊鏈接跳轉(zhuǎn)獲取: https://mp.weixin.qq.com/s/ECJelOb6NUjZjpUvUa17pg 或者 可以獲取 百度網(wǎng)盤下載鏈接 以及博主的聯(lián)系方式 3、Linux系統(tǒng)安裝包一般有三種Linux系統(tǒng)比較常用:RedHat 、 OracleLinux 、Centos 。
?? 注意: 上述 Linux 安裝包 可點(diǎn)擊鏈接跳轉(zhuǎn)獲?。?/p> https://mp.weixin.qq.com/s/PFKkftgaTWpJKCnhI3uxZw 或者 可以獲取 百度網(wǎng)盤下載鏈接 以及博主的聯(lián)系方式 4、Linux遠(yuǎn)程連接工具本文將使用XShell和Xftp工具,安裝包可以在官網(wǎng)下載,也可私信博主獲取。 其他工具也可以,比如:putty,SecureCRT 等等工具。 這篇博客演示RedHat Linux 7.6 版本安裝Oracle 11GR2版本數(shù)據(jù)庫(kù)。 二、Linux主機(jī)配置安裝 使用XShell工具連接Linux主機(jī)root用戶: 1、主機(jī)名配置如果安裝時(shí)沒有配置主機(jī)名,或者想要修改主機(jī)名,可以通過以下命令修改: hostnamectl set-hostname orcl
2、網(wǎng)絡(luò)配置如果安裝時(shí)沒有配置網(wǎng)絡(luò),或者想要修改網(wǎng)絡(luò),可以通過以下命令修改: nmcli connection modify eth0 ipv4.addresses 10.211.55.188/24 ipv4.gateway 10.211.55.1 ipv4.method manual autoconnect yesnmcli connection up eth0
3、配置Hosts文件根據(jù)上面配置好的主機(jī)名和IP,配置hosts文件: cat <<EOF >>/etc/hosts##OracleBegin## ##Public IP 10.211.55.188 orcl ##OracleEnd## EOF
4、防火墻配置systemctl stop firewalld systemctl disable firewalld
5、Selinux配置selinux修改后需要重啟主機(jī)生效: sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
6、ISO鏡像源配置?? 注意: 需要先掛載主機(jī)鏡像! Parallels Desktop 掛載 Linux 主機(jī)鏡像: mount /dev/cdrom /mntcat <<EOF>/etc/yum.repos.d/local.repo[local]name=localbaseurl=file:///mntgpgcheck=0enabled=1EOF
7、安裝Oracle依賴包如下依賴包從Oracle官方文檔推薦獲?。?/p> yum install -y bc \binutils \compat-libcap1 \compat-libstdc++-33 \gcc \gcc-c++ \elfutils-libelf \elfutils-libelf-devel \glibc \glibc-devel \ksh \libaio \libaio-devel \libgcc \libstdc++ \libstdc++-devel \libxcb \libX11 \libXau \libXi \libXtst \libXrender \libXrender-devel \make \net-tools \nfs-utils \smartmontools \sysstat \e2fsprogs \e2fsprogs-libs \fontconfig-devel \expect \unzip \openssh-clients \readline* \psmisc --skip-broken 檢查是否安裝成功: rpm -q bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ elfutils-libelf elfutils-libelf-devel glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libxcb libX11 libXau libXi libXtst libXrender libXrender-devel make net-tools nfs-utils smartmontools sysstat e2fsprogs e2fsprogs-libs fontconfig-devel expect unzip openssh-clients readline
rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
8、配置ZeroConf##關(guān)閉Zeroconf service的服務(wù)守護(hù)進(jìn)程systemctl stop avahi-daemon.socket systemctl stop avahi-daemon.service systemctl disable avahi-daemon.service systemctl disable avahi-daemon.socket##關(guān)閉NOZEROCONFcat <<EOF >>/etc/sysconfig/network#OracleBegin NOZEROCONF=yes #OracleEnd EOF
9、關(guān)閉透明大頁(yè)和numased -i 's/quiet/quiet transparent_hugepage=never numa=off/' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg
10、配置系統(tǒng)參數(shù)文件##計(jì)算shmall和shmmax值memTotal=$(grep MemTotal /proc/meminfo | awk '{print $2}')totalMemory=$((memTotal / 2048))shmall=$((memTotal / 4))if [ $shmall -lt 2097152 ]; then
shmall=2097152fishmmax=$((memTotal * 1024 - 1))if [ "$shmmax" -lt 4294967295 ]; then
shmmax=4294967295fiecho $shmallecho $shmmax##配置系統(tǒng)參數(shù)cat <<EOF >>/etc/sysctl.conf#OracleBegin
##shmmal's Calculation formula: physical memory 8G:(8*1024*1024*1024)/4096=2097152
##shmmax's Calculation formula: physical memory 8G:(8/2)*1024*1024*1024 -1=4294967295
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = $shmallkernel.shmmax = $shmmaxkernel.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
EOF##系統(tǒng)參數(shù)生效sysctl -p
11、配置系統(tǒng)資源限制cat <<EOF >>/etc/security/limits.conf#OracleBegin oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768 oracle soft nproc 2047 oracle hard nproc 16384 oracle hard memlock 134217728 oracle soft memlock 134217728 #OracleEnd EOFcat <<EOF >>/etc/pam.d/login#OracleBegin session required pam_limits.so session required /lib64/security/pam_limits.so #OracleEnd EOF
12、創(chuàng)建用戶和組/usr/sbin/groupadd -g 54321 oinstall /usr/sbin/groupadd -g 54322 dba /usr/sbin/groupadd -g 54323 oper /usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracleecho oracle | passwd --stdin oracle
13、創(chuàng)建Oracle安裝目錄mkdir -p /u01/app/oracle/product/11.2.0/dbmkdir -p /u01/app/oraInventorymkdir -p /oradatachown -R oracle:oinstall /oradatachown -R oracle:oinstall /u01/appchmod -R 775 /u01/app
14、配置用戶環(huán)境變量cat <<EOF >>/home/oracle/.bash_profile################OracleBegin######################### umask 022 export TMP=/tmp export TMPDIR=\$TMPexport NLS_LANG=AMERICAN_AMERICA.AL32UTF8 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db export ORACLE_HOSTNAME=orcl export ORACLE_TERM=xterm export TNS_ADMIN=\$ORACLE_HOME/network/admin export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib export ORACLE_SID=orcl export PATH=/usr/sbin:\$PATHexport PATH=\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch:\$PATHalias sas='sqlplus / as sysdba' export PS1="[\`whoami\`@\`hostname\`:"'\$PWD]\$ ' EOF
三、Oracle軟件安裝1、Oracle軟件包上傳[root@orcl soft]# ll-rw-r--r--. 1 root root 1395582860 May 31 16:56 p13390677_112040_Linux-x86-64_1of7.zip -rw-r--r--. 1 root root 1151304589 May 31 16:56 p13390677_112040_Linux-x86-64_2of7.zip
2、解壓Oracle軟件安裝包需要按順序解壓1,2安裝包: cd /softunzip -q p13390677_112040_Linux-x86-64_1of7.zipunzip -q p13390677_112040_Linux-x86-64_2of7.zip##授權(quán)/soft給oracle讀寫權(quán)限chown -R oracle:oinstall /soft
3、安裝VNC軟件yum install -y tigervnc*su - oracle vncserver##輸入密碼
4、連接VNC遠(yuǎn)程工具或者直接打開虛擬機(jī)圖形化界面
./runInstaller -jreLoc /etc/alternatives/jre_1.8.0
rpm -e ksh-20120801-142.el7.x86_64rpm -ivh pdksh-5.2.14-37.el5.x86_64.rpm
su - oraclesed -i 's/^\(\s*\$(MK_EMAGENT_NMECTL)\)\s*$/\1 -lnnz11/g' $ORACLE_HOME/sysman/lib/ins_emagent.mk 執(zhí)行完點(diǎn)擊retry重試: /u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/db/root.sh
四、創(chuàng)建數(shù)據(jù)庫(kù)1、打開監(jiān)聽su - oracle lsnrctl start lsnrctl status
2、連接VNC遠(yuǎn)程工具或者直接打開虛擬機(jī)圖形化界面dbca
五、連接數(shù)據(jù)庫(kù)確保監(jiān)聽正常啟動(dòng),并監(jiān)聽數(shù)據(jù)庫(kù): 1、通過數(shù)據(jù)庫(kù)主機(jī)連接su - oracle sqlplus / as sysdbaselect sysdate from dual;##創(chuàng)建數(shù)據(jù)庫(kù)用戶create user test identified by test;grant dba to test;conn test/test##創(chuàng)建表create table test (id number not null,name varchar2(100));insert into test values (1,'lucifer');commit; 2、通過PL/SQL連接test用戶
|
|
|