想个标题偏头痛 2020-02-18
centos7.7
oracle11gR2
新加
[ ~]# vim /etc/sysconfig/network NETWORKING_IPV6=no
修改/etc/hosts,把ipv6那句本地主机名解析的注释掉
[ ~]# vim /etc/hosts # ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
在/etc/modprobe.d/dist.conf文件中添加
[ ~]# vim /etc/modprobe.d/dist.conf alias net-pf-10 off alias ipv6 off
[ ~]# hostname localhost.localdomain
[ ~]# vim /etc/hosts 192.168.0.33 localhost.localdomain
[ ~]# vim /etc/selinux/config SELINUX=disabled
关闭防火墙
[ ~]# systemctl stop firewalld
关闭开机自启动防火墙
[ ~]# systemctl disable firewalld
查看防火墙状态
[ ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel
添加
[ ~]# vim /etc/sysctl.conf io-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
让更改的配置立即生效
[ ~]# sysctl –p
添加
[ ~]# 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
添加
[ ~]# vim /etc/pam.d/login session required /lib64/security/pam_limits.so session required pam_limits.so
添加
[ ~]# cat /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
[ ~]# groupadd oinstall [ ~]# groupadd dba [ ~]# useradd -g oinstall -G dba oracle [ ~]# passwd oracle
查看
[ ~]# id oracle uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba)
[ ~]# mkdir -p /u01/app/oracle/product/11.2.0/ [ ~]# mkdir /u01/app/oracle/oradata/ [ ~]# mkdir /u01/app/oracle/inventory/ [ ~]# mkdir /u01/app/oracle/fast_recovery_area/ [ ~]# chown -R oracle:oinstall /u01/app/oracle [ ~]# chmod -R 775 /u01/app/oracle/
[ ~]# ll /u01/app/ total 0 drwxrwxr-x. 11 oracle oinstall 169 Feb 18 07:31 oracle
可以通过wget从官网下载,或者通过xftp上传
[ ~]# ll /tmp/ -rw-r--r--. 1 root root 1239269270 Feb 2 21:36 linux.x64_11gR2_database_1of2.zip -rw-r--r--. 1 root root 1111416131 Feb 2 21:35 linux.x64_11gR2_database_2of2.zip
安装解压软件
[ ~]# yum install unzip zip -y
解压
[ tmp]# unzip linux.x64_11gR2_database_1of2.zip [ tmp]# unzip linux.x64_11gR2_database_2of2.zip
在tmp目录下多了一个目录
[ tmp]# ls database/ doc install response rpm runInstaller sshsetup stage welcome.html
[ tmp]# su - oracle Last login: Tue Feb 18 07:50:52 CST 2020 from 192.168.0.31 on pts/0
添加
[ ~]$ vim .bash_profile export PATH ORACLE_BASE=/u01/app/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
备份配置文件
[ oracle]# cp /tmp/database/response/db_install.rsp /root/
编辑
[ oracle]# vim /tmp/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=localhost.localdomain UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oracle/inventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/u01/app/oracle/product/11.2.0 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba DECLINE_SECURITY_UPDATES=true
oracle用户下,/tmp/database/目录下执行
[ database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
Checking swap space: 0 MB available, 150 MB required.
创建交换分区
[ database]$ su root Password: [ database]# dd if=/dev/zero of=/swapfile bs=1024 count=300000 [ database]# mkswap /swapfile [ database]# swapon /swapfile
查看
[ database]# swapon -s Filename Type Size Used Priority /swapfile file 299996 0 -2
加入到文件中
[ database]# vim /etc/fstab /swapfile swap swap defaults 0 0 [ database]# chown root:root /swapfile [ database]# chmod 0600 /swapfile
/u01/app/oracle/inventory/orainstRoot.sh /u01/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.
[ database]# sh /u01/app/oracle/inventory/orainstRoot.sh [ database]# sh /u01/app/oracle/product/11.2.0/root.sh
[ database]# su - oracle
[ ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp ****DISPLAY environment variable not set! Oracle Net Configuration Assistant is a GUI tool which requires that DISPLAY specify a location where GUI tools can display. Set and export DISPLAY, then re-run.
当提示如上,需要配置DISPLAY变量
[ ~]$ export DISPLAY=localhost:0.0
当提示
[ ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp Exception in thread "main" java.lang.UnsatisfiedLinkError: /u01/app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
需要安装
[ oracle]# yum install libXp [ oracle]# yum install libXp-devel
再次执行上面netca语句,输入下面内容,则成功执行
Listener configuration complete. Oracle Net Services configuration successful. The exit code is 0
[ ~]$ ls /u01/app/oracle/product/11.2.0/network/admin/ listener.ora samples shrept.lst sqlnet.ora
[ oracle]# yum install net-tools [ oracle]# netstat -tnulp | grep 1521 tcp6 0 0 :::1521 :::* LISTEN 14861/tnslsnr
[ oracle]# vim /tmp/database/response/dbca.rsp GDBNAME = "orcl" SID = "orcl" SYSPASSWORD = "oracle" SYSTEMPASSWORD = "oracle" SYSMANPASSWORD = "oracle" DBSNMPPASSWORD = "oracle" DATAFILEDESTINATION = /u01/app/oracle/oradata RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area CHARACTERSET = "ZHS16GBK" TOTALMEMORY = "1638"
[ oracle]# su - oracle [ ~]$ dbca -silent -responseFile /tmp/database/response/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 50% complete 55% complete 56% complete 60% complete 62% complete Completing Database Creation 66% complete 70% complete 73% complete 85% complete 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[ ~]$ ps -ef | grep ora_ | grep -v grep oracle 16464 1 0 07:32 ? 00:00:00 ora_pmon_orcl oracle 16466 1 0 07:32 ? 00:00:00 ora_vktm_orcl oracle 16470 1 0 07:32 ? 00:00:00 ora_gen0_orcl oracle 16472 1 0 07:32 ? 00:00:00 ora_diag_orcl oracle 16474 1 0 07:32 ? 00:00:00 ora_dbrm_orcl oracle 16476 1 0 07:32 ? 00:00:00 ora_psp0_orcl oracle 16478 1 0 07:32 ? 00:00:00 ora_dia0_orcl oracle 16480 1 0 07:32 ? 00:00:00 ora_mman_orcl
[ ~]$ lsnrctl status
底部出现如下信息,即成功
The command completed successfully
[ database]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 18 18:54:16 2020 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. SQL>
SQL> startup ORA-01081: cannot start already-running ORACLE - shut it down first
我是重启过机器,再次尝试,成功
SQL> startup
ORACLE instance started.
Total System Global Area 759943168 bytes
Fixed Size 2217224 bytes
Variable Size 448793336 bytes
Database Buffers 306184192 bytes
Redo Buffers 2748416 bytes
Database mounted.
Database opened.
SQL> select * from v$database;
DBID NAME CREATED RESETLOGS_CHANGE# RESETLOGS
PRIOR_RESETLOGS_CHANGE# PRIOR_RES LOG_MODE CHECKPOINT_CHANGE#
...
```