阿里云centos安装oracle

目录

    • 安装oracle所需的依赖包
    • 关闭selinux(阿里云缺省关闭)
      • 安装oracle

阿里云centos安装oracle

阿里云默认没有swap分区,oracle安装需要

创建swap分区是为了弥补物理内存的不足,也就是虚拟内存的概念,把硬盘的一部分划分作为虚拟内存,但这个空间不是越大越好,硬盘的速度远低于内存,设置不当反而拖慢系统的速度。

阿里云的主机默认没有swap分区,可以使用free命令查看。

  1. 使用dd命令创建一个swap分区: dd if=/dev/zero of=/home/swap bs=1024 count=1048576 (count的值是:size(多少m)* 1024,我这里设置的1g虚拟内存,也就是count=1024000)

  2. 格式化swap分区: mkswap /home/swap

  3. 把格式化后的文件分区设置为swap分区: swapon /home/swap (关闭swap分区命令为:[root@localhost desktop]#swapoff /home/swap)

  4. swap分区自动挂载:vi /etc/fstab 在文件末尾加上”/home/swap swap swap default 0 0″

安装oracle所需的依赖包

yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixodbc unixodbc-devel sysstat ksh

创建用户和组

groupadd -g 200 oinstall  #添加oinstall组,组的id为200
groupadd -g 201 dba       #添加dba组,组的id为201
useradd -u 440 -g oinstall -g dba oracle #添加用户oracle,并specified它的id为440.
passwd oracle             #输入oracle用户的密码
id oracle                 #查看用户id和所属组。

关闭selinux(阿里云缺省关闭)

vim /etc/selinux/config   #编辑配置文件,关闭selinux
setenforce 0              #立即关闭selinux

开始安装

使用“su – u oracle”切换到oracle账号下

把下面两个文件上传到centos7-64bits服务器的/app/oracle目录下(我比较喜欢把软件安装在/app下)

linux.x64_11gr2_database_1of2.zip和linux.x64_11gr2_database_2of2.zip

unzip linux.x64_11gr2_database_1of2.zip
unzip linux.x64_11gr2_database_2of2.zip

在/app/oracle目录下会出现database目录。

vim /app/oracle/database/response/db_install.rsp

修改db_install.rsp文件

oracle.install.responsefileversion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=install_db_swonly
oracle_hostname=可以写本机地址
unix_group_name=oinstall
inventory_location=/app/oracle/orainventory
selected_languages=zh_cn,en
oracle_home=/app/oracle/product/11.2.0/db_1
oracle_base=/app/oracle
oracle.install.db.installedition=ee
oracle.install.db.iscustominstall=false
oracle.install.db.dba_group=dba
oracle.install.db.oper_group=oinstall
oracle.install.db.config.starterdb.type=general_purpose
oracle.install.db.config.starterdb.globaldbname=orcl
oracle.install.db.config.starterdb.sid=orcl
oracle.install.db.config.starterdb.characterset=al32utf8
oracle.install.db.config.starterdb.memoryoption=true
oracle.install.db.config.starterdb.memorylimit=512
oracle.install.db.config.starterdb.installexampleschemas=false
oracle.install.db.config.starterdb.enablesecuritysettings=true
oracle.install.db.config.starterdb.password.all=oracle2018
oracle.install.db.config.starterdb.control=db_control
oracle.install.db.config.starterdb.dbcontrol.enableemailnotification=false
oracle.install.db.config.starterdb.automatedbackup.enable=false
decline_security_updates=true

安装oracle

oracle账号登陆,在/app/oracle/database路径下执行开始安装

./runinstaller -silent -responsefile /app/oracle/database/response/db_install.rsp

安装成功之后会出现如下:

the following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #root scripts to run

/app/oracle/orainventory/orainstroot.sh
/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

successfully setup software.

按照提示以root身份登录centos7系统执行如下命令

/app/oracle/orainventory/orainstroot.sh
/app/oracle/product/11.2.0/db_1/root.sh

以oracle身份登录centos7系统,设置环境变量

vi ~/.bash_profile

export path
export oracle_base=/app/oracle
export oracle_home=$oracle_base/product/11.2.0/db_1
export path=$path:$oracle_home/bin
export oracle_sid=orcl
export tns_admin=$oracle_home/network/admin

使用下面命令使环境变量生效:source ~/.bash_profile

为了使sqlplus能够访问远程oracle数据库,不但要配置“tns_admin”环境变量,还需要环境变量指向的地址(我这里是/app/oracle/product/11.2.0/db_1/network/admin/)中放入tnsnames.ora文件

下面是我tnsnames.ora的内容,其中orcl是数据库名字。

localoracle =  
  (description =  
    (address_list =  
      (address = (protocol = tcp)(host = 127.0.0.1)(port = 1521))  
    )  
    (connect_data =  
      (service_name = orcl)  
    )  
  )  

建库

确认并修改/app/oracle/database/response/dbca.rsp,其中修改的都是createdatabase操作的内容,其他的不动。

responsefile_version = "11.2.0"
operation_type = "createdatabase"
[createdatabase]
gdbname = "orcl"
sid = "orcl"
characterset="al32utf8"

用oracle账号调用下面的命令

dbca -silent -responsefile /app/oracle/database/response/dbca.rsp
#执行结束后需要输入2次oracle设置的密码

验证oracle安装是否成功:

su – u oracle

sqlplus “/as sysdba”

select * from tabs;

如果成功运行,表示oracle已经启来,否则需要运行“startup”命令启动oracle.

添加listener.ora文件

位置:/app/oracle/product/11.2.0/db_1/network/admin

文件内容

# copyright (c) 1997 by the oracle corporation
# 
# name
#   listener.ora
# function
#   network listener startup parameter file example
# notes
#   this file contains all the parameters for listener.ora,
#   and could be used to configure the listener by uncommenting
#   and changing values.  multiple listeners can be configured
#   in one listener.ora, so listener.ora parameters take the form
#   of sid_list_<lsnr>, where <lsnr> is the name of the listener
#   this parameter refers to.  all parameters and values are
#   case-insensitive.

# <lsnr>
#   this parameter specifies both the name of the listener, and
#   it listening address(es). other parameters for this listener
#   us this name in place of <lsnr>.  when not specified,
#   the name for <lsnr> defaults to "listener", with the default
#   address value as shown below.
#
# listener =
#  (address_list=
#   (address=(protocol=tcp)(host=localhost)(port=1521))
#   (address=(protocol=ipc)(key=pnpkey)))   
listener=(description_list=(description=
      (address=(protocol=tcp)(host=localhost)(port=1521))  
  )
)

# sid_list_<lsnr>
#   list of services the listener knows about and can connect 
#   clients to.  there is no default.  see the net8 administrator's
#   guide for more information.
#
# sid_list_listener=
#   (sid_list=
#   (sid_desc=
#           #bequeath config
#          (global_dbname=salesdb.mycompany)
#          (sid_name=sid1)          
#          (oracle_home=/private/app/oracle/product/8.0.3)
#           #prespawn config
#         (prespawn_max=20)
#     (prespawn_list=
#           (prespawn_desc=(protocol=tcp)(pool_size=2)(timeout=1))
#         )
#        )
#       )

sid_list_listener=
  (sid_list=
      (sid_desc=
         (global_dbname=orcl)
         (sid_name=orcl)
         (oracle_home=/app/oracle/product/11.2.0/db_1)
        (prespawn_max=20)
        (prespawn_list=
          (prespawn_desc=(protocol=tcp)(pool_size=2)(timeout=1))
        )
       )
      )
    
# passwords_<lsnr>
#   specifies a password to authenticate stopping the listener.
#   both encrypted and plain-text values can be set.  encrypted passwords
#   can be set and stored using lsnrctl.  
#     lsnrctl> change_password
#       will prompt for old and new passwords, and use encryption both
#       to match the old password and to set the new one.
#     lsnrctl> set password
#   will prompt for the new password, for authentication with 
#       the listener. the password must be set before running the next
#       command.
#     lsnrctl> save_config
#       will save the changed password to listener.ora. these last two
#       steps are not necessary if save_config_on_stop_<lsnr> is on.
#       see below.
#
# default: none
#
# passwords_listener = 20a22647832fb454      # "foobar"

# save_config_on_stop_<lsnr>
#   tells the listener to save configuration changes to listener.ora when
#   it shuts down.  changed parameter values will be written to the file,
#   while preserving formatting and comments.
# default: off
# values: on/off
#
# save_config_on_stop_listener = on

# use_plug_and_play_<lsnr>
#   tells the listener to contact an onames server and register itself
#   and its services with onames.
# values: on/off
# default: off
#
# use_plug_and_play_listener = on

# log_file_<lsnr>
#   sets the name of the listener's log file.  the .log extension
#   is added automatically.
# default=<lsnr>
#
# log_file_listener = lsnr

# log_directory_<lsnr>
#   sets the directory for the listener's log file.
# default: <oracle_home>/network/log
#
# log_directory_listener = /private/app/oracle/product/8.0.3/network/log

# trace_level_<lsnr>
#   specifies desired tracing level.
# default: off
# values: off/user/admin/support/0-16
#
# trace_level_listener = support

# trace_file_<lsnr>
#   sets the name of the listener's trace file. the .trc extension
#   is added automatically.
# default: <lsnr>
#
# trace_file_listener = lsnr

# trace_directory_<lsnr>
#   sets the directory for the listener's trace file.
# default: <oracle_home>/network/trace
#
# trace_directory_listener=/private/app/oracle/product/8.0.3/network/trace
# connect_timeout_<lsnr>
#   sets the number of seconds that the listener waits to get a 
#   valid database query after it has been started.
# default: 10
#
# connect_timeout_listener=10

使用lsnrctl start命令启动侦听器

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐