我以 CentOS-7-x86_64-Minimal-1708.iso 爲例,簡述Oracle 11g的安裝過程。html
因爲是使用靜默模式(silent)安裝的,無需使用圖形化界面,我選擇了最小安裝的服務器版的CentOS 7。linux
安裝完成後,只有命令行界面。c++
Oracle官方網站sql
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.htmlshell
個人機器安裝的是CentOS7 64位系統,所以下載的Oracle版本也是64位的數據庫
11.2.0.2.0 zlinux64版本的Oracle是安裝在IBM服務器的,CentOS 7是沒法安裝的。vim
下載完成後,有兩個壓縮文件centos
linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zipbash
經過Xftp將壓縮文件上傳到 /usr/local/服務器
安裝依賴包以前,我的建議將yum源修改成aliyun源,下載速度快些,執行以下命令便可:
cd /etc
mv yum.repos.d yum.repos.d.bak
mkdir yum.repos.d
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
修改爲功後,安裝以下依賴包:
yum -y install binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel
安裝完成後顯示以下界面
使用以下命令檢查依賴是否安裝完整
rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel | grep "not installed"
發現 pdksh 沒有安裝
執行 yum -y install pdksh,發現CentOS 7 沒有相關安裝包可用
經過wget命令直接下載pdksh的rpm包,我下載到了/tmp/
wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
下載完成後,進入 /tmp/
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
再次檢查依賴包是否安裝完整
rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
pdksh \
sysstat \
unixODBC \
unixODBC-devel | grep "not installed"
到此依賴包安裝完整
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
添加完成後,查看oracle用戶
id oracle
初始化oracle用戶的密碼
passwd oracle
vim /etc/hosts
192.168.154.154 centos-orcl(不要改變後面配置監聽時需用到,否則監聽配不成功)
測試hostname
ping -c 3 centos-orcl
kernel.shmmax 參數設置爲物理內存的一半
vim /etc/sysctl.conf
fs.aio-max-nr=1048576
fs.file-max=6815744
kernel.shmall=2097152
kernel.shmmni=4096
kernel.shmmax = 1073741824
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
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
vim /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
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
mkdir -p /usr/local/oracle/product/11.2.0
mkdir /usr/local/oracle/oradata
mkdir /usr/local/oracle/inventory
mkdir /usr/local/oracle/fast_recovery_area
chown -R oracle:oinstall /usr/local/oracle
chmod -R 775 /usr/local/oracle
su - oracle
vim .bash_profile
umask 022
export ORACLE_HOSTNAME=centos-orcl(不要改變後面配置監聽時需用到,否則監聽配不成功)
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
以上配置完成後,我的建議重啓下系統
reboot
cd /usr/local/
unzip linux.x64_11gR2_database_1of2.zip -d /usr/local
unzip linux.x64_11gR2_database_2of2.zip -d /usr/local
解壓完成後
mkdir /usr/local/etc/
cp /usr/local/database/response/* /usr/local/etc/
vim /usr/local/etc/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/usr/local/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOSTNAME=centos-oracle
ORACLE_HOME=/usr/local/oracle/product/11.2.0
ORACLE_BASE=//usr/local/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
開始安裝
su - oracle
cd /usr/local/database
能夠看見database文件夾下有三個模板其中dbca.rsp是用來建立數據庫的。db_install.rsp是用來安裝Oracle軟件的。netca.rsp是用來建立監聽器的
./runInstaller -silent -ignorePrereq -responseFile /usr/local/etc/db_install.rsp
安裝期間能夠使用tail命令監看oracle的安裝日誌
tail -f /usr/local/oracle/inventory/logs/installActions2017-07-12_03-48-29PM.log
安裝完成,提示Successfully Setup Software.
根據提示完成配置
su root
sh /usr/local/oracle/inventory/orainstRoot.sh
sh /usr/local/oracle/product/11.2.0/root.sh
su - oracle
netca /silent /responsefile /usr/local/etc/netca.rsp
查看監聽端口
netstat -tnulp | grep 1521(監聽配置成功)
TOTALMEMORY 設置爲總內存的80%
vi /usr/local/etc/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/usr/local/oracle/oradata
RECOVERYAREADESTINATION=/usr/local/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
執行靜默建庫
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName test -sysPassword oracle -systemPassword oracle
查看oracle實例進程
ps -ef | grep ora_ | grep -v grep
查看監聽狀態
lsnrctl status
報錯:The listener supports no services
解決方案:修改/usr/local/oracle/product/11.2.0/network/admin/listener.ora
在LISTENER裏添加內容:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
#BEQUEATH CONFIG
(GLOBAL_DBNAME=orcl)
(SID_NAME=orcl)
(ORACLE_HOME=/u01/app/oracle/product/11.2)
#PRESPAWN CONFIG
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
重啓監聽器,問題解決。
http://blog.csdn.net/snowfoxmonitor/article/details/47705885
登陸sqlplus,查看實例狀態
sqlplus / as sysdba
select status from v$instance;
報錯:ORA-01034: ORACLE not available
解決方案:startup
報錯:ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/usr/local/oracle/product/11.2.0/dbs/initORCL.ora'
解決方案:將/usr/local/oracle/admin/test/pfile/init.ora.1014201721194修更名稱放到/usr/local/oracle/product/11.2.0/dbs/initORCL.ora
再次startup命令解決
查看數據庫編碼
select userenv('language') from dual;
查看數據庫版本信息
select * from v$version;
激活scott用戶
alter user scott account unlock;
alter user scott identified by tiger;
select username,account_status from all_users;
開放1521端口
firewall-cmd --zone=public --add-port=1521/tcp --permanent
firewall-cmd --reload
官方網站
https://www.allroundautomations.com/plsqldev.html
1,下載 plsqldev1206x64.msi(最好使用代理)
安裝plsql
二、下載32位的 oci.dll 文件
oracle 官方提供免費下載,http://www.oracle.com/technetwork/topics/winsoft-085727.html 須要Oracle帳號登錄
由於PLSQL Developer 爲32位軟件,故在訪問 Oracle 11g 64位數據庫時,需首先通過32位的oci.dll這個中間人再與64位oracle 數據庫通訊。故在PLSQL Developer訪問 64位oracle 數據庫時,必需要能能找到 32位的 oci.dll文件位置。
3,將instantclient-basic-nt-12.1.0.1.0.zip解壓到本地的一個目錄下
在instantclient_11_2目錄下新建兩層文件夾/NETWORK/ADMIN,再將/usr/local/oracle/product/11.2.0/network/admin/tnsnames.ora文件放到ADMIN文件夾下。其中tnsnames.ora文件的HOST屬性改爲外網IP
四、進行PL/SQL Developer的配置:
安裝完成以後,運行PL/SQL Developer,此時出現的登陸窗體不能進行登陸,點擊Calcel按鈕,這時會在無登陸狀態下進入。
5,配置相應信息,把以前的解壓包信息配置上:
六、從新啓動PL/SQL Developer進行登陸。
輸入相應的信息就能夠進行鏈接登陸。
用戶名使用剛激活的scott,密碼爲tiger,填完以上信息後點擊鏈接
到此PLSQL遠程鏈接Oracle數據庫成功
vi /usr/local/oracle/product/11.2.0/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /usr/local/oracle/product/11.2.0/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
vi /etc/oratab
orcl:/usr/local/oracle/product/11.2.0:Y
vi /etc/rc.d/init.d/oracle
[plain] view plain copy
#! /bin/bash
# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
# processname: oracle
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/usr/local/oracle/product/11.2.0
ORACLE_USER=oracle
case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0
開機啓動oracle
systemctl enable oracle
oracle ORA-12547: TNS:lost contact
cd /usr/local/oracle/product/11.2.0/bin/
chmod 6751 oracle
TNS-12555: TNS:permission denied
cd /var/tmp
chown -R oracle:oinstall .oracle
oracle.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig oracle on
cd /etc/init.d
cat oracle
#!/bin/bash
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
有(# chkconfig:和# description: )這兩個選項說明文件是正確的
再看oracle文件權限問題
修改權限chmod +x /etc/init.d/oracle