Centos7.0无桌面环境上静默安装oracle 11ggroupadd oinstall #创建oinstallgroupadd dba # 创建dba组useradd -g oinstall -G dba oracle #创建oracle用户passwd oracle # 修改oracle用户的登录密码[root@test-1 oracle]# id oracle #查看oracle用户信息uid=1000(oracle) gid=1000(oinstall)groups=1000(oinstall),1001(dba)mkdir -p /mnt/app/oraclechown -R oracle:oinstall /mnt/app/oraclechmod -R 775 /mnt/app/oracle依赖包是安装oracle的必须,如果某些需要的依赖包没有安装上,安装过程中会出现各种各样的错误。所以,依赖包安装完整,安装过程一般会比较顺利。直接执行如下命令,安装依赖包。yum -y install binutils compat-libcap1compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.develcompat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devellibaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686参考官方:http://docs.oracle.com/cd/E11882_01/install.112/e24326/toc.htm#BHCCADGDThe following or later version of packagesfor Oracle Linux 7, and Red Hat Enterprise Linux 7 must be installed:binutils-2.23.52.0.1-12.el7.x86_64compat-libcap1-1.10-3.el7.x86_64compat-libstdc++-33-3.2.3-71.el7.i686compat-libstdc++-33-3.2.3-71.el7.x86_64gcc-4.8.2-3.el7.x86_64gcc-c++-4.8.2-3.el7.x86_64glibc-2.17-36.el7.i686glibc-2.17-36.el7.x86_64glibc-devel-2.17-36.el7.i686glibc-devel-2.17-36.el7.x86_64kshlibaio-0.3.109-9.el7.i686libaio-0.3.109-9.el7.x86_64libaio-devel-0.3.109-9.el7.i686libaio-devel-0.3.109-9.el7.x86_64libgcc-4.8.2-3.el7.i686libgcc-4.8.2-3.el7.x86_64libstdc++-4.8.2-3.el7.i686libstdc++-4.8.2-3.el7.x86_64libstdc++-devel-4.8.2-3.el7.i686libstdc++-devel-4.8.2-3.el7.x86_64libXi-1.7.2-1.el7.i686libXi-1.7.2-1.el7.x86_64libXtst-1.2.2-1.el7.i686libXtst-1.2.2-1.el7.x86_64make-3.82-19.el7.x86_64sysstat-10.1.5-1.el7.x86_64unixODBC-2.3.1-6.el7.x86_64 or laterunixODBC-2.3.1-6.el7.i686 or laterunixODBC-devel-2.3.1-6.el7.x86_64 or laterunixODBC-devel-2.3.1-6.el7.i686 or laterhosts文件中,要讲主机名添加到配置文件中,及添加到127.0.0.1后面,如果没有加,安装过程中会出错。首先查看主机名:使用hostname命令[root@test-1 oracle]# hostnametest-1主机名为test-1,则把test-1添加到/etc/hosts文件中:[root@test-1 oracle]# vi /etc/hosts127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4test-1::1localhost localhost.localdomain localhost6 localhost6.localdomain6将自己的主机名添加到文件中,保存退出。编辑sysctl.conf文件`[root@test-1 oracle]# vi /etc/sysctl.conf加入如下配置fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576vm.hugetlb_shm_group = 1001 #此处与id oracle中的dba中一致让内核参数生效,执行:/sbin/sysctl -pvi /etc/security/limits.conf#在末尾添加oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240保存退出。vi /etc/pam.d/login打开编辑此文件,在末尾加入如下配置:session required /lib64/security/pam_limits.sosession required pam_limits.so说明:此处,要使用lib64,如果使用lib,则可能会出现无法登陆系统的情况,使用lib是在32位的情况下,如果是64位系统,则应该使用lib64保存退出。vi /etc/profile加入如下配置:if [[ $USER = “oracle” ]]; thenif [[ $SHELL = “/bin/ksh” ]]; then ulimit -p16384 ulimit -n65536else ulimit -u16384 -n 65536fifi注意空格保存退出使其生效 source /etc/profilevi /home/oracle/.bash_profile加入如下配置文件:#oracleexport TMP=/tmp;export TMPDIR=$TMP;export ORACLE_BASE=/mnt/app/oracle;exportORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1;export ORACLE_SID=orcl;export ORACLE_TERM=xterm;export PATH=/usr/sbin:$PATH;export PATH=$ORACLE_HOME/bin:$PATH;export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;exportCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;保存退出。使其生效:source /home/oracle/.bash_profile使用sftp将安装文件上传至服务器。解压文件夹[root@test-1 oracle]# unziplinuxamd64_12102_database_1of2.zip[root@test-1 oracle]# unziplinuxamd64_12102_database_2of2.zip加压之后,得到一个database的文件夹,将其移动到/mnt/app/oracle目录下mv database /mnt/app/oracle对文件授权chown -R oracle:oinstall/mnt/app/oracle/database最终的安装主要在与三个响应文件的配置:dbca.rsp,netca.rsp,db_install.rsp,分别对应于创建数据库,创建监听,安装数据库。三个文件的路径在database/response 文件夹下。为了防止出错,我们把三个响应文件复制到oracle用户路径下,出错之后可以删除再复制更改即可。在oracle用户目录下,创建一个etc文件夹[oracle@test-1 /]$ mkdir /home/oracle/etc复制响应文件[oracle@test-1 /]$ cp /mnt/app/oracle/database/response/*/home/oracle/etc[oracle@test-1 /]$ ls /home/oracle/etc/dbca.rspdb_install.rsp netca.rsp授权[oracle@test-1 /]$ su – root[root@test-1 ~]# chmod 777 /home/oracle/etc/*.rsp编辑安装响应文件[root@test-1 ~]# vi /home/oracle/etc/db_install.rsp找到如下的配置,将配置更改如下:`oracle.install.option=INSTALL_DB_SWONLY //安装类型ORACLE_HOSTNAME=test-1 // 主机名称(hostname查询)UNIX_GROUP_NAME=oinstall // 安装组INVENTORY_LOCATION=/mnt/app/oracle/oraInventory//INVENTORY目录(不填就是默认值)SELECTED_LANGUAGES=en // 选择语言ORACLE_HOME=/mnt/app/oracle/product/12.1.0/db_1//oracle_homeORACLE_BASE=/mnt/app/oracle //oracle_baseoracle.install.db.InstallEdition=EE // oracle版本oracle.install.db.isCustomInstall=false //自定义安装,否,使用默认组件oracle.install.db.DBA_GROUP=dba // dba用户组oracle.install.db.OPER_GROUP=dba // oper用户组oracle.install.db.config.starterdb.type=GENERAL_PURPOSE//数据库类型oracle.install.db.config.starterdb.globalDBName=orcl//globalDBNameoracle.install.db.config.starterdb.SID=orcl//SIDoracle.install.db.config.starterdb.password.ALL=Admin@123#@!//设定所有数据库用户使用同一个密码SECURITY_UPDATES_VIA_MYORACLESUPPORT=false//(手动写了false)DECLINE_SECURITY_UPDATES=true //设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)`配置好后。保存退出。[root@test-1 ~]# su – oracle[oracle@test-1 database]$/mnt/app/oracle/database/runInstaller-silent -responseFile /home/oracle/etc/db_install.rsp安装过程如下,出现如下结果,说明安装成功Starting Oracle Universal Installer…Checking Temp space: must be greater than500 MB. Actual 17997 MB PassedChecking swap space: must be greater than150 MB. Actual 2999 MB PassedPreparing to launch Oracle UniversalInstaller from /tmp/OraInstall2017-06-04_07-51-31PM. Please wait…[oracle@test-1 database]$ [WARNING] [INS-32055] The Central Inventory is locatedin the Oracle base.ACTION: Oracle recommends placing thisCentral Inventory in a location outside the Oracle base directory.[WARNING] [INS-13014] Target environmentdoes not meet some optional requirements.CAUSE: Some of the optional prerequisitesare not met. See logs for details./tmp/OraInstall2017-06-04_07-51-31PM/installActions2017-06-04_07-51-31PM.logACTION: Identify the list of failedprerequisite checks from the log:/tmp/OraInstall2017-06-04_07-51-31PM/installActions2017-06-04_07-51-31PM.log.Then either from the log file or from installation manual find the appropriateconfiguration to meet the prerequisites and fix it manually.You can find the log of this installsession at:/mnt/app/oracle/oraInventory/logs/installActions2017-06-04_07-51-31PM.logThe installation of Oracle Database 12c wassuccessful.Please check’/mnt/app/oracle/oraInventory/logs/silentInstall2017-06-04_07-51-31PM.log’ formore details.As a root user, execute the followingscript(s):1. /mnt/app/oracle/oraInventory/orainstRoot.sh2. /mnt/app/oracle/product/12.1.0/db_1/root.shSuccessfully Setup Software/mnt/app/oracle/oraInventory/orainstRoot.sh/mnt/app/oracle/product/12.1.0/db_1/root.sh到此,数据库已成功安装上。监听器配置响应文件为:/home/oracle/etc/netca.rsp,此文件使用默认即可。执行配置监听[oracle@test-1 database]$ netca /silent/responsefile /home/oracle/etc/netca.rsp出现如下信息,说明监听配置成功。[oracle@test-1 oracle]$ netca /silent/responsefile /home/oracle/etc/netca.rsp正在对命令行参数进行语法分析:参数“silent” = true参数“responsefile” =/home/oracle/etc/netca.rsp完成对命令行参数进行语法分析。Oracle Net Services 配置:完成概要文件配置。Oracle Net 监听程序启动: 正在运行监听程序控制:/mnt/app/oracle/product/12.1.0/db_1/bin/lsnrctl start LISTENER 监听程序控制完成。 监听程序已成功启动。监听程序配置完成。成功完成 Oracle Net Services 配置。退出代码是0成功运行后,在/mnt/app/oracle/product/12.1.0/db_1/network/admin/中生成listener.ora和sqlnet.ora通过netstat命令可以查看1521端口正在监听。Yum安装netstat软件,软件包是在net-tools中[root@test-1 ~]# yum install net-tools[root@test-1 ~]# netstat -lntup|grep 1521tcp60 0 :::1521 :::* LISTEN 14496/tnslsnr[oracle@test-1 database]$ lsnrctl start查看监听状态[oracle@test-1 database]$ lsnrctl statusLSNRCTL for Linux: Version 12.1.0.2.0 -Production on 04-JUN-2017 20:15:07Copyright (c) 1991, 2014, Oracle. Allrights reserved.Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))STATUS of the LISTENERAlias LISTENERVersion TNSLSNR for Linux: Version12.1.0.2.0 – ProductionStart Date 04-JUN-2017 20:08:08Uptime 0 days 0 hr. 7 min. 0 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File/mnt/app/oracle/product/12.1.0/db_1/network/admin/listener.oraListener Log File/mnt/app/oracle/diag/tnslsnr/test-1/listener/alert/log.xmlListening Endpoints Summary…(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))The listener supports no servicesThe command completed successfully[oracle@test-1 database]$ lsnrctl reload[oracle@test-1 /]$ su – root[root@test-1 ~]# vim/home/oracle/etc/dbca.rsp设置以下参数:GDBNAME = “orcl”SID = “orcl”SYSPASSWORD = “oracle”SYSTEMPASSWORD = “oracle”SYSMANPASSWORD = “oracle”DBSNMPPASSWORD = “oracle”DATAFILEDESTINATION=/mnt/app/oracle/oradataRECOVERYAREADESTINATION=/mnt/app/oracle/fast_recovery_areaCHARACTERSET = “ZHS16GBK”TOTALMEMORY = “1638”其中TOTALMEMORY = “1638” 为1638MB,物理内存2G*80%。执行安装数据库实例切换到oracle用户[root@test-1 ~]# su – oracle[oracle@test-1 ~]$ dbca -silent-responseFile /home/oracle/etc/dbca.rsp日志显示,数据库实例已经成功创建。[oracle@test-1 ~]$ ps -ef | grep ora_ |grep -v grep[oracle@test-1~]$ lsnrctl status[oracle@test-1 ~]$ sqlplus / as sysdbaSQL> select status from v$instance;进入到oracle安装目录的bin目录下,执行 dbstop即可停止数据库。由于数据库安装了一般需要外网访问,所以需要开放数据库连接端口免费云主机域名。[root@test-1 /]# firewall-cmd –zone=public–add-port=1521/tcp –permanentsuccess[root@test-1 /]# firewall-cmd –zone=public–add-port=5500/tcp –permanentsuccess[root@test-1 /]# firewall-cmd –reloadsuccess命令含义:–zone #作用域–add-port=80/tcp #添加端口,格式为:端口/通讯协议–permanent #永久生效,没有此参数重启后失效重启防火墙firewall-cmd –reload1、修改/mnt/app/oracle/product/12.1.0/db_1/bin/dbstart[oracle@test-1 ~]$ vim/mnt/app/oracle/product/12.1.0/db_1/bin/dbstart将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME2、修改/mnt/app/oracle/product/12.1.0/db_1/bin/dbshut[oracle@test-1 ~]$ vim /mnt/app/oracle/product/12.1.0/db_1/bin/dbshut将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME3、修改/etc/oratab文件[oracle@test-1~]$ vim /etc/oratab将orcl:/mnt/app/oracle/product/11.2.0:N中最后的N改为Y,成为orcl:/mnt/app/oracle/product/11.2.0:Y[oracle@test-1~]$ dbshutOracle监听停止,进程消失。Oracle监听启动,进程启动。vi /etc/rc.d/rc.local加入如下配置:su oracle -lc “/mnt/app/oracle/product/12.1.0/db_1/bin/lsnrctlstart”su oracle -lc /mnt/app/oracle/product/12.1.0/db_1/bin/dbstart保存退出重启系统,再次连接数据库,将正常连接上。 [oracle@test-1~]$ su –[root@test-1~]# vim /etc/rc.d/init.d/oracle添加以下内容(有些值如ORACLE_HOME和ORACLE_USER等根据实际情况可以修改):[root@test-1 ~]# cat/etc/rc.d/init.d/oracle#!/bin/bash# oracle: Start/Stop Oracle Database 11g R2# chkconfig: 345 90 10# description: The Oracle Database is anObject-Relational Database Management System.#. /etc/rc.d/init.d/functionsLOCKFILE=/mnt/app/oracle/var/lock/subsys/oracleORACLE_HOME=/mnt/app/oracle/product/12.1.0/db_1/ORACLE_USER=oraclecase “$1” in’start’) if[ ! -f $LOCKFILE ];then touch “$LOCKFILE”elseexit 1 fi su- $ORACLE_USER -c “$ORACLE_HOME/bin/lsnrctl start” su- $ORACLE_USER -c “$ORACLE_HOME/bin/dbstart” su- $ORACLE_USER -c “$ORACLE_HOME/bin/emctl start dbconsole”echo -n $”Starting Oracle Database:” ;;’stop’) if[ ! -f $LOCKFILE ]; thenecho $0 already stopping.exit 1 fi echo-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’) $0stop $0start ;;’status’) if[ -e $LOCKFILE ]; then echo $0 started.else echo $0 stopped. fi ;;*)echo “Usage: $0 [start|stop|status]”exit 1esacexit 0[root@test-1 ~]# chmod 755 /etc/init.d/oracle[root@test-1 ~]# ll /etc/init.d/oracle-rwxr-xr-x 1 root root 1203 6月 29 10:59 /etc/init.d/oracle[root@test-1 ~]# chkconfig oracle on
相关推荐: oracle常见的几种数据类型 Oracle 10g学习系列(3)
oracle常见的几种数据类型:char的长度是固定的,最大长度为2K字节。比如说,你定义了char(20),即使你你插入abc,不足二十个字节,数据库也会在abc后面自动加上17个空格,以补足二十个字节。中文在char中占两个字节,而英文占一个,所以char…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。