linux安装Oracle11G
linux安装Oracle11G
阅读目录:
阅读正文:
linux安装Oracle11G
0、下载Orcle11G
说明一下: [[email protected] install]#中的myYUn 等价于 [[email protected] install]#中的iz2f570bi1k56uz; 这是为了界面效果调整的,但是有些没调整到,理解一哈。
1、上传文件到服务器或虚拟机的/install目录下
[[email protected] install]# rz –y
如果rz –y命令不能使用,可用如下方法解决:
yum install lrzsz -y
2、解压文件到当前目录:
[[email protected] install]# unzip linux.x64_11gR2_database_1of2.zip
[[email protected] install]# unzip linux.x64_11gR2_database_2of2.zip
如果unzip命令不能使用,依次执行如下命令:
yum list | grep zip/unzip yum install zip yum install unzip
将解压后的文件夹直接移动到/software目录下:
[[email protected] install]# mv database/ /software/
[[email protected] install]# cd /software
[[email protected] install]# ll
3、关闭selinux
[[email protected] software]# vim /etc/selinux/config
设置SELINUX=disabled
[[email protected] software]# setenforce 0
4、关闭防火墙
[[email protected] software]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[[email protected] software]# getconf LONG_BIT
64
如果是6及以下:
[[email protected] software]# service iptables stop
[[email protected] software]# service iptables status
[[email protected] software]# chkconfig iptables off
如果是centenOS7:
[[email protected] software]# systemctl restart firewalld.service
[[email protected] software]# systemctl list-unit-files|grep firewalld.service
firewalld.service disabled
[[email protected] software]# systemctl disable firewalld.service
5、安装Oracle 11g依赖包
[[email protected] software]# 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
6、添加安装用户和用户组
[[email protected] software]# groupadd oinstall
[[email protected] software]# groupadd dba
[[email protected] software]# useradd -g oinstall -G dba oracle
[[email protected] software]# 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.
[[email protected] software]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
7、修改内核参数配置文件
[[email protected] software]# vim /etc/sysctl.conf
在末尾添加以下内容:
fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1073741824 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文件中:
[[email protected] software]# sysctl -p
其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte。
8、修改用户的限制文件
修改/etc/security/limits.conf文件:
[[email protected] software]# vim /etc/security/limits.conf
在末尾添加以下内容:
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
修改/etc/pam.d/login文件:
[[email protected] software]# vim /etc/pam.d/login
在末尾添加以下内容:
session required /lib64/security/pam_limits.so session required pam_limits.so
修改/etc/profile文件:
[[email protected] myYUn software]# vim /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、创建安装目录和设置文件权限
[[email protected] software]# mkdir -p /data/oracle/product/11.2.0
[[email protected] software]# mkdir /data/oracle/oradata
[[email protected] software]# mkdir /data/oracle/inventory
[[email protected] software]# mkdir /data/oracle/fast_recovery_area
[[email protected] software]# chown -R oracle:oinstall /data/oracle
[[email protected] software]# chmod -R 775 /data/oracle
10、设置oracle用户环境变量
首先切换到oracle用户下:
[[email protected] software]# su -l oracle
[[email protected] ~]$ vim .bash_profile
在末尾添加如下内容:
ORACLE_BASE=/data/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
注意,标红处必须与创建的数据库实例名称一致,否则数据库启动后无法访问。第一次配置完记得source一下。
[[email protected] ~]$ source .bash_profile
11、编辑静默安装响应文件
复制安装文件夹response到当前oracle用户的家目录下:
[[email protected] ~]$ cp -R /software/database/response/ .
[[email protected] ~]$ cd response/
[[email protected] response]$ vim db_install.rsp
需要设置的选项如下:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=CentOS
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0
ORACLE_BASE=/data/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
12、根据响应文件静默安装Oracle11g
[[email protected] response]$ cd /software/database/
[[email protected] database]$ ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
如果执行以上命令出错,会提示有参数格式,按照提示参数格式修改修改即可,一般是由于word中的字体、符号格式复制到客户端命令行后不一致引起,修改即可。
楼主遇到了交换空间不足的问题:
解决方案如下(在root用户下执行):
[[email protected] /]# free
[[email protected] /]# dd if=/dev/zero of=swapfile bs=1024 count=500000
500000+0 records in
500000+0 records out
512000000 bytes (512 MB) copied, 1.67013 s, 307 MB/s
[[email protected] /]# mkswap swapfile
Setting up swapspace version 1, size = 499996 KiB
no label, UUID=c5e355eb-e73e-4aa0-b882-cb6d1f88e6bc
[[email protected] /]# swapon swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[[email protected] /]# free
开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现Successfully Setup Software,则安装程序已经停止了。
可以在以下位置找到本次安装会话的日志:/data/oracle/inventory/logs/installActions2018-05-13_02-14-55PM.log
可以切换终端执行top命令查看后台进程一直是在安装的,/data目录也在不断增大,
当出现以下提示时,代表安装成功:
按照要求执行脚本。
打开终端,退出到root身份登录,执行脚本:
[[email protected] database]$ exit
logout
[[email protected] software]# sh /data/oracle/inventory/orainstRoot.sh
Changing permissions of /data/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /data/oracle/inventory to oinstall.
The execution of the script is complete.
[[email protected] software]# sh /data/oracle/product/11.2.0/root.sh
Check /data/oracle/product/11.2.0/install/root_iZ2f570bi1k56uZ_2018-05-13_14-25-04.log for the output of root script
13、以静默方式配置监听
重新使用oracle用户登录:
[[email protected] software]# su -l oracle
Last login: Sun May 13 14:09:10 CST 2018 on pts/3
[[email protected] ~]$ netca /silent /responseFile /home/oracle/response/netca.rsp
注意此处,必须使用/silent /responseFile格式,而不是-silent -responseFile,因为是静默安装。
成功运行后,在/data/oracle/product/11.2.0/network/admin中生成listener.ora和sqlnet.ora
通过netstat命令可以查看1521端口正在监听。
Yum安装netstat软件,软件包是在net-tools中。
[[email protected] /]# yum install net-tools
[[email protected] /]# yum install net-tools
14、以静默方式建立新库,同时也建立一个对应的实例
[[email protected] ~]$ vim /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"
进行静默配置:
[[email protected] ~]$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
建库后进行实例进程检查:
[[email protected] ~]$ ps -ef | grep ora_ | grep -v grep
查看监听状态:
[[email protected] ~]$ lsnrctl status
数据库创建完成。
有关详细信息, 请查看以下位置的日志文件: /data/oracle/cfgtoollogs/dbca/orcl/orcl.log。
数据库信息:
全局数据库名:orcl.test
系统标识符 (SID):orcl
登录查看实例状态:
[[email protected] ~]$ sqlplus / as sysdba
SQL> select status from v$instance;
Linux下启动/关闭Oracle
一、Linux下启动Oracle
Linux下启动Oracle分为两步:
1)启动监听;
2)启动数据库实例;
1.登录服务器,切换到oracle用户,或者以oracle用户登录
[[email protected] ~]$ su - oracle 密码: [[email protected] ~]$
2.打开监听服务
[[email protected] ~]$ lsnrctl start
可以通过lsnrctl status命令查看Oracle监听器运行状况
[[email protected] ~]$ lsnrctl status
3.以SYS用户身份登录Oracle
[[email protected] ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Fri Dec 1 23:29:19 2017 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> conn /as sysdba Connected to an idle instance.
切换用户:
CONN 用户名/密码 [AS SYSDBA],如果是sys用户一定要写上AS SYSDBA
4.通过startup命令启动实例
SQL> startup ORACLE instance started. Total System ... ... Database mounted. Database opened. SQL>
二、Linux下关闭Oracle
1.关闭数据库实例
SQL> shutdown Database closed. Database dismounted. ORACLE instance shut down. SQL> quit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.关闭监听器
[[email protected] ~]$ lsnrctl stop
原文: