共计 14728 个字符,预计需要花费 37 分钟才能阅读完成。
几种必须静默装置的状况
- 服务器为了缩小资源占用,没装置图形组件
- 不能进入机房,只能近程 SSH
- 想炫 (Z) 耀(B),静默装置显得有技术含量
磁盘分区要求
如没有特地要求,装机时可按如下分区比拟好治理
/boot ext3 100M
Swap swap 32G #个别和内存一样大
/u01 ext3 800G #Oracle 装置目录和数据库数据文件寄存目录,大小要大于预估的全副数据量
/opt ext3 5G
/tmp ext3 2G
/ ext3 残余空间
装置步骤纲要
没明确指出操作账号的步骤,请认真看命令后面是井号还是美元,井号就是用 root 做的,美元就是用 oracle 做的。
- 装前查看
- 创立组和用户
- 批改内核参数
- 批改用户限度
- 敞开 SELinux 及防火墙
- 创立装置目录
- 设置环境变量
- 执行 runInstaller 装置 Oracle
- 执行 dbca 建设数据库
- 配置 tnsnames.ora
- 执行 lsnrctl 启动监听,PLSQL 连贯
装置前查看
两个安装包
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
Oracle 版本是 11.2.0.1.0
Linux 版本 Red Hat Enterprise Linux Server release 6.6 (Santiago)
物理内存查看:
至多 4G,查看物理内存命令:
# grep MemTotal /proc/meminfo
虚拟内存查看:
物理内存 4 -8G,虚拟内存为 2 倍物理内存;
物理内存 8 -32G,虚拟内存为 1.5 倍物理内存;
物理内存 >32G,虚拟内存等于物理内存;
查看虚拟内存命令:
# grep SwapTotal /proc/meminfo
依赖包查看
rpm -q \
binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
elfutils-libelf-devel-static \
expat \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
ksh \
sysstat \
numactl-devel \
kernel-headers \
libgomp \
unixODBC \
unixODBC-devel | grep "not installed"|awk '{print $2;}'
输出上面几个包,阐明零碎没有
compat-libstdc++-33
elfutils-libelf-devel
elfutils-libelf-devel-static
gcc
gcc-c++
libaio-devel
libstdc++-devel
ksh
numactl-devel
unixODBC
unixODBC-devel
配好 yum 源,一一 yum install 下面的包。
创立组和用户
[root@ORATEST]# groupadd oinstall
[root@ORATEST]# groupadd dba
[root@ORATEST]# useradd -g oinstall -G dba oracle
[root@ORATEST]# passwd oracle
Changing password for user oracle.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: #此处明码输出 oracle,BAD PASSWORD 提醒不必管
passwd: all authentication tokens updated successfully.
批改内核参数
# vi /etc/sysctl.conf
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
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
fs.aio-max-nr = 1048576
使设置失效
#sysctl -p
查看设置是否胜利
[root@ORATEST ~]# sysctl kernel.sem fs.file-max net.ipv4.ip_local_port_range net.core.rmem_default net.core.rmem_max net.core.wmem_default net.core.wmem_max fs.aio-max-nr
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
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
fs.aio-max-nr = 1048576
用户限度设置
# vi /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
vi /etc/pam.d/login
session required /lib64/security/pam_limits.so
session required pam_limits.so
# vi /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
敞开 SELinux 及防火墙
查看 SELinux 状态:sestatus
永恒敞开 SELinux,需重启:# vi /etc/sysconfig/selinux
#SELINUX=enforcing
SELINUX=disabled
即时敞开 SELinux 指令:setenforce 0 或者 setenforce permissive
敞开防火墙:Linux6 及以下:查看防火墙状态:service iptables status
重启后失效
敞开:chkconfig iptables off
即时敞开防火墙指令
敞开:service iptables stop
创立装置目录
[root@ORATEST ~]# mkdir -p /u01/app/
[root@ORATEST ~]# chown -R oracle:oinstall /u01/app/
[root@ORATEST ~]# chmod -R 775 /u01/app/
配置环境变量
[root@ORATEST ~]# su - oracle
[oracle@ORATEST ~]$ vi /home/oracle/.bash_profile vi /home/oracle/.bash_profile
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_SID=oral; export ORACLE_SID
export ORACLE_OWNER=oracle
export PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/local/bin:/usr/sbin:/usr/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/oracm/lib:/lib:/usr/lib:/usr/local/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
export SPFILE_PATH=$ORACLE_HOME/dbs
export ORA_NLS10=$ORACLE_HOME/nls/data
umask 022
新开个会话,以 Oracle 账号登陆,查看环境是否失效
[oracle@ORATEST ~]$ env | more
[oracle@ORATEST ~]$ umask
以 root 账号,新建 oraInst.loc,执行
# vi /etc/oraInst.loc
inventory_loc=/u01/app/oracle/oraInventory
inst_group=oinstall
[root@ORATEST ~]# chown oracle:oinstall /etc/oraInst.loc
[root@ORATEST ~]# chmod 664 /etc/oraInst.loc
执行 runInstaller 装置 Oracle
批改 host 文件
[root@ORATEST ~]# vi /etc/hosts
...
127.0.0.1 ORATEST #最初加上这行
将两个安装包上传到 /u01/app,确保安装包属于 oracle 用户
[root@ORATEST app]# chown -R oracle:oinstall *.zip
[root@ORATEST app]# ll
total 2295600
-rw-r--r--. 1 oracle oinstall 1239269270 Jan 22 14:29 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 oracle oinstall 1111416131 Jan 22 14:29 linux.x64_11gR2_database_2of2.zip
如果曾经属于 oracle 用户,下面步骤不必做。
在 oracle 账号下,按程序解压
[oracle@ORATEST app]$unzip linux.x64_11gR2_database_1of2.zip
[oracle@ORATEST app]$unzip linux.x64_11gR2_database_2of2.zip
解压后文件都在 database 目录里
[oracle@ORATEST app]$ ll
total 2295604
drwxr-xr-x. 8 oracle oinstall 4096 Aug 21 2009 database
-rw-r--r--. 1 oracle oinstall 1239269270 Jan 22 14:29 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 oracle oinstall 1111416131 Jan 22 14:29 linux.x64_11gR2_database_2of2.zip
拷贝装置配置模板文件到当前目录(/u01/app)下
[oracle@ORATEST app]$ cp database/response/db_install.rsp .
创立三个目录,oracle 是装置目录,oradata 是数据文件目录,oradatabackup,是数据文件备份目录
[oracle@ORATEST app]$ mkdir oracle
[oracle@ORATEST app]$ mkdir oradata
[oracle@ORATEST app]$ mkdir oradatabackup
编辑 db_install.rsp,编辑后和原始文件差别如下,
[oracle@ORATEST app]$ diff db_install.rsp database/response/db_install.rsp
29c29
< oracle.install.option=INSTALL_DB_AND_CONFIG
---
> oracle.install.option=
37c37
< ORACLE_HOSTNAME=localhost
---
> ORACLE_HOSTNAME=
42c42
< UNIX_GROUP_NAME=oinstall
---
> UNIX_GROUP_NAME=
47c47
< INVENTORY_LOCATION=/u01/app
---
> INVENTORY_LOCATION=
78c78
< SELECTED_LANGUAGES=en,zh_CN
---
> SELECTED_LANGUAGES=
83c83
< ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
---
> ORACLE_HOME=
88c88
< ORACLE_BASE=/u01/app/oracle
---
> ORACLE_BASE=
99c99
< oracle.install.db.InstallEdition=EE
---
> oracle.install.db.InstallEdition=
142c142
< oracle.install.db.DBA_GROUP=dba
---
> oracle.install.db.DBA_GROUP=
147c147
< oracle.install.db.OPER_GROUP=dba
---
> oracle.install.db.OPER_GROUP=
160c160
< oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
---
> oracle.install.db.config.starterdb.type=
165c165
< oracle.install.db.config.starterdb.globalDBName=orcl
---
> oracle.install.db.config.starterdb.globalDBName=
170c170
< oracle.install.db.config.starterdb.SID=orcl
---
> oracle.install.db.config.starterdb.SID=
184c184
< oracle.install.db.config.starterdb.characterSet=ZHS16GBK
---
> oracle.install.db.config.starterdb.characterSet=AL32UTF8
200c200
< oracle.install.db.config.starterdb.memoryLimit=1024
---
> oracle.install.db.config.starterdb.memoryLimit=
233c233
< oracle.install.db.config.starterdb.password.ALL=oracle
---
> oracle.install.db.config.starterdb.password.ALL=
278,279c278
< oracle.install.db.config.starterdb.dbcontrol.emailAddress=test@qq.com
<
---
> oracle.install.db.config.starterdb.dbcontrol.emailAddress=
325c324
< oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
---
> oracle.install.db.config.starterdb.storageType=
333c332
< oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oradata
---
> oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
340c339
< oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oradatabackup
---
> oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
386c385
< DECLINE_SECURITY_UPDATES=true
---
> DECLINE_SECURITY_UPDATES=
这些配置项也能够在装置命令参数里写,本文抉择编辑 db_install.rsp 达到成果。
装置前文件和环境如下
[oracle@ORATEST app]$ ll
total 2295640
drwxr-xr-x. 8 oracle oinstall 4096 Aug 21 2009 database
-rw-r--r--. 1 oracle oinstall 22770 Jan 22 15:15 db_install.rsp
-rw-r--r--. 1 oracle oinstall 1239269270 Jan 22 14:29 linux.x64_11gR2_database_1of2.zip
-rw-r--r--. 1 oracle oinstall 1111416131 Jan 22 14:29 linux.x64_11gR2_database_2of2.zip
drwxr-xr-x. 2 oracle oinstall 4096 Jan 22 14:56 oracle
drwxr-xr-x. 2 oracle oinstall 4096 Jan 22 15:12 oradata
drwxr-xr-x. 2 oracle oinstall 4096 Jan 22 15:12 oradatabackup
[oracle@ORATEST app]$ env | grep ORA
ORACLE_OWNER=oracle
ORA_NLS10=/u01/app/oracle/product/11.2.0/db_1/nls/data
ORACLE_SID=oral
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
执行装置命令
[oracle@ORATEST database]$ ./runInstaller -silent -force -noconfig -ignorePrereq -responseFile /u01/app/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 1628 MB Passed
Checking swap space: must be greater than 150 MB. Actual 65535 MB Passed
Preparing ...
CAUSE: ...
ACTION: ....
[WARNING] [INS-30011] ...
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/app/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Configuration assistants have not been run. This can happen for following reasons - either root.sh is to be run before config or Oracle Universal Installer was invoked with the -noConfig option.
"/u01/app/oracle/product/11.2.0/db_1/cfgtoollogs/configToolAllCommands" script contains all commands to be executed by the configuration assistants. This file may be used to run the configuration assistants outside of OUI. Note that you may have to update this script with passwords (if any) before executing the same.
Successfully Setup Software.
输入 Successfully Setup Software 示意装置胜利。同时提醒以 root 账号执行 /u01/app/oracle/product/11.2.0/db_1/root.sh 脚本。
[root@ORATEST ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
Check /u01/app/oracle/product/11.2.0/db_1/install/root_ORATEST_2021-01-25_08-19-46.log for the output of root script
执行完 Oracle 软件装置实现。
建设数据库
oracle 账号执行,拷贝建设数据库的配置文件 dbca.rsp 到 app 目录下
[oracle@ORATEST app]$ cp /u01/app/oracle/product/11.2.0/db_1/assistants/dbca/dbca.rsp .
编辑 dbca.rsp,编写完各我的项目如下
[oracle@ORATEST app]$ cat dbca.rsp | grep -v ^# | grep -v ^$
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "ORCL"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
DATAFILEDESTINATION =/u01/app/oradata
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "8000"
[createTemplateFromDB]
SOURCEDB = "myhost:1521:orcl"
SYSDBAUSERNAME = "system"
TEMPLATENAME = "My Copy TEMPLATE"
[createCloneTemplate]
SOURCEDB = "orcl"
TEMPLATENAME = "My Clone TEMPLATE"
[DELETEDATABASE]
SOURCEDB = "orcl"
[generateScripts]
TEMPLATENAME = "New Database"
GDBNAME = "orcl11.us.oracle.com"
[CONFIGUREDATABASE]
[ADDINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
NODELIST=
SYSDBAUSERNAME = "sys"
[DELETEINSTANCE]
DB_UNIQUE_NAME = "orcl11g.us.oracle.com"
INSTANCENAME = "orcl11g"
SYSDBAUSERNAME = "sys"
同样这个文件的内容也能够在执行 dbca 命令时以参数模式输出,本文抉择编辑 dbca.rsp 的形式。
app 目录下执行命令建设数据库
[oracle@ORATEST app]$ dbca -silent -responseFile ./dbca.rsp
Copying database files
1% complete
3% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ORCL/ORCL.log" for further details.
此时数据库曾经启动,能够拜访了。上面指令测试是否胜利
[oracle@ORATEST ~]$ sqlplus / as sysdba
...
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 8351150080 bytes
Fixed Size 2214936 bytes
Variable Size 5100274664 bytes
Database Buffers 3221225472 bytes
Redo Buffers 27435008 bytes
Database mounted.
Database opened.
SQL>
shutdown 和 startup 都胜利执行,阐明数据库失常启动了。
/u01/app/oradata/ORCL 目录下是刚建设数据库 ORCL 的数据文件
[oracle@ORATEST oradata]$ cd ORCL/
[oracle@ORATEST ORCL]$ ll
total 1433964
-rw-r----- 1 oracle oinstall 9748480 Jan 25 15:42 control01.ctl
-rw-r----- 1 oracle oinstall 52429312 Jan 25 15:23 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 25 15:41 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 25 15:23 redo03.log
-rw-r----- 1 oracle oinstall 513810432 Jan 25 15:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall 702554112 Jan 25 15:36 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 Jan 25 11:41 temp01.dbf
-rw-r----- 1 oracle oinstall 78651392 Jan 25 15:36 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Jan 25 15:23 users01.dbf
配置 tnsnames.ora
network/admin 下新建 ora 文件
[oracle@ORATEST ~]$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
webdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.6.2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
近程客户端的 tnsnames.ora 写上雷同的配置。如果近程在 PC 上,ora 文件放在 TNS_ADMIN 环境变量对应的目录下。
执行 lsnrctl 启动监听,PLSQL 连贯
监听的配置文件不必编写,采纳默认配置。查看 webdb 是否解析
[oracle@ORATEST ~]$ tnsping webdb
...
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.6.2)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
TNS-12541: TNS:no listener
能够解析出地址和端口号,否则会报 Failed to resolve name。no listerer 提醒监听程序没有启动,启动监听
[oracle@ORATEST ~]$ lsnrctl start
...
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ORATEST)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 31-JAN-2021 13:55:20
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/ORATEST/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ORATEST)(PORT=1521)))
The listener supports no services
The command completed successfully
启动胜利。
PLSQL 连贯,用户 system,明码 oracle,数据库下拉抉择 webdb,能够胜利登陆。
如果一切顺利,到此功败垂成。如果遇到一些报错请往下看。
一些报错的解决办法
谬误:LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initoral.ora'
解决:[oracle@ORATEST dbs]$ cp /u01/app/oracle/product/11.2.0/db_1/srvm/admin/init.ora ./initoral.ora
谬误:ORA-00371: not enough shared pool memory, should be atleast 307023052 bytes
解决
[oracle@ORATEST dbs]$ vi initoral.ora
# replace "clustdb" with your database name
db_name = orcl
shared_pool_size = 307023052 #按提醒大小改
谬误:ORA-00401: the value for parameter compatible is not supported by this release
解决:[oracle@ORATEST dbs]$ vi initoral.ora
#compatible=9.2.0.0.0
compatible=11.2.0.0.0 #改成 11 版本
谬误:ORA-27504: IPC error creating OSD context
ORA-27300: OS system dependent operation:unsupp_mtu failed with status: 0
ORA-27301: OS failure message: Error 0
ORA-27302: failure occurred at: skgxpvaddr10
ORA-27303: additional information: requested interface 127.0.0.1 mtu not supported. Check output from ifconfig command
解决:cd $ORACLE_HOME/rdbms/lib/
[oracle@ORATEST lib]$ make -f ins_rdbms.mk rac_off ioracle
谬误:ORA-00439: feature not enabled: Real Application Clusters
解决:cd $ORACLE_HOME/rdbms/lib/
[oracle@ORATEST lib]$ make -f ins_rdbms.mk rac_on ioracle
谬误:ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORA-00205: error in identifying control file, check alert log for more info
解决:[root@ORATEST ~]# find / -name init.ora*
/u01/app/oracle/admin/ORCL/pfile/init.ora.025202192615
[oracle@ORATEST dbs]$ sqlplus / as sysdba
...
SQL> startup pfile='/u01/app/oracle/admin/ORCL/pfile/init.ora.025202192615'
ORACLE instance started.
;
Total System Global Area 8351150080 bytes
Fixed Size 2214936 bytes
Variable Size 4697621480 bytes
Database Buffers 3623878656 bytes
Redo Buffers 27435008 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/u01/app/oracle/admin/ORCL/pfile/init.ora.025202192615';
File created.
整库导入
如果新装置的库要导入老库的数据,
在老库服务器以 oracle 用户执行
exp system/oracle@orcl file=./exp.dmp full=y
新库建设完后,什么都不须要做,上传 exp.dmp 后,间接执行
[oracle@ORATEST app]$ imp system/oracle full=y file=./exp.dmp #这里没写实例名 @orcl 因为只有一个 orcl 实例能够省略
就能够胜利导入老库所有数据和用户。
新老数据库的字符集雷同即可,其它环节字符集不同也能够胜利。
总结
终于搞定了传说中装置成功率只有 50% 的 Oracle,还是静默装置,爽。
如果失败了,倡议格式化 u01 分区间接重来。