目录
- 1. 搭建本地源:
- 2. Centos7.2基本环境配置:
- 3. 配置安装oracle
- 3.1. 检查内存SWAP分区大小
- 3.2. 安装oracle必须的环境包
- 3.3. 检查oracle需要的用户和组,并确认oracle用户及设置密码
- 3.4. 优化oracle内核参数
- 3.5. 创建oracle安装目录并设置权限
- 3.6. 使用su命令切换到oracle用户,为其设置环境变量
- 3.7. 将下载好的oracle安装包解压
- 3.8. 编辑Oracle静默安装响应文件 db_install.rsp
- 3.9. 编辑 Oracle 静默安装响应文件 db_install.rsp 根据响应文件配置安装oracle
- 3.10. 切换回oracle用户,配置监听以便能让其他主机能远程到当前oracle数据库
- 3.11. 静默创建Oracle实例和数据库
- 3.12. 启动Oracle数据库
- 3.13. 启动Oracle数据库基础命令
- 4. 表空间
- 5. 参考文献
1. 搭建本地源:
1.1. 加载 CentOS的ISO镜像并挂载:
1 2 |
[root@localhost files]# mount CentOS-7-x86_64-DVD-1511.iso /mnt/cdrom/ |
1.2. 新建CentOS目录并把ISO上的文件复制到该目录下:
1 2 3 |
[root@localhost files]# mkdir /media/CentOS/ [root@localhost files]# cp -fr /mnt/cdrom/* /media/CentOS/ |
1.3. 修改yum配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@localhost /]# vi /etc/yum.repos.d/CentOS-Media.repo # CentOS-Media.repo # # This repo can be used with mounted DVD media, verify the mount point for # CentOS-7. You can use this repo and yum to install items directly off the # DVD ISO that we release. # # To use this repo, put in your DVD and use it with the other repos too: # yum --enablerepo=c7-media [command] # # or for ONLY the media repo, do this: # # yum --disablerepo=\* --enablerepo=c7-media [command] [c7-media] name=CentOS-$releasever - Media baseurl=file:///media/CentOS/ -->这一行改成之前新建的CentOS目录 # file:///media/cdrom/ -->这一行加#号注释掉 # file:///media/cdrecorder/ -->这一行加#号注释掉 gpgcheck=1 enabled=1 -->这一行把0改成1来启用源 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 |
1.4. 清除yum缓存及更新yum源
1 2 3 |
[root@localhost /]# yum clean all [root@localhost /]# yum repolist all |
1.5. 卸载镜像并重启
1 2 3 |
[root@localhost /]# umount /mnt/cdrom/ [root@localhost /]# reboot |
2. Centos7.2基本环境配置:
2.1. 关闭防火墙和SELinux
1 2 3 4 5 6 |
[root@localhost ~]# setenforce 0 [root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld |
2.2. 配置计算机名
1 2 3 |
[root@localhost ~]# hostnamectl --static set-hostname edata [root@localhost ~]# echo "192.168.0.97 edata" >>/etc/hosts |
2.3. 修改IP为固定IP地址
1 2 3 4 5 6 7 8 9 |
[root@localhost ~]# cd /etc/sysconfig/network-scripts/ [root@localhost network-scripts]# vi ifcfg-ens33 ONBOOT=yes //修改ONBOOT=yes BOOTPROTO=static //修改dhcp为static,设置静态IP地址 IPADDR=192.168.0.97 //新增行配置IP地址 NETMASK=255.255.255.0 //新增行配置子网掩码 GATEWAY=192.168.0.251 //新增行配置网关 [root@localhost ~]# systemctl restart network |
2.4. 安装lrzsz
1 2 |
[root@localhost ~]# yum -y install lrzsz |
3. 配置安装oracle
3.1. 检查内存SWAP分区大小
1 2 3 4 5 |
[root@edata ~]# grep MemTotal /proc/meminfo MemTotal: 3882640 kB [root@edata ~]# grep SwapTotal /proc/meminfo SwapTotal: 4063228 kB |
3.2. 安装oracle必须的环境包
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@imorcl ~]# yum -y install binutils \ compat-libstdc++-33 \ elfutils-libelf \ elfutils-libelf-devel \ expat \ gcc \ gcc-c++ \ glibc \ glibc-common \ glibc-devel \ glibc-headers \ libaio \ libaio-devel \ libgcc \ libstdc++ \ libstdc++-devel \ libXp \ make \ pdksh \ sysstat \ unixODBC \ unixODBC-devel |
注意pdksh和compat-libstdc++-33是没办法接使用yum安装上的,所以需要单独安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@edata ~]# ll total 6524092 -rw-------. 1 root root 1209 Nov 21 2018 anaconda-ks.cfg -rw-r--r-- 1 root root 4329570304 Aug 24 2017 CentOS-7-x86_64-DVD-1511.iso -rw-r--r-- 1 root root 195388 May 2 2018 compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm -rw-r--r-- 1 root root 1239269270 Nov 19 17:27 linux.x64_11gR2_database_1of2.zip -rw-r--r-- 1 root root 1111416131 Nov 19 17:27 linux.x64_11gR2_database_2of2.zip -rw-r--r-- 1 root root 210877 May 2 2018 pdksh-5.2.14-37.el5_8.1.x86_64.rpm [root@edata ~]# rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm warning: pdksh-5.2.14-37.el5_8.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID e8562897: NOKEY Preparing... ################################# [100%] package pdksh-5.2.14-37.el5_8.1.x86_64 is already installed [root@edata ~]# rpm -ivh compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm Preparing... ################################# [100%] package compat-libstdc++-33-3.2.3-72.el7.x86_64 is already installed |
再次检查环境包是否安装完整
1 2 |
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel libXp make pdksh sysstat unixODBC unixODBC-devel |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
binutils-2.23.52.0.1-55.el7.x86_64 compat-libstdc++-33-3.2.3-72.el7.x86_64 elfutils-libelf-0.163-3.el7.x86_64 elfutils-libelf-devel-0.163-3.el7.x86_64 expat-2.1.0-8.el7.x86_64 gcc-4.8.5-4.el7.x86_64 gcc-c++-4.8.5-4.el7.x86_64 glibc-2.17-105.el7.x86_64 glibc-common-2.17-105.el7.x86_64 glibc-devel-2.17-105.el7.x86_64 glibc-headers-2.17-105.el7.x86_64 libaio-0.3.109-13.el7.x86_64 libaio-devel-0.3.109-13.el7.x86_64 libgcc-4.8.5-4.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 libstdc++-devel-4.8.5-4.el7.x86_64 libXp-1.0.2-2.1.el7.x86_64 make-3.82-21.el7.x86_64 pdksh-5.2.14-37.el5_8.1.x86_64 sysstat-10.1.5-7.el7.x86_64 unixODBC-2.3.1-11.el7.x86_64 unixODBC-devel-2.3.1-11.el7.x86_64 [root@edata ~]# |
3.3. 检查oracle需要的用户和组,并确认oracle用户及设置密码
1 2 3 4 5 6 7 8 9 |
[root@edata ~]# groupadd oinstall [root@edata ~]# groupadd dba [root@edata ~]# groupadd asmadmin [root@edata ~]# groupadd asmdba [root@edata ~]# useradd -g oinstall -G dba,asmdba oracle [root@edata ~]# echo 111111 |passwd --stdin oracle [root@edata ~]# id oracle uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba),1003(asmdba |
3.4. 优化oracle内核参数
3.4.1. 修改 sysctl.conf 文件,在文档尾部新增如下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@edata ~]# vi /etc/sysctl.conf fs.aio-max-nr=1048576 fs.file-max=6815744 kernel.shmall=2097152 kernel.shmmni=4096 #该值为物理内存的一半(byte),最好不要低于我设置的这个值,不然后面新增数据库实例时可能会报错 kernel.shmmax = 536870912 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=1048586 [root@imorcl ~]# sysctl -p |
3.4.2. 修改 limits.conf 文件,在文档尾部新增如下内容
1 2 3 4 5 6 7 |
[root@edata~]# 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 |
3.4.3. 修改 login 文件,在文档尾部新增如下内容
1 2 3 4 |
[root@edata ~]# tail -n 2 /etc/pam.d/login session required /lib64/security/pam_limits.so session required pam_limits.so |
3.4.4. 修改 profile 文件,在文档尾部新增如下内容
1 2 3 4 5 6 7 8 9 10 |
[root@edata~]# tail -n 8 /etc/profile if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi |
3.5. 创建oracle安装目录并设置权限
1 2 3 4 5 6 7 |
[root@edata ~]# mkdir -p /home/oracle/app/oracle/product/11.2.0 [root@edata ~]# mkdir /home/oracle/app/oracle/oradata [root@edata ~]# mkdir /home/oracle/app/oracle/inventory [root@edata ~]# mkdir /home/oracle/app/oracle/fast_recovery_area [root@edata ~]# chown -R oracle:oinstall /home/oracle/app/oracle [root@edata ~]# chmod -R 755 /home/oracle/app/oracle |
3.6. 使用su命令切换到oracle用户,为其设置环境变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@edata ~]# su - oracle [oracle@edata ~]$ vi .bash_profile #修改.bash_profile文件,在文档尾部新增如下内容 [oracle@edata ~]$ tail -n 6 .bash_profile export ORACLE_SID=orcl export ORACLE_BASE=/home/oracle/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0 export INVENTORY_LOCATION=/home/oracle/app/oraInventory export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib export NLS_LANG="American_america.zhs16gbk" export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' export PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin |
3.7. 将下载好的oracle安装包解压
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@edata ~]# ll total 6524092 -rw-------. 1 root root 1209 Nov 21 2018 anaconda-ks.cfg -rw-r--r-- 1 root root 4329570304 Aug 24 2017 CentOS-7-x86_64-DVD-1511.iso -rw-r--r-- 1 root root 195388 May 2 2018 compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm -rw-r--r-- 1 root root 1239269270 Nov 19 17:27 linux.x64_11gR2_database_1of2.zip -rw-r--r-- 1 root root 1111416131 Nov 19 17:27 linux.x64_11gR2_database_2of2.zip -rw-r--r-- 1 root root 210877 May 2 2018 pdksh-5.2.14-37.el5_8.1.x86_64.rpm [root@imorcl ~]# mkdir /home/oracle/installSoft [root@imorcl ~]# unzip linux.x64_11gR2_database_1of2.zip -d /home/oracle/installSoft/ [root@imorcl ~]# unzip linux.x64_11gR2_database_2of2.zip -d /home/oracle/installSoft/ |
3.8. 编辑Oracle静默安装响应文件 db_install.rsp
注意:这里的 ORACLE_HOSTNAME
是你当前主机的主机名,复制之前请修改。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@edata ~]# cd /home/oracle/installSoft/database/response/ [root@edata response]# sed -i 's/^DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/' db_install.rsp [root@edata response]# sed -i 's/oracle.install.db.OPER_GROUP=/oracle.install.db.OPER_GROUP=dba/' db_install.rsp [root@edata response]# sed -i 's/oracle.install.db.DBA_GROUP=/oracle.install.db.DBA_GROUP=dba/' db_install.rsp [root@edata response]# sed -i 's/oracle.install.db.InstallEdition=/oracle.install.db.InstallEdition=EE/' db_install.rsp [root@edata response]# sed -i 's@ORACLE_BASE=@ORACLE_BASE=/home/oracle/app/oracle@' db_install.rsp [root@edata response]# sed -i 's@ORACLE_HOME=@ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0@' db_install.rsp [root@edata response]# sed -i 's/^SELECTED_LANGUAGES=/SELECTED_LANGUAGES=en,zh_CN/' db_install.rsp [root@edata response]# sed -i 's@INVENTORY_LOCATION=@INVENTORY_LOCATION=/home/oracle/app/oracle/inventory@' db_install.rsp [root@edata response]# sed -i 's/UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/' db_install.rsp [root@imorcl response]# sed -i 's/ORACLE_HOSTNAME=/ORACLE_HOSTNAME=edata/' db_install.rsp [root@edata response]# sed -i 's/oracle.install.option=/oracle.install.option=INSTALL_DB_SWONLY/' db_install.rsp |
校验
grep -E 'oracle.install.option|ORACLE_HOSTNAME|UNIX_GROUP_NAME|INVENTORY_LOCATION|SELECTED_LANGUAGES|ORACLE_HOME|ORACLE_BASE|oracle.install.db.InstallEdition|racle.install.db.DBA_GROUP|racle.install.db.OPER_GROUP|ECLINE_SECURITY_UPDATES' ./db_install.rsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[oracle@edata response]$ grep -E 'oracle.install.option|ORACLE_HOSTNAME|UNIX_GROUP_NAME|INVENTORY_LOCATION|SELECTED_LANGUAGES|ORACLE_HOME|ORACLE_BASE|oracle.install.db.InstallEdition|racle.install.db.DBA_GROUP|racle.install.db.OPER_GROUP|ECLINE_SECURITY_UPDATES' ./db_install.rsp oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=edata UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/home/oracle/app/oracle/inventory # Example : SELECTED_LANGUAGES=en,fr,ja SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0 ORACLE_BASE=/home/oracle/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba # Example : DECLINE_SECURITY_UPDATES=false DECLINE_SECURITY_UPDATES=true [oracle@edata response]$ |
3.9. 编辑 Oracle 静默安装响应文件 db_install.rsp 根据响应文件配置安装oracle
警告:千万不要中断会话,或者做其他操作,直到中断提示成功或者其他失败信息;
如正常的话,会提示让查看日志文件确认安装情况,直接xshell复制当前会话在打开一个终端,时候使用 tail -f FileName
,确认日志文件一直有输出就说明在安装了。
1 2 3 4 |
[root@edata ~]# su - oracle [oracle@edata ~]$ cd /home/oracle/installSoft/database/ [oracle@edata database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/installSoft/database/response/db_install.rsp |
根据提示在安装完成后,切换到root用户,执行提示的两个脚本
1 2 3 4 5 6 7 8 9 10 11 12 |
[oracle@edata database]$ su - root [root@edata ~]# /home/oracle/app/oracle/inventory/orainstRoot.sh Changing permissions of /home/oracle/app/oracle/inventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /home/oracle/app/oracle/inventory to oinstall. The execution of the script is complete. [root@edata ~]# /home/oracle/app/oracle/product/11.2.0/root.sh Check /home/oracle/app/oracle/product/11.2.0/install/root_edata_2018-11-22_17-40-56.log for the output of root script [root@edata ~]# |
执行结果如图实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[root@edata ~]# su - oracle [oracle@edata ~]$ cd /home/oracle/installSoft/database/ [oracle@node4 database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/installSoft/database/response/db_install.rsp Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 50023 MB Passed Checking swap space: must be greater than 150 MB. Actual 8063 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-11-22_03-06-40PM. Please wait ...[oracle@node4 database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base. CAUSE: The Central Inventory is located in the Oracle base. ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory. [WARNING] [INS-32055] The Central Inventory is located in the Oracle base. CAUSE: The Central Inventory is located in the Oracle base. ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory. You can find the log of this install session at: /home/oracle/app/oracle/inventory/logs/installActions2018-11-22_03-06-40PM.log [oracle@node4 database]$ The following configuration scripts need to be executed as the "root" user. #!/bin/sh #Root scripts to run /home/oracle/app/oracle/inventory/orainstRoot.sh /home/oracle/app/oracle/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. [oracle@node4 database]$ |
3.10. 切换回oracle用户,配置监听以便能让其他主机能远程到当前oracle数据库
请将DISPLAY 改为当前机器的 ip
1 2 3 4 |
[root@edata ~]# su - oracle [oracle@edata ~]$ export DISPLAY=192.168.0.64:0.0 [oracle@edata ~]$ netca -silent -responseFile /home/oracle/installSoft/database/response/netca.rsp |
3.11. 静默创建Oracle实例和数据库
1 2 |
[oracle@edata ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -sysPassword 111111 -systemPassword 111111 -responseFile NO_VALUE -datafileDestination /home/oracle/app/oracle/oradata/ -redoLogFileSize 50 -recoveryAreaDestination /home/oracle/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE |
3.12. 启动Oracle数据库
这步应该不需要,因为已经启动
1 2 3 |
[oracle@edata ~]$ sqlplus / as sysdba SQL> startup |
3.13. 启动Oracle数据库基础命令
3.13.1. 监听状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[oracle@edata ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-NOV-2018 14:55:48 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 21-NOV-2018 14:38:33 Uptime 0 days 0 hr. 17 min. 15 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/11.2.0/network/admin/listener.ora Listener Log File /home/oracle/app/oracle/diag/tnslsnr/edata/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edata)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status BLOCKED, has 1 handler(s) for this service... The command completed successfully |
3.13.2. 查看oracle是否启动
1 2 3 4 |
[oracle@edata ~]$ ps -ef |grep ora_mmon oracle 14012 1 0 14:48 ? 00:00:00 ora_mmon_orcl oracle 14137 14100 0 14:56 pts/2 00:00:00 grep --color=auto ora_mmon |
4. 表空间
4.1. 创建名称为 edata 的表空间
1 2 |
create tablespace edata datafile '/home/oracle/app/oracle/oradata/orcl/edata.dbf' size 512M autoextend on next 1024M maxsize 4096M extent management local; |
4.2. 创建用户名/密码为 edata/edata 的用户
1 2 |
CREATE USER edata IDENTIFIED BY edata ACCOUNT UNLOCK DEFAULT TABLESPACE edata; |
4.3. 为用户配置权限
1 2 |
GRANT DBA,CONNECT,RESOURCE TO edata; |
4.4. 导入 dmp 文件
1 2 |
imp edata/edata file=/tmp/edata.dmp full=y |
5. 参考文献
https://www.imorcl.cn/281.html
原创文章,转载请注明: 转载自LoserZhao – 诗和远方[ http://www.loserzhao.com/ ]
本文链接地址: http://www.loserzhao.com/bigdata-maintenance/oracle-11gr2-install-outline-centos7-2.html
文章的脚注信息由WordPress的wp-posturl插件自动生成
0 条评论。