一、使用腳本初始化環(huán)境
專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)贊皇免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千余家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
腳本如下:(標(biāo)紅處修改對(duì)應(yīng)的配置需求)
#!/bin/bash
#1.配置主機(jī)名/etc/hosts 并關(guān)閉防火墻及selinux
echo ' 172.168.0.xx linux.tk ' /etc/hosts
#注意修改為服務(wù)器的ip和主機(jī)名
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#2.安裝相關(guān)軟件包
yum -y install telnet vim lszrz gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel
elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat
unixODBC unixODBC-devel pcre-devel wget unzip
#3.配置內(nèi)核參數(shù)
echo "fs.aio-max-nr = 1048576" /etc/sysctl.conf
echo "fs.file-max = 6815744" /etc/sysctl.conf
echo "kernel.shmmni = 4096" /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" /etc/sysctl.conf
echo "net.core.rmem_default = 262144" /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" /etc/sysctl.conf
echo "net.core.wmem_default = 262144" /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" /etc/sysctl.conf
sysctl -p
#4.oracle用戶資源限制
echo "oracle soft nproc 2047" /etc/security/limits.conf
echo "oracle hard nproc 16384" /etc/security/limits.conf
echo "oracle soft nofile 4096" /etc/security/limits.conf
echo "oracle hard nofile 65536" /etc/security/limits.conf
#5.登錄配置
echo "session required /lib64/security/pam_limits.so" /etc/pam.d/login
echo "session required pam_limits.so" /etc/pam.d/login
#改授權(quán)
echo "if [ $USER = 'oracle' ];then" /etc/profile
echo "if [ $SHELL = '/bin/ksh' ];then" /etc/profile
echo "ulimit -p 16384" /etc/profile
echo "ulimit -n 65536" /etc/profile
echo "else" /etc/profile
echo "ulimit -u 16384 -n 65536" /etc/profile
echo "fi" /etc/profile
echo "fi" /etc/profile
source /etc/profile
#6.創(chuàng)建用戶組和用戶
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
echo 'oracle' | passwd --stdin oracle
#7.創(chuàng)建相關(guān)目錄
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app
#8.配置oracle用戶環(huán)境變量
echo "ORACLE_SID=ora; export ORACLE_SID" /home/oracle/.bash_profile
#sid指定為現(xiàn)場的sid
echo "ORACLE_BASE= /u01/app/oracle ; export ORACLE_BASE" /home/oracle/.bash_profile
echo "ORACLE_HOME=$ORACLE_BASE/ product/11.2.0/dbhome_1 ; export ORACLE_HOME" /home/oracle/.bash_profile
echo "ORACLE_PATH=/u01/app/common/oracle/sql; export ORACLE_PATH" /home/oracle/.bash_profile
echo "ORACLE_TERM=xterm; export ORACLE_TERM" /home/oracle/.bash_profile
echo "TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN" /home/oracle/.bash_profile
echo "ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11" /home/oracle/.bash_profile
echo "PATH=.:${JAVA_HOME}/bin:${PATH}:$ORACLE_HOME/bin " /home/oracle/.bash_profile
echo "PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin " /home/oracle/.bash_profile
echo "export PATH " /home/oracle/.bash_profile
echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=$ORACLE_HOME/lib" /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib " /home/oracle/.bash_profile
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib " /home/oracle/.bash_profile
echo "export LD_LIBRARY_PATH" /home/oracle/.bash_profile
echo "export LANG=en_US.UTF-8 " /home/oracle/.bash_profile
echo "export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" /home/oracle/.bash_profile
echo "CLASSPATH=$ORACLE_HOME/JRE " /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib" /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib" /home/oracle/.bash_profile
echo "CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib" /home/oracle/.bash_profile
echo "export CLASSPATH" /home/oracle/.bash_profile
echo "THREADS_FLAG=native; export THREADS_FLAG" /home/oracle/.bash_profile
echo "nls_date_format='yyyy-mm-dd hh24:mi:ss' " /home/oracle/.bash_profile
echo "export nls_date_format " /home/oracle/.bash_profile
echo "export TEMP=/tmp " /home/oracle/.bash_profile
echo "export TMPDIR=/tmp " /home/oracle/.bash_profile
echo "umask 022 " /home/oracle/.bash_profile
source ~/.bash_profile
二、上傳或者下載oracle安裝包并解壓,例如放置在/opt/目錄下
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
直接在目錄解壓,會(huì)在當(dāng)前目錄中生成database目錄
三、修改應(yīng)答文件安裝數(shù)據(jù)庫軟件
修改前建議先備份下
cp /opt/database/response/*.rsp /opt/database/rspbak
3.1、生成修改響應(yīng)文件(/opt/database/response/db_install.rsp)
備注:清空源文件,復(fù)制粘貼如下內(nèi)容(標(biāo)紅處需要修改對(duì)應(yīng)的設(shè)置需求):
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME= linux.tk
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION= /u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE= /u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:10.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
3.2、開始安裝
1)、用oracle用戶登錄操作
# su - oracle
$ cd /opt/database
$ ./runInstaller -silent -responseFile /opt/database/response/db_install.rsp
2)、在安裝過程中可以新開會(huì)話,使用tailf 命令查看進(jìn)度
# tailf /u01/app/oraInventory/logs/installActions2022-XX-XX_03-28-06PM.log
提示安裝結(jié)束,需要在root用戶執(zhí)行兩個(gè)腳本,如下:
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
四、修改應(yīng)答文件安裝數(shù)據(jù)庫實(shí)例(/opt/database/response/dbca.rsp)
安裝實(shí)例前,需要新建一個(gè)實(shí)例存放的目錄(/home/OracleData/),如下:
# mkdir /home/OracleData
# chown -R oracle:oinstall /home/OracleData/
4.1、修改應(yīng)答文件
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "ora"
SID = "ora"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "***012"
SYSTEMPASSWORD = "***012"
DATAFILEDESTINATION = /home/OracleData/
RECOVERYAREADESTINATION = /u01/app/oracle/flash_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "2048"
4.2、建實(shí)例,登錄oracle用戶
# su - oracle
$ dbca -silent -responseFile /opt/database/response/dbca.rsp
此安裝過程是有進(jìn)度顯示,不用tailf查看,不過也可以查看對(duì)應(yīng)的log日志查看進(jìn)度
4.3、刪除實(shí)例
編輯應(yīng)答文件
#vim /opt/database/response/del_dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "deleteDatabase"
[DELETEDATABASE]
SOURCEDB = "ora "
$ dbca -silent -responseFile del_dbca.rsp
五、啟動(dòng)監(jiān)聽,配置自啟動(dòng)等
5.1、啟動(dòng)監(jiān)聽
# su – oracle
$ lsnrctl start
查看狀態(tài) lsnrctl status
# netstat -tnulp | grep 1521
# ps -ef | grep ora_ | grep -v grep
5.2、設(shè)置自啟動(dòng)
修改vim /etc/oratab 如下
ora:/u01/app/oracle/product/11.2.0/dbhome_1: Y
5.3、修改dbstart文件
vim /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
將ORACLE_HOME_LISTNER=$1
修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
5.4、將dbstart加入開機(jī)自啟動(dòng),/etc/rc.d/rc.local中增加
su - oracle -lc /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart
賦權(quán)限 chmod +x /etc/rc.d/rc.local
5.3、登錄數(shù)據(jù)庫設(shè)置權(quán)限等
sqlplus / as sysdba
startup;
alter system register;
create user ora identified by ***012;
grant dba to ora;
exit
六、遠(yuǎn)程連接數(shù)據(jù)庫
6.1、開放1521端口
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd –reload
firewall-cmd --list-ports
①-service iptables stop
###手動(dòng)禁用
②-service iptables off
###禁止開機(jī)自啟動(dòng)
③-禁用selinux
setenforce 0 ###臨時(shí)禁用
vi /etc/sysconfig/selinux ###修改文件將SELINUX=enforcing改為SELINUX=disabled
首先,設(shè)置成共享socket,自己百度 oracle 共享socket
然后,配置允許1521tcp訪問即可
你安裝的可能是客戶端的Oracle,你公司安裝的是Oracle服務(wù)器。你可以在你自己的本機(jī)上安裝Oracle服務(wù)器即可。另外,最好客戶端和服務(wù)器別在一個(gè)盤符下。
oracle12c安裝閃退解決方法如下:
oracle安裝閃退的解決辦法:首先找到Oracle的安裝目錄,并找到名字為2的文件夾;然后刪除這個(gè)文件夾。
最后重新點(diǎn)擊setup、exe即可。以管理員身份運(yùn)行Oracle11g安裝文件stepup、exe文件;打開Oracle11g目錄下database\stage\cvu\cvu_prereq、xml文件。
刪除生成的啟動(dòng)安裝文件目錄,重新以管理員身份運(yùn)行Oracle11g安裝文件stepup、exe文件。
一、問題描述:
安裝好ORACLE服務(wù)器端后,利用PL/SQL連數(shù)據(jù),提示無監(jiān)聽程序。
二、解決步驟:
1.檢查防火墻。
將防火墻關(guān)閉。
2.查看監(jiān)聽服務(wù)。
在管理工具-服務(wù)中查看監(jiān)聽服務(wù)是否已經(jīng)啟動(dòng),如果沒有,請(qǐng)啟動(dòng)。
3.查看注冊(cè)表。
在HKEY_LOCAL_MACHINE-SYSTEM-CurrentControlSet-services中查看監(jiān)聽程序是否注冊(cè)。
1)如果沒有ImagePath字段,就手動(dòng)添加這個(gè)字段,將TNSLSNR.EXE的路徑添加進(jìn)去。
我的是F:\app\Administrator\product\11.2.0\dbhome_1\BIN\TNSLSNR。
2)如果整個(gè)監(jiān)聽程序都未注冊(cè),那么請(qǐng)重新配置監(jiān)聽服務(wù)。步驟如下:
1打開網(wǎng)絡(luò)配置工具(Net Configuration Assistant)
2.選擇監(jiān)聽程序配置,點(diǎn)擊下一步
2.刪除原有的監(jiān)聽配置,直接點(diǎn)下一步即可。如果沒有刪除選項(xiàng)則跳過此步進(jìn)行第3步。
3添加監(jiān)聽程序,也是直接點(diǎn)擊下一步即可。
4.監(jiān)聽服務(wù)添加后,在管理工具-服務(wù)中查看監(jiān)聽服務(wù),并重啟該服務(wù)。
4.查看客戶端的tnsnames.ora文件。