個人centos7是在virtualbox下安裝的,安裝Oracle安裝了很久很久,最開始的時候在網上找的兩個文章,按照步驟裝,有一篇寫着裝的時候有灰色的豎線,直接按space鍵或者鼠標右鍵closed關閉掉就OK,我想着這多好,安裝了好幾回,都失敗了,並且,在安裝以前我也沒有備份,我又有強迫症,稍有和步驟不同,或者安裝依賴包失敗了,就又要從頭再來,有時候會很生氣,真的就把它們通通卸載了,又從新安裝virtualbox,centos,安裝Oracle以前的準備工做,安裝Oracle,折騰了特別久,我要寫一個安裝步驟記錄下來我通過慘痛的教訓以後獲得的經驗。html
1.內存:python
RAW
|
Swap |
1G至2G | 1.5倍 |
2G至16G | 同RAW相等 |
16G以上 | 16G |
1 [cindyma@localhost ~]$ su root #切換到root 2 Password: 3 [root@localhost]# groupadd oinstall #建立用戶組oinstall 4 [root@localhost]# groupadd dba #建立用戶組dba 5 [root@localhost]# useradd -g oinstall -g dba -m oracle #建立oracle用戶,並加入到oinstall和dba用戶組 6 [root@localhost]# passwd oracle #設置用戶oracle的登錄密碼,不設置密碼,在CentOS的圖形登錄界面無法登錄 7 Changing password for user oracle. 8 New password: # 密碼 9 BAD PASSWORD: The password is shorter than 8 characters 10 Retype new password: # 確認密碼 11 passwd: all authentication tokens updated successfully. 12 [root@localhost]# id oracle # 查看新建的oracle用戶 13 uid=1001(oracle) gid=1002(dba) groups=1002(dba)
1 [root@localhost]# cd /. #進入根目錄 2 [root@localhost]# mkdir -p /data/oracle #oracle數據庫安裝目錄 3 [root@localhost]# mkdir -p /data/oraInventory #oracle數據庫配置文件目錄 4 [root@localhost]# mkdir -p /data/database #oracle數據庫軟件包解壓目錄 5 [root@localhost]# cd /data 6 [root@localhost data]# ls #建立完畢檢查一下(強迫症) 7 database oracle oraInventory 8 [root@localhost data]# chown -R oracle:oinstall /data/oracle #設置目錄全部者爲oinstall用戶組的oracle用戶 9 [root@localhost data]# chown -R oracle:oinstall /data/oraInventory 10 [root@localhost data]# chown -R oracle:oinstall /data/database 11 [root@localhost data]#
1 [root@localhost data]# cat /proc/version 2 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
3 [root@localhost data]# cat /etc/redhat-release 4 CentOS Linux release 7.3.1611 (Core) 5 [root@localhost data]# vi /etc/redhat-release 6 [root@localhost data]# cat /etc/redhat-release 7 redhat-7
1 [root@localhost data]# 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* unixODBC*
1 [root@localhost data]# systemctl status firewalld.service #查看防火牆狀態(運行中) 2 ● firewalld.service - firewalld - dynamic firewall daemon 3 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 4 Active: active (running) since Wed 2017-09-13 09:23:08 CST; 25min ago 5 Docs: man:firewalld(1) 6 Main PID: 641 (firewalld) 7 CGroup: /system.slice/firewalld.service 8 └─641 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 9
10 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami... 11 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic... 12 Hint: Some lines were ellipsized, use -l to show in full. 13 [root@localhost data]# systemctl stop firewalld.service #關閉防火牆 14 [root@localhost data]# systemctl status firewalld.service #查看防火牆狀態(已關閉) 15 ● firewalld.service - firewalld - dynamic firewall daemon 16 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 17 Active: inactive (dead) since Wed 2017-09-13 09:48:55 CST; 10s ago 18 Docs: man:firewalld(1) 19 Process: 641 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS) 20 Main PID: 641 (code=exited, status=0/SUCCESS) 21
22 Sep 13 09:22:58 localhost.localdomain systemd[1]: Starting firewalld - dynami... 23 Sep 13 09:23:08 localhost.localdomain systemd[1]: Started firewalld - dynamic... 24 Sep 13 09:48:54 localhost.localdomain systemd[1]: Stopping firewalld - dynami... 25 Sep 13 09:48:55 localhost.localdomain systemd[1]: Stopped firewalld - dynamic... 26 Hint: Some lines were ellipsized, use -l to show in full. 27 [root@localhost data]# systemctl disable firewalld.service #禁止使用防火牆(重啓也是禁止的) 28 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. 29 Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
1 [root@localhost data]# vi /etc/selinux/config 2 [root@localhost data]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.七、修改內核參數(加入斜體部分)
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #此處修改成disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
1 [root@local++host data]# vi /etc/sysctl.conf 2 [root@localhost data]# cat /etc/sysctl.conf
# sysctl settings are defined through files in八、使配置修改內核的參數生效
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
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
1 [root@localhost data]# sysctl -p
net.ipv4.icmp_echo_ignore_broadcasts = 1九、對oracle用戶設置限制,提升軟件運行性能(斜體爲添加部分)
net.ipv4.conf.all.rp_filter = 1
sysctl: setting key "fs.file-max": Invalid argument
fs.file-max = 6815744 #設置最大打開文件數
fs.aio-max-nr = 1048576
sysctl: setting key "kernel.shmall": Invalid argument
kernel.shmall = 2097152 #共享內存的總量,8G內存設置:2097152*4k/1024/1024
sysctl: setting key "kernel.shmmax": Invalid argument
kernel.shmmax = 2147483648 #最大共享內存的段大小
sysctl: setting key "kernel.shmmni": Invalid argument
kernel.shmmni = 4096 #整個系統共享內存端的最大數
kernel.sem = 250 32000 100 128
sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument
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
1 [root@localhost data]# vi /etc/security/limits.conf 2 [root@localhost data]# cat /etc/security/limits.conf
十、配置用戶的環境變量(斜體部分爲添加代碼)@student - maxlogins 4
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
End of
file
1 [root@localhost data]# vi /home/oracle/.bash_profile 2 [root@localhost data]# cat /home/oracle/.bash_profile
# .bash_profilelinux
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fic++# User specific environment and startup programssql
PATH=$PATH:$HOME/.local/bin:$HOME/bin數據庫
export PATHvim
export ORACLE_BASE=/data/oracle #oracle數據庫安裝目錄
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 #oracle數據庫路徑
export ORACLE_SID=orcl #oracle啓動數據庫實例名
export ORACLE_UNQNAME=orcl
export ORACLE_TERM=xterm #xterm窗口模式安裝
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH #添加系統環境變量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #添加系統環境變量
export LANG=C #防止安裝過程出現亂碼
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK #設置Oracle客戶端字符集,必須與Oracle安裝時設置的字符集保持一致centos
1 [root@localhost data]# source /home/oracle/.bash_profile
1 [root@localhost ~]# cd /. 2 [root@localhost /]# cd /home/anzerong/Desktop/
3 [root@localhost Desktop]# ls
4 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
5 [root@localhost Desktop]# mv linux.x64_11gR2_database_1of2.zip /usr/local/src 6 [root@localhost Desktop]# ls
7 linux.x64_11gR2_database_2of2.zip
8 [root@localhost Desktop]# mv linux.x64_11gR2_database_2of2.zip /usr/local/src
1 [root@localhost Desktop]# reboot
1 [oracle@localhost /]$ cd /usr/local/src 2 [oracle@localhost src]$ ls 3 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
1 [oracle@localhost src]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/database/ #解壓 2 (省略...) 3 [oracle@localhost src]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/database/ #解壓 4 (省略...)
1 [oracle@localhost src]$ su root 2 Password: 3 [root@localhost src]# chown -R oracle:oinstall /data/database/database/
4 [oracle@localhost /]$ cd /data/database/database/
5 [oracle@localhost database]$ ls
6 doc install response rpm runInstaller sshsetup stage welcome.html 7 [oracle@localhost database]$ ./runInstaller 8 Starting Oracle Universal Installer... 9 (省略...)
1 [oracle@localhost ~]# su - root 2 password 3 [root@localhost ~]# yum -y install glibc-static
該軟件包包含一個靜態連接庫,地址是:/usr/lib64/libc.a
解決辦法:安裝rlwrap包bash
1)下載rlwrap壓縮包(我下載的是rlwrap-0.37.tar.gz);oracle
2)yum安裝readline
[root@localhost oracle]#yum -y install readline*
3)解壓,安裝
[root@localhost oracle]#tar -xzvf rlwrap-0.37.tar.gz [root@localhost oracle]#cd rlwrap-0.37.tar.gz [root@localhost oracle]#./configure [root@localhost oracle]#make [root@localhost oracle]#make install
4)切換到oracle用戶下,編輯bash_profile文件
[oracle@localhost ~]vi .bash_profile
在最後添加
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
保存退出,執行source .bash_profile使其生效。
或者直接不修改bash_profile文件,直接在輸入sqlplus命令前加上rlwrap便可(我修改了bash_profile文件,重啓系統仍是要從新輸入source命令使其生效,我以後直接在sqlplus命令前加rlwrap)。
這樣在sqlplus中就可使用上下左右鍵來查看歷史紀錄了。
設置~下或者oracle用戶下的.vimrc文件,加上fileencodings、enc、fencs,代碼以下:
vim ~/.vimrc #或者vim /home/oracle(用戶名)/.vimrc
#添加以下代碼
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set enc=utf8
set fencs=utf8,gbk,gb2312,gb18030
參考:
1.http://www.cnblogs.com/anzerong2012/p/7528311.html
2.http://www.jb51.net/article/105102.htm
3.http://www.javashuo.com/article/p-ynsowrkv-gh.html
4.https://jingyan.baidu.com/article/90808022edddf0fd91c80fdd.html
5.https://www.zhihu.com/question/22363620