Oracle 11g 基于CentOS7安装并启动em
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
Oracle 11g 基于CentOS7安裝并啟動em
1、可以在虛擬機或者服務器上安裝centos,具體過程省略,建議使用最小化安裝
以root用戶登錄centos,安裝vim、unzip、lrzsz、wget包
yum install vim -y
yum install unzip -y
yum install lrzsz -y
yum install wget -y
2、更新centos內(nèi)核到最新版本并更換yum源為aliyun源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update
3、通過rz命令上傳oracle11gR2,并解壓縮
[root@CentOS ~]#?cd /tmp
[root@CentOS tmp]#?unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
等待解壓完成后,會在/tmp目錄下生產(chǎn)一個database文件夾,里面就Oracle 11g安裝文件。
4、在/etc/hosts文件中添加主機名
-
在/etc/hosts文件中添加主機名
[root@CentOS tmp]#?vim /etc/hosts
添加192.168.206.135 CentOS
[root@CentOS tmp]#?vim /etc/sysconfig/network
添加NETWORKING=yes
HOSTNAME=CentOS
[root@CentOS tmp]#?hostname CentOS
5、關閉selinux和firewalld
[root@CentOS tmp]#?vim /etc/selinux/config
設置SELINUX=disabled
?
[root@CentOS tmp]#?reboot
[root@CentOS tmp]#?service iptables stop
[root@CentOS ~]#?systemctl stop firewalld
[root@CentOS ~]#?systemctl disable firewalld
6、安裝Oracle 11g依賴包
[root@CentOS tmp]#?yum install 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
7、添加安裝用戶和用戶組
[root@CentOS tmp]#?groupadd oinstall
[root@CentOS tmp]#?groupadd dba
[root@CentOS tmp]#?useradd -g oinstall -G dba oracle
[root@CentOS tmp]#?passwd oracle
[root@CentOS tmp]#?id oracle
uid=1001(oracle) gid=1001(oinstall)?組=1001(oinstall),1002(dba)
8、修改內(nèi)核參數(shù)配置文件
[root@CentOS ~]#?vim /etc/sysctl.conf
添加以下內(nèi)容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax =?2147483648
kernel.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
[root@CentOS ~]# /sbin/sysctl –p
其中kernel.shmmax =?2147483648?為本機物理內(nèi)存(4G)的一半,單位為byte。
9、修改用戶的限制文件
[root@CentOS ~]#?vim /etc/security/limits.conf
添加以下內(nèi)容
oracle?????????? soft??? nproc?????????? 2047
oracle?????????? hard??? nproc?????????? 16384
oracle?????????? soft??? nofile????????? 1024
oracle?????????? hard??? nofile????????? 65536
oracle?????????? soft??? stack?????????? 10240
修改/etc/pam.d/login文件:
[root@CentOS ~]#?vim /etc/pam.d/login
添加以下內(nèi)容:
session? required?? /lib64/security/pam_limits.so
session? required?? pam_limits.so
修改/etc/profile文件:
[root@CentOS ~]# vim /etc/profile
添加以下內(nèi)容:
if [ $USER = "oracle" ]; then
? if [ $SHELL = "/bin/ksh" ]; then
?? ulimit -p 16384
?? ulimit -n 65536
? else
?? ulimit -u 16384 -n 65536
? fi
fi
[root@CentOS ~]# source /etc/profile
10、創(chuàng)建安裝目錄和設置文件權限
[root@CentOS ~]#?mkdir -p /u01/app/oracle/product/11.2.0
[root@CentOS ~]#?mkdir /u01/app/oracle/oradata
[root@CentOS ~]#?mkdir /u01/app/oracle/inventory
[root@CentOS ~]#?mkdir /u01/app/oracle/fast_recovery_area
[root@CentOS ~]#?chown -R oracle:oinstall /u01/app/oracle
[root@CentOS ~]#?chmod -R 775 /u01/app/oracle
11、設置oracle用戶環(huán)境變量
[root@CentOS ~]#?su - oracle
[oracle@CentOS ~]$?vim .bash_profile
添加如下內(nèi)容:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
export? ORACLE_UNQNAME=$ORACLE_SID
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
[oracle@CentOS ~]$ source?.bash_profile
12、編輯靜默安裝響應文件
oracle@CentOS ~]$?cp -R /tmp/database/response/ .
[oracle@CentOS ~]$?cd response/
[oracle@CentOS response]$?vim db_install.rsp
需要設置的選項如下:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=CentOS
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
13、根據(jù)響應文件靜默安裝Oracle 11g
[oracle@CentOS response]$?cd /tmp/database/
[oracle@CentOS database]$?./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
開始Oracle在后臺靜默安裝。安裝過程中,如果提示[WARNING]不必理會,此時安裝程序仍在后臺進行,如果出現(xiàn)[FATAL],則安裝程序已經(jīng)停止了。
可以在以下位置找到本次安裝會話的日志:
/u01/app/oracle/inventory/logs/installActions2015-06-08_04-00-25PM.log
可以切換終端執(zhí)行top命令查看后臺進程一直是在安裝的,/data目錄也在不斷增大,
當出現(xiàn)以下提示時,代表安裝成功:
按照要求執(zhí)行腳本。
打開終端,以root身份登錄,執(zhí)行腳本:
[root@CentOS ~]#?sh /u01/app/oracle/inventory/orainstRoot.sh
[root@CentOS ~]#?sh /u01/app/oracle/product/11.2.0/root.sh
14、以靜默方式配置監(jiān)聽
重新使用oracle用戶登錄
[oracle@CentOS ~]$?netca /silent /responsefile /home/oracle/response/netca.rsp
成功運行后,在/u01/app/oracle/product/11.2.0/network/admin/中生成listener.ora和sqlnet.ora
通過netstat命令可以查看1521端口正在監(jiān)聽。
Yum安裝netstat軟件,軟件包是在net-tools中。
[root@CentOS ~]#?yum install net-tools
[root@CentOS ~]#?netstat -tnulp | grep 1521
15、以靜默方式建立新庫,同時也建立一個對應的實例。
[oracle@CentOS ~]$?vim /home/oracle/response/dbca.rsp
設置以下參數(shù):
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "3277"
其中TOTALMEMORY = "3277"為3277?MB,物理內(nèi)存4G*80%。
進行靜默配置:
[oracle@CentOS ~]$?dbca -silent -responseFile /home/oracle/response/dbca.rsp
建庫后進行實例進程檢查:
[oracle@CentOS ~]$?ps -ef | grep ora_ | grep -v grep
查看監(jiān)聽狀態(tài):
[oracle@CentOS ~]$?lsnrctl status
登錄查看實例狀態(tài):
[oracle@CentOS ~]$?sqlplus / as sysdba
SQL> select status from v$instance;
16、Oracle開機自啟動設置
?1、修改/u01/app/oracle/product/11.2.0/bin/dbstart
?[oracle@CentOS ~]$?vim /u01/app/oracle/product/11.2.0/bin/dbstart
?將ORACLE_HOME_LISTNER=$1修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
?2、修改/u01/app/oracle/product/11.2.0/bin/dbshut
?[oracle@CentOS ~]$?vim /u01/app/oracle/product/11.2.0/bin/dbshut
?將ORACLE_HOME_LISTNER=$1修改為ORACLE_HOME_LISTNER=$ORACLE_HOME
?3、修改/etc/oratab文件
?[oracle@CentOS ~]$?vim /etc/oratab
?將orcl:/u01/app/oracle/product/11.2.0:N中最后的N改為Y,成為orcl:/u01/app/oracle/product/11.2.0:Y
?4、輸入命令dbshut和dbstart測試
?[oracle@CentOS ~]$?dbshut
??
Oracle監(jiān)聽停止,進程消失。
[oracle@CentOS ~]$?dbstart
?
Oracle監(jiān)聽啟動,進程啟動。
[oracle@CentOS ~]$?su -
[root@CentOS ~]#?vim /etc/rc.d/init.d/oracle
添加以下內(nèi)容(有些值如ORACLE_HOME和ORACLE_USER等根據(jù)實際情況可以修改):
?
?
#!/bin/bash # oracle: Start/Stop Oracle Database 11g R2 # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # . /etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0 ORACLE_USER=oracle case "$1" in 'start') if [ -f $LOCKFILE ]; thenecho $0 already running.exit 1fiecho -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 ]; thenecho $0 already stopping.exit 1fiecho -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 ]; thenecho $0 started.elseecho $0 stopped.fi;; *)echo "Usage: $0 [start|stop|status]"exit 1 esac exit 0?
[root@CentOS init.d]#?chmod 755 /etc/init.d/oracle
[root@CentOS ~]#?chkconfig oracle on
8、進行service oracle start/stop/restart測試
9、Reboot重啟查看Oracle監(jiān)聽和實例進程均能自動啟動。
?
17、啟動em
1、刪除早期DBCONSOLE創(chuàng)建的用戶:
2、刪除早期DBCONSOLE創(chuàng)建的對象:
3、重新創(chuàng)建DBCONSOLE:
$emca?-config?dbcontrol?db?-repos?create ?
4、如果提示創(chuàng)建失敗,輸出類似 “Could not complete the configuration. Refer to the log file at /opt/oracle/cfgtoollogs/emca/orcl/emca_*.log for more details.” 的錯誤信息,請查看對應的日志文件, 日志文件的最后一行內(nèi)容如果是 “ORA-00955: name is already used by an existing object”,則需要執(zhí)行一次重建的命令:
$emca?-config?dbcontrol?db?-repos?recreate
在執(zhí)行上面命令的過程中需要根據(jù)提示輸入對應的數(shù)據(jù)庫信息及 SYS、DBSNMP 和?SYSMAN 的登錄密碼,最后輸入 Y 進行確認,如:
STARTED?EMCA?at?Mar?10,?2015?10:03:17?PM??
EM?Configuration?Assistant,?Version?11.2.0.0.2?Production??
Copyright?(c)?2003,?2005,?Oracle.??All?rights?reserved.??
Enter?the?following?information:??
Database?SID:?orcl??
Listener?port?number:?1521??
Listener?ORACLE_HOME?[?/opt/oracle/11g?]:???
Password?for?SYS?user:????
Password?for?DBSNMP?user:????
Password?for?SYSMAN?user:????
Email?address?for?notifications?(optional):???
Outgoing?Mail?(SMTP)?server?for?notifications?(optional): ?
5、檢查 em 的狀態(tài)
$?emctl?status?dbconsole??
Oracle?Enterprise?Manager?11g?Database?Control?Release?11.2.0.1.0???
Copyright?(c)?1996,?2009?Oracle?Corporation.??All?rights?reserved.??
https://hemw-pc:1158/em/console/aboutApplication??
Oracle?Enterprise?Manager?11g?is?running.???
------------------------------------------------------------------??
Logs?are?generated?in?directory?/opt/oracle/11g/hemw-pc_orcl/sysman/log ?
導出用戶數(shù)據(jù)庫數(shù)據(jù):(需要用oracle用戶)
exp system/systempwd@ORCL owner=system file=abcd.dmp
?
轉(zhuǎn)載于:https://my.oschina.net/rootliu/blog/1613507
總結
以上是生活随笔為你收集整理的Oracle 11g 基于CentOS7安装并启动em的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。