[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