linux安装Oracle11G

参考
https://www.cnblogs.com/mmzs/p/9033112.html
https://www.cnblogs.com/zhaojingyu/p/10050342.html

5、安装Oracle 11g依赖包
yum install gcc make binutils gcc-c++ compat-libstdc+±33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y

yum install gcc
yum install make
yum install binutils
yum install gcc-c++
yum install compat-libstdc+±33elfutils-libelf-devel
yum install elfutils-libelf-devel-static
yum install ksh
yum install libaio
yum install libaio-develnumactl-devel
yum install sysstat
yum install unixODBC
yum install unixODBC-devel
yum install pcre-devel –y

6、添加安装用户和用户组
groupadd oinstall
groupadd dba
groupadd asmadmin
groupadd asmdba
useradd -g oinstall -G dba,asmdba oracle -d /home/oracle

passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

7、修改内核参数配置文件
vi /etc/sysctl.conf

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

查看是否成功写进/etc/sysctl.conf文件中:
sysctl -p
其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte。
2,147,483,648

8、修改用户的限制文件
vi /etc/security/limits.conf

oracle           soft    nproc           2047

oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

vi /etc/pam.d/login

session required  /lib64/security/pam_limits.so

session required pam_limits.so

vi /etc/profile

#oracle配置

if [ $USER = “oracle” ]; then
if [ $SHELL = “/bin/ksh” ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

9、创建安装目录和设置文件权限

mkdir -p /u01/app/ 
chown -R oracle:oinstall /u01/app/ 
chmod -R 775 /u01/app/

chown -R oracle:oinstall /home/oracle  
chmod -R 775 /home/oracle 

mkdir -p /u01/app/oracle/product/11.2.0
mkdir /u01/app/oracle/oradata
mkdir /u01/app/oracle/inventory
mkdir /u01/app/oracle/oraInventory
mkdir /u01/app/oracle/fast_recovery_area


chown -R oracle:oinstall /u01/app/oracle  
chmod -R 775 /u01/app/oracle 

vi /etc/oraInst.loc

inventory_loc=/u01/app/oracle/oraInventory

inst_group=oinstall

chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc

10、设置oracle用户环境变量
首先切换到oracle用户下:

su -l oracle
vi .bash_profile

ORACLE_BASE=/u01/app/oracle	

ORACLE_HOME= O R A C L E B A S E / p r o d u c t / 11.2.0 / d b h o m e 1 O R A C L E S I D = o r c l P A T H = ORACLE_BASE/product/11.2.0/dbhome_1 ORACLE_SID=orcl PATH= ORACLEBASE/product/11.2.0/dbhome1ORACLESID=orclPATH=PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

source .bash_profile
env

11、编辑静默安装响应文件

[root@medicalmatter03 install]# mv database/ /software/

[oracle@medicalmatter03 ~]$ cp -R /software/database/response/ .

复制安装文件夹response到当前oracle用户的家目录下:

vi db_install.rsp

12、根据响应文件静默安装Oracle11g
cd /software/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

如果执行以上命令出错,会提示有参数格式,按照提示参数格式修改修改即可,一般是由于word中的字体、符号格式复制到客户端命令行后不一致引起,修改即可。

静默安装Oracle时提示:"[SEVERE] - Email Address Not Specified"
解决方法:

修改responseFile文件db_install.rsp,将DECLINE_SECURITY_UPDATES=的值设为true,如果为空系统会假设该值为false,DECLINE_SECURITY_UPDATES=的值默认为空。

[oracle@yiwuguanli03 database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer…

Checking Temp space: must be greater than 120 MB. Actual 134191 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-12-20_03-07-26PM. Please wait …[oracle@yiwuguanli03 database]$ You can find the log of this install session at:
/u01/app/oracle/oraInventory/logs/installActions2019-12-20_03-07-26PM.log
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/dbhome_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

Successfully Setup Software.

sh /u01/app/oracle/oraInventory/orainstRoot.sh

13、环境变量

su - oracle

vi ~/.bash_profile

今天在oracle linux下安装oracle软件,遇到一个问题:oracle的环境变量,配置到了~/.bash_profile文件中。在虚拟机中,echo $ORACLE_HOME能正常显示环境变量,但是,用xshell每次重新连接,环境变量就会失效,需要重复手动执行. .bash_profile.

最后在网上查找资料发现,用图形界面登录时,系统会读取~/.bash_profile中的配置信息,所以环境变量可以生效。
但是用命令行登录,例如xshell,系统加载的是~/.bashrc 中的配置信息。
所以,我们把环境变量在~/.bashrc文件中,重新配置一次,问题解决,用命令行就不用每次执行 . .bash_profile命令了。

vi ~/.bashrc

export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl

export ORACLE_HOME= O R A C L E B A S E / p r o d u c t / 11.2.0 / d b h o m e 1 e x p o r t T N S A D M I N = ORACLE_BASE/product/11.2.0/dbhome_1 export TNS_ADMIN= ORACLEBASE/product/11.2.0/dbhome1exportTNSADMIN=ORACLE_HOME/network/admin
export PATH=.: P A T H : {PATH}: PATH:HOME/bin: O R A C L E H O M E / b i n e x p o r t P A T H = ORACLE_HOME/bin export PATH= ORACLEHOME/binexportPATH={PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export LD_LIBRARY_PATH= L D L I B R A R Y P A T H : {LD_LIBRARY_PATH}: LDLIBRARYPATH:ORACLE_HOME/lib
export LD_LIBRARY_PATH= L D L I B R A R Y P A T H : {LD_LIBRARY_PATH}: LDLIBRARYPATH:ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH= L D L I B R A R Y P A T H : / l i b : / u s r / l i b : / u s r / l o c a l / l i b e x p o r t C L A S S P A T H = {LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib export CLASSPATH= LDLIBRARYPATH:/lib:/usr/lib:/usr/local/libexportCLASSPATH={CLASSPATH}: O R A C L E H O M E / J R E e x p o r t C L A S S P A T H = ORACLE_HOME/JRE export CLASSPATH= ORACLEHOME/JREexportCLASSPATH={CLASSPATH}: O R A C L E H O M E / J R E / l i b e x p o r t C L A S S P A T H = ORACLE_HOME/JRE/lib export CLASSPATH= ORACLEHOME/JRE/libexportCLASSPATH={CLASSPATH}: O R A C L E H O M E / j l i b e x p o r t C L A S S P A T H = ORACLE_HOME/jlib export CLASSPATH= ORACLEHOME/jlibexportCLASSPATH={CLASSPATH}: O R A C L E H O M E / r d b m s / j l i b e x p o r t C L A S S P A T H = ORACLE_HOME/rdbms/jlib export CLASSPATH= ORACLEHOME/rdbms/jlibexportCLASSPATH={CLASSPATH}: O R A C L E H O M E / n e t w o r k / j l i b e x p o r t L I B P A T H = ORACLE_HOME/network/jlib export LIBPATH= ORACLEHOME/network/jlibexportLIBPATH={CLASSPATH}: O R A C L E H O M E / l i b : ORACLE_HOME/lib: ORACLEHOME/lib:ORACLE_HOME/ctx/lib
export ORACLE_OWNER=oracle
export SPFILE_PATH= O R A C L E H O M E / d b s e x p o r t O R A N L S 10 = ORACLE_HOME/dbs export ORA_NLS10= ORACLEHOME/dbsexportORANLS10=ORACLE_HOME/nls/data
#export NLS_LANG=‘SIMPLIFIED CHINESE_CHINA.ZHS16GBK’
export NLS_LANG=“AMERICAN_CHINA.ZHS16GBK”

source /home/oracle/.bash_profile

13、以静默方式配置监听

netca /silent /responseFile /home/oracle/response/netca.rsp 

[oracle@yiwuguanli03 ~]$ netca /silent /responseFile /home/oracle/response/netca.rsp 

Parsing command line arguments:
Parameter “silent” = true
Parameter “responsefile” = /home/oracle/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0

14、以静默方式建立新库,同时也建立一个对应的实例

vi /home/oracle/response/dbca.rsp

[GENERAL]

oracle版本,不能更改

RESPONSEFILE_VERSION = “11.2.0”

Description : Type of operation

OPERATION_TYPE = “createDatabase”

[CREATEDATABASE]

Description : Global database name of the database

全局数据库的名字=SID+主机域名

第三方工具链接数据库的时候使用的service名称

GDBNAME = “orcl.test”

Description : System identifier (SID) of the database

对应的实例名字

SID = “orcl”

Description : Name of the template

建库用的模板文件

TEMPLATENAME = “General_Purpose.dbc”

Description : Password for SYS user

SYS管理员密码

SYSPASSWORD = “123456”

Description : Password for SYSTEM user

SYSTEM管理员密码

SYSTEMPASSWORD = “123456”

Description : Password for SYSMAN user

SYSMAN管理员密码

SYSMANPASSWORD = “123456”

Description : Password for DBSNMP user

DBSNMP管理员密码

DBSNMPPASSWORD = “123456”

Description : Location of the data file’s

数据文件存放目录

DATAFILEDESTINATION =/data/oracle/oradata

Description : Location of the data file’s

恢复数据存放目录

RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area

Description : Character set of the database

字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。

(CHARACTERSET = “AL32UTF8” NATIONALCHARACTERSET= “UTF8”)

CHARACTERSET = “ZHS16GBK”

Description : total memory in MB to allocate to Oracle

oracle内存1638MB,物理内存2G*80%

TOTALMEMORY = “1638”

[oracle@yiwuguanli03 ~]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
Enter SYSTEM user password:

Copying database files
1% complete
3% complete
11% complete
18% complete
26% 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.

建库后进行实例进程检查:

ps -ef | grep ora_ | grep -v grep

查看监听状态:

lsnrctl status

sqlplus / as sysdba

SQL> select status from v$instance;

15、命令行模式静默删除
1、首先查看dbca的帮助信息

dbca -help

修改/home/oracle/response/dbca.rsp文件里以下几个参数,下面三个参数根据建库实际情况进行修改:

OPERATION_TYPE = “deleteDatabase”

SOURCEDB = “orcl”

SYSDBAUSERNAME = “sys”

SYSDBAPASSWORD = “123456”

然后运行:

dbca -silent -responseFile /home/oracle/response/dbca.rsp

各参数含义如下:

-silent 表示以静默方式删除

-responseFile 表示使用哪个响应文件,必需使用绝对路径

RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改

OPERATION_TYPE 安装类型,该参数不要更改

SOURCEDB 数据库名,不是全局数据库名,即不包含db_domain

很简单数据库卸载完成了,请注意,只是数据库卸载完了,数据库软件还是在的。

2、使用DBCA卸载数据库

dbca -silent -delete Database -responseFile dbca.rsp

a.选项-silent表示静默安装,免安装交互,大部分安装信息也不输出

b.选项-responseFile指定应答文件,要求用绝对路径

16、建库后实例检查
ps -ef | grep ora_ | grep -v grep | wc -l
ps -ef | grep ora_ | grep -v grep
17、建库后监听检查
lsnrctl status

18、.修改oracle启动配置文件
vi /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
dbstart
dbshut
19、sqlplus / as sysdba

conn /as sysdba 连接到数据本地数据
alter user system identified by password; 修改System 密码 为password
已连接。
SQL> alter user system identified by password;
用户已更改。
SQL> alter user sys identified by password;
用户已更改。
SQL> alter user system identified by manger;
解锁方法
alter user system account unlock;

======================================================

你可能感兴趣的:(Oracle)