cento7静默安装oracle11g
2021/7/1 2:21:12
本文主要是介绍cento7静默安装oracle11g,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
安装硬件要求
1、内存 要求:内存最小1G,推荐2G或者更高。查看命令:
grep MemTotal /proc/meminfo
2、swap
|RAW|Swap|
|:—- |:—— |
|1G至2G|1.5倍|
|2G至16G|同RAW相等|
|16G以上|16G|
查看命令:
grep SwapTotal /proc/meminfo
环境准备
安装包:
- linux.x64_11gR2_database_1of2.zip
- linux.x64_11gR2_database_2of2.zip
oracle 下载地址:http://www.oracle.com/technetwork/indexes/downloads/index.html#database
安装Oracle前的准备
1、创建运行oracle数据库的系统用户和用户组
[root@localhost ~]# groupadd oinstall #创建用户组oinstall [root@localhost ~]# groupadd dba #创建用户组dba [root@localhost ~]# useradd -g oinstall -g dba -m oracle #创建oracle用户,并加入到oinstall和dba用户组 [root@localhost ~]# passwd oracle #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆 [root@localhost ~]# id oracle # 查看新建的oracle用户
2、创建oracle数据库安装目录
查看每个目录容量大小
[root@localhost ~]# df -h |文件系统 |容量 |已用 |可用 |已用% |挂载点| |:---- |:------ |:------ |:------ |:------ |:------ | |/dev/mapper/centos-root |50G |13G |38G |26% |/ |devtmpfs |7.8G |0 |7.8G |0% |/dev |tmpfs |7.8G |0 |7.8G |0% |/dev/shm |tmpfs |7.8G |138M |7.6G |2% |/run |tmpfs |7.8G |0 |7.8G |0% |/sys/fs/cgroup |/dev/sda1 |1014M |223M |792M |22% |/boot |/dev/mapper/centos-home |1.8T |144G |1.7T |8% |/home |tmpfs |1.6G |0 |1.6G |0% |/run/user/0 |tmpfs |1.6G |12K |1.6G |1% |/run/user/42
[root@localhost ~]# cd /home/oracle # 进入到 /home/oracle目录 [root@localhost ~]# mkdir data #oracle数据库安装目录 [root@localhost ~]# mkdir database #oracle数据库配置文件目录 [root@localhost ~]# mkdir oraInventory #oracle数据库软件包解压目录 [root@localhost ~]# chown -R oracle:oinstall data #设置目录所有者为oinstall用户组的oracle用户 [root@localhost ~]# chown -R oracle:oinstall database #设置目录所有者为oinstall用户组的oracle用户 [root@localhost ~]# chown -R oracle:oinstall oraInventory #设置目录所有者为oinstall用户组的oracle用户
3、修改OS系统标识(oracle默认不支持CentOS系统安装,但是centos其实就是redhat)
[root@localhost ~]# cat /proc/version Linux version 3.10.0-514.26.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017 [root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@localhost ~]# vi /etc/redhat-release [root@localhost ~]# cat /etc/redhat-release redhat-7
4、安装oracle数据库所需要的软件包
[root@localhost ~]# yum -y install binutils* compat-libcap1* compat-libstdc++* gcc* gcc-c++* glibc* glibc-devel* ksh* libaio* libaio-devel* libgcc* libstdc++* libstdc++-devel* libXi* libXtst* make* sysstat* elfutils* [root@localhost ~]# yum -y install unixODBC-2.3.1-11.el7.i686 [root@localhost ~]# yum -y install unixODBC-devel-2.3.1-11.el7.i686
5、关闭防火墙
[root@localhost ~]# systemctl status firewalld.service #查看防火墙状态(运行中) [root@localhost ~]# systemctl stop firewalld.service #关闭防火墙 [root@localhost ~]# systemctl disable firewalld.service #禁止使用防火墙(重启也是禁止的) 如果是内网无所谓,如果是阿里云或者其他云建议不要这样做,开启防火墙策略即可 其他防火墙命令 请参考我的 linux防火墙策略文章
6、修改内核参数
[root@localhost ~]# vi /etc/sysctl.conf # 加入以下部分 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.all.rp_filter = 1 fs.file-max = 6815744 #设置最大打开文件数 fs.aio-max-nr = 1048576 kernel.shmall = 2097152 #共享内存的总量,8G内存设置:2097152*4k/1024/1024 kernel.shmmax = 2147483648 #最大共享内存的段大小 kernel.shmmni = 4096 #整个系统共享内存端的最大数 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 #可使用的IPv4端口范围 net.core.rmem_default = 262144 net.core.rmem_max= 4194304 net.core.wmem_default= 262144 net.core.wmem_max= 1048576
7、使配置修改内核的参数生效
[root@localhost ~]# sysctl -p
8、对oracle用户设置限制,提高软件运行性能
[root@localhost ~]# vi /etc/security/limits.conf # 加入以下部分 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
9、配置用户的环境变量
[root@localhost ~]# vi /home/oracle/.bash_profile export ORACLE_BASE=/home/oracle/data #oracle数据库安装目录 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/ #oracle数据库路径 export ORACLE_SID=orcl #oracle启动数据库实例名 export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系统环境变量 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export LC_ALL="en_US" export LANG="en_US" export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK" export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
10、将安装包移动到 /home/oracle/src 目录下面
[root@localhost ~]# mkdir /home/oracle/src. # 在oracle 目录下面创建src 目录 [root@localhost oracle]# chown -R oracle:oinstall src # 切换到oracle 目录,并更改目录的用户和用户组 [root@localhost oracle]# mv /root/soft/linux.x64_11gR2_database_* ./ # 移动安装包到这两个目录 [root@localhost src]# ll 总用量 2295592 -rwxr-xr-x 1 root root 1239269270 11月 27 09:37 linux.x64_11gR2_database_1of2.zip -rwxr-xr-x 1 root root 1111416131 11月 27 09:39 linux.x64_11gR2_database_2of2.zip [root@localhost src]#
11、解压 文件至 /home/oracle/database/ 目录下
[root@localhost src]# unzip linux.x64_11gR2_database_1of2.zip /home/oracle/database [root@localhost src]# unzip linux.x64_11gR2_database_2of2.zip /home/oracle/database #查看解压文件 [oracle@localhost database]$ ls doc install response rpm runInstaller sshsetup stage welcome.html [oracle@localhost database]$ pwd /home/oracle/database/database。 # 在此目录下
12、进入管理员权限,设置目录所有者为oinstall用户组的oracle用户,执行安装脚本
[root@localhost src]# su root # 设置目录所有者为 oinstall用户组的oracle用户 [root@localhost src]# chown -R oracle:oinstall /home/oracle/database/database/ [root@localhost oracle]# ll 总用量 0 drwxr-xr-x 2 oracle oinstall 6 11月 27 10:03 data drwxr-xr-x 3 oracle oinstall 22 11月 27 11:00 database drwxr-xr-x 2 oracle oinstall 6 11月 27 10:04 oraInventory drwxr-xr-x 2 oracle dba 6 11月 27 10:47 perl5 drwxr-xr-x 2 oracle oinstall 88 11月 27 11:00 src [root@localhost src]# su oracle # 权限设置完成后 切换回oracle 用户 在oracle 用户下执行以下命令 [oracle@localhost database]# ls doc install response rpm runInstaller sshsetup stage welcome.html [oracle@localhost database]# pwd /home/oracle/database/database。 # 进入安装目录 [oracle@localhost database]# ./runInstaller #执行命令
13、修改db_install.rsp 值 以下操作请使用 root 用户
[root@localhost src]# cd /home/oracle/database/database/response # 切换到此目录 [root@localhost response]# ls dbca.rsp db_install.rsp netca.rsp [root@localhost response]# pwd /home/oracle/database/database/response [root@localhost response]# mkdir -p /home/oracle/data/etc #创建etc目录 [root@localhost response]# cp * /home/oracle/data/etc # 复制文件到 etc 目录 [root@localhost response]# cd /home/oracle/data/etc。 # 切换目录 [root@localhost etc]# ll # 查看文件 total 76 -rw-r--r-- 1 root root 44969 Nov 27 11:45 dbca.rsp -rw-r--r-- 1 root root 22557 Nov 27 11:45 db_install.rsp -rwxr-xr-x 1 root root 5740 Nov 27 11:45 netca.rsp #修改db_install.rsp 值 [root@localhost etc]# vim db_install.rsp # 修改以下变量的值 oracle.install.option=INSTALL_DB_SWONLY DECLINE_SECURITY_UPDATES=true UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/home/oracle/data/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOSTNAME=oracle ORACLE_HOME=/home/oracle/data/product/11.2.0 ORACLE_BASE=/home/oracle/data oracle.install.db.InstallEdition=EE oracle.install.db.isCustomInstall=true oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba
安装oracle
1、安装
[root@localhost etc]$ su - oracle # 切换到oracle 用户 [oracle@localhost ~]$ /home/oracle/database/database # 切换到database 目录 [oracle@localhost database]$ ./runInstaller -silent -responseFile /home/oracle/data/etc/db_install.rsp -ignorePrereq # 执行命令
2、安装期间可以使用tail命令监看oracle的安装日志
tail -f /home/oracle/app/oraInventory/logs/installActions2019-11-27_12-05-14PM.log # 出现以下命令则说明安装完成 The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root scripts to run /home/oracle/data/product/11.2.0/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.
3、使用root用户执行脚本
重新打开一个窗口,使用root 用户执行上面所说的脚本。
[oracle@localhost ~]$ sh /home/oracle/data/product/11.2.0/root.sh
4、配置监听程序
[oracle@localhost ~]$ su - oracle [oracle@localhost ~]$ netca /silent /responsefile /home/oracle/data/etc/netca.rsp # 以下为输出内容 Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /home/oracle/data/etc/netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Oracle Net Listener Startup: Running Listener Control: /home/oracle/data/product/11.2.0/bin/lsnrctl start LISTENER Listener Control complete. Listener started successfully. Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
5、查看监听端口
netstat -tnpl | grep 1521 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0 0 :::1521 :::* LISTEN 16453/tnslsnr
静默创建数据库
1、编辑应答文件。/home/oracle/data/etc/dbca.rsp
[oracle@localhost ~]$ vim /home/oracle/data/etc/dbca.rsp # 更改以下内容 [GENERAL] RESPONSEFILE_VERSION = "11.2.0" OPERATION_TYPE = "createDatabase" [CREATEDATABASE] GDBNAME = "orcl" SID = "orcl" SYSPASSWORD = "oracle" SYSTEMPASSWORD = "oracle" SYSMANPASSWORD = "oracle" DBSNMPPASSWORD = "oracle" DATAFILEDESTINATION =/home/oracle/data/oradata # 默认是 $ORACLE_BASE/oradata RECOVERYAREADESTINATION=/home/oracle/data/fast_recovery_area # 默认是 $ORACLE_BASE/fast_recovery_area CHARACTERSET = "AL32UTF8" TOTALMEMORY = "1638"
2、执行静默建库
[oracle@localhost ~]$ su - oracle [oracle@localhost ~]$ dbca -silent -responseFile /home/oracle/data/etc/dbca.rsp # 输出日志如下 Copying database files 1% complete 3% complete 11% complete 18% complete 26% complete 37% complete Creating and starting Oracle instance 40% complete 45% complete [root@localhost ~]# ps -ef | grep ora_ | grep -v grep # 查看进程 oracle 21722 1 0 13:00 ? 00:00:00 ora_pmon_orcl oracle 21724 1 0 13:00 ? 00:00:00 ora_vktm_orcl oracle 21728 1 0 13:00 ? 00:00:00 ora_gen0_orcl oracle 21730 1 0 13:00 ? 00:00:00 ora_diag_orcl oracle 21732 1 0 13:00 ? 00:00:00 ora_dbrm_orcl oracle 21734 1 0 13:00 ? 00:00:00 ora_psp0_orcl oracle 21736 1 0 13:00 ? 00:00:00 ora_dia0_orcl oracle 21738 1 0 13:00 ? 00:00:00 ora_mman_orcl oracle 21740 1 0 13:00 ? 00:00:00 ora_dbw0_orcl oracle 21742 1 0 13:00 ? 00:00:00 ora_dbw1_orcl oracle 21744 1 0 13:00 ? 00:00:00 ora_lgwr_orcl oracle 21746 1 0 13:00 ? 00:00:00 ora_ckpt_orcl oracle 21748 1 0 13:00 ? 00:00:00 ora_smon_orcl oracle 21750 1 0 13:00 ? 00:00:00 ora_reco_orcl oracle 21752 1 0 13:00 ? 00:00:00 ora_mmon_orcl oracle 21754 1 0 13:00 ? 00:00:00 ora_mmnl_orcl oracle 21756 1 0 13:00 ? 00:00:00 ora_d000_orcl oracle 21758 1 0 13:00 ? 00:00:00 ora_s000_orcl oracle 21838 1 0 13:00 ? 00:00:00 ora_qmnc_orcl oracle 21855 1 0 13:00 ? 00:00:00 ora_cjq0_orcl oracle 21867 1 0 13:00 ? 00:00:00 ora_q000_orcl oracle 21869 1 0 13:00 ? 00:00:00 ora_q001_orcl [oracle@localhost data]$ lsnrctl status # 查看监听状态 在oracle 用户下执行 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 27-NOV-2019 13:07:09 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 27-NOV-2019 12:21:15 Uptime 0 days 0 hr. 45 min. 54 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/data/product/11.2.0/network/admin/listener.ora Listener Log File /home/oracle/data/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
3、至此数据库就安装成功了,下面我们登录下数据库
su - oracle [oracle@localhost data]$ sqlplus / as sysdba SQL> select status from v$instance; SQL> select status from v$instance; select status from v$instance * ERROR at line 1: ORA-01034: ORACLE not available Process ID: 0 Session ID: 0 Serial number: 0 # 报错 解决方式 可参考 https://www.cnblogs.com/kerrycode/p/3656655.html # 我的问题是 删除了 /home/oracle/data/product/11.2.0/dbs/lkORCL 文件即可正常使用 # 通过以下命令可以查看具体的错误 日志 如果找不到日志 通过 find / -name alert*.log 搜索即可 [root@localhost data]$ tail -f /home/oracle/data/diag/rdbms/orcl/orcl/trace/alert_orcl.log
4、查看数据库编码
SQL> select userenv('language') from dual; USERENV('LANGUAGE') -------------------------------------------------------------------------------- AMERICAN_AMERICA.US7ASCII
5、查看数据库版本
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production
6、激活scott用户
SQL> alter user scott account unlock; alter user scott account unlock * ERROR at line 1: ORA-01109: database not open 解决: 查看共享内存 [root@localhost dbs]# ipcs -map --------- 消息队列 PID ----------- msqid 拥有者 lspid lrpid -------- 共享内存 创建者/上次修改者 PID ---------- shmid 拥有者 cpid lpid 294912 oracle 21676 26322 622593 oracle 26199 26301 移除共享内存 ipcrm -m 294912 ipcrm -m 294912 SQL> shutdown ORA-01507: database not mounted # 依然报错,继续解决 ORA-27120: unable to removed shared memory segment Linux-x86_64 Error: 22: Invalid argument Additional information: 622593 Additional information: 11 SQL> startup ORA-00600: internal error code, arguments: [SKGMBUSY], [1], [0], [0], [0], [], [], [], [], [], [], [] ORA-27123: unable to attach to shared memory segment SQL> 以上报错执行以下命令即可解决,执行完成后,重启 [root@localhost data]$ mount -o remount rw / # 重启完成后进入oracle 用户 [oracle@localhost ~]$sqlplus / as sysdba SQL> startup # 启动oracle 实例 ORACLE instance started. Total System Global Area 1720328192 bytes Fixed Size 2214056 bytes Variable Size 1006634840 bytes Database Buffers 704643072 bytes Redo Buffers 6836224 bytes Database mounted. Database opened. #重新执行 sql 语音 # 查看数据库编码方式 SQL> select userenv('language') from dual; USERENV('LANGUAGE') -------------------------------------------------------------------------------- AMERICAN_AMERICA.AL32UTF8 #实例状态 SQL> select status from v$instance; STATUS ------------------------ OPEN #数据库版本 SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production #激活sofft 用户 SQL> alter user scott account unlock; User altered. SQL> alter user scott identified by tiger; User altered. SQL> select username,account_status from dba_users; USERNAME ------------------------------------------------------------ ACCOUNT_STATUS ---------------------------------------------------------------- SYS OPEN SYSTEM OPEN SCOTT OPEN 。。。。。。省略
设置Oracle开机启动
1、修改 /home/oracle/data/product/11.2.0/bin/dbstart
[root@localhost bin]# vim dbstart #更改以下内容 将 ORACLE_HOME_LISTNER=$1 更改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
2、修改 /home/oracle/data/product/11.2.0/bin/dbshut
[root@localhost bin]# vim dbshut #更改以下内容 将 ORACLE_HOME_LISTNER=$1 更改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
3、修改 /etc/oratab
[root@localhost bin]# vim /etc/oratab 将 orcl:/home/oracle/data/product/11.2.0:N 修改为 orcl:/home/oracle/data/product/11.2.0:Y
4、新建文件 /etc/rc.d/init.d/oracle
#! /bin/bash # oracle: Start/Stop Oracle Database 11g R2 # # chkconfig: 345 90 10 # description: The Oracle Database is an Object-Relational Database Management System. # # processname: oracle ./etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/home/oracle/data/product/11.2.0 ORACLE_USER=oracle case "$1" in 'start') if [ -f $LOCKFILE ]; then echo $0 already running. exit 1 fi echo -n $"Starting Oracle Database:" su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start" su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole" touch $LOCKFILE ;; 'stop') if [ ! -f $LOCKFILE ]; then echo $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') $0 stop $0 start ;; 'status') if [ -f $LOCKFILE ]; then echo $0 started. else echo $0 stopped. fi ;; *) echo "Usage: $0 [start|stop|status]" exit 1 esac exit 0
5、给/etc/init.d/oracle添加执行权限
chmod +x /etc/init.d/oracle
6、开机启动oracle
[root@localhost init.d]# systemctl enable oracle 或 [root@localhost init.d]# chkconfig oracle on # 如; [root@localhost init.d]# systemctl enable oracle oracle.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig oracle on [root@localhost init.d]# chkconfig oracle on [root@localhost init.d]#
7、防火墙配置放开Oracle的端口
# 防火墙更多资料请参考我另一篇文章 firewall-cmd --zone=public --add-port=1521/tcp --permanent firewall-cmd --reload
参考文献
1、https://blog.csdn.net/chenghuikai/article/details/85776622
2、https://blog.csdn.net/lvtao0519/article/details/51135101
这篇关于cento7静默安装oracle11g的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享
- 2024-11-22怎么实现ansible playbook 备份代码中命名包含时间戳功能?-icode9专业技术文章分享