[root@centos7 ~]# yum update -y
vi /etc/security/limits.conf
添加以下参数:html
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
vi /etc/sysctl.conf
添加以下参数:linux
fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 4294967295 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
[root@centos7 ~]# sysctl -p [root@centos7 ~]# sysctl -a
/usr/sbin/groupadd -g 54321 oinstall /usr/sbin/groupadd -g 54322 dba /usr/sbin/groupadd -g 54323 oper /usr/sbin/groupadd -g 54324 backupdba /usr/sbin/groupadd -g 54325 dgdba /usr/sbin/groupadd -g 54326 kmdba /usr/sbin/groupadd -g 54327 asmdba /usr/sbin/groupadd -g 54328 asmoper /usr/sbin/groupadd -g 54329 asmadmin /usr/sbin/groupadd -g 54330 racdba /usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,oper oracle /usr/sbin/useradd -u 54322 -g oinstall -G asmdba,asmadmin grid
设置oracle和grid用户密码:c++
[root@centos7 ~]# passwd oracle
[root@centos7 ~]# passwd grid
[root@centos7 ~]# yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 \ glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 \ libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 \ libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64
若是CentOS7没有安装X Window,还要安装一X Window的相关软件:git
[root@centos7 ~]# yum groupinstall -y "X Window System" [root@centos7 ~]# yum install cjkuni-uming-fonts
经过oracle用户上传linuxx64_12201_database.zip文件github
在使用oracle用户进行安装sql
ssh -X oracle@192.168.1.100
这样就能够将服务器端的界面输出到客户端。数据库
[oracle@centos7 ~]$ unzip linuxx64_12201_database.zip [oracle@centos7 ~]$ cd database [oracle@centos7 database]$ ./runInstaller
# /home/oracle/:是oracle用户的home目录 # 因此Oracle基目录默认是操做系统用户的home目录下面的app/oracle
# /home/oracle/app/oracle/product/12.2.0/dbhome_1 # 这里意味着其余oracle数据库软件目录都放在Oracle基目录的product目录下面,这里能够看出我安装的oracle软件版本为12.2.0
# /home/oracle/app/oraInventory: 与Oracle基目录并列在同一个app父目录下面
**Note:**值得注意的是最后须要root用户执行2次脚本。centos
[root@centos7 ~]# /home/oracle/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /home/oracle/app/oraInventory to oinstall. The execution of the script is complete. # 把/home/oracle/app/oraInventory目录的读写权限给oinstall用户组
[root@centos7 ~]# /home/oracle/app/oracle/product/12.1.0/dbhome_1/root.sh Performing root user operation. The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /home/oracle/app/oracle/product/12.1.0/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: <PRESS ENTER> Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root script. Now product-specific root actions will be performed. Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : yes Installing Oracle Trace File Analyzer (TFA). Log File: /home/oracle/app/oracle/product/12.2.0/dbhome_1/install/root_localhost.localdomain_2017-05-22_14-31-35-542560085.log Finished installing Oracle Trace File Analyzer (TFA) # 告诉你一些oracle的基本安装信息,最后问你是否安装TFA,我选择了yes,等一段时间就能够了
到这里就安装完成了Oracle数据库软件。安全
[oracle@centos7 ~]$ vi /home/oracle/.bash_profile
TMPDIR=$TMP; export TMPDIR ORACLE_BASE=/home/oracle/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID # 注意这里到oracle sid PATH=$ORACLE_HOME/bin:$PATH; export PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
使配置生效:bash
[oracle@centos7 ~]$ . .bash_profile
**NOTE:**必定要启用归档,归档很重要的。
![这样就建库完成了(http://upload-images.jianshu.io/upload_images/650171-e2ee72a531107e7b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) **Note:**这里建议仍是去口令管理,修改一下SYS和SYSTEM账户。
[oracle@oracle ~]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Mon May 22 16:34:08 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. ???: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL>
这里出现乱码了。
SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- SIMPLIFIED CHINESE_CHINA.AL32UTF8 SQL> quit # 添加环境便利NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8" [oracle@oracle ~]$ vi .bash_profile NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"; export NLS_LANG [oracle@oracle ~]$ . .bash_profile
再次sqlplus登陆就没有乱码了。
https://github.com/hanslub42/rlwrap 到这里下载源代码进行安装,由于yum没有rlwrap,下载后上传到root的home目录,进行源码安装。
[root@oracle ~]# tar xvf rlwrap-0.43.tar.gz [root@oracle ~]# cd rlwrap-0.43/ ... checking for readline in -lreadline... no configure: error: You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build this program!
这里表示rlwrap须要readline依赖。
[root@oracle rlwrap-0.43]# yum install readline-static.x86_64
继续编译安装rlwrap:
make make check make install
安装rlwrap成功后,配置环境变量:
[root@oracle ~]# vi .bash_profile alias rlsqlplus='rlwrap sqlplus' alias rlrman='rlwrap rman' [oracle@oracle ~]$ source .bash_profile
再次使用rlsqlplus登陆oralce,就能够正常调用上下键了,不会出现乱码了:
[oracle@oracle ~]$ rlsqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on 星期一 5月 22 17:15:44 2017 Copyright (c) 1982, 2016, Oracle. All rights reserved. 链接到: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- SIMPLIFIED CHINESE_CHINA.AL32UTF8 SQL> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- SIMPLIFIED CHINESE_CHINA.AL32UTF8 SQL> quit 从 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 断开
参考:
Linux下SQLPlus中文乱码处理
rlwrap for Command Line History and Editing in SQL*Plus and RMAN on Linux
oracle单实例12.2.0.1安装
Oracle Database 12c Installation on CentOS 7