服務器采用的是阿里云,具體看下面
創(chuàng)新互聯(lián)于2013年開始,是專業(yè)互聯(lián)網技術服務公司,擁有項目做網站、成都網站制作網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元烏魯木齊做網站,已為上家服務,為烏魯木齊各地企業(yè)和個人服務,聯(lián)系電話:18980820575
[root@aliyun_test var]# cat /etc/system-release
CentOS release 6.5 (Final)
[root@aliyun_test var]# uname -r
2.6.32-431.23.3.el6.x86_64
[root@aliyun_test var]# uname -n
aliyun_test
內存:
由于阿里云默認是沒有swap的,所以這個需要自己創(chuàng)建,后面會提到如何創(chuàng)建
靜默安裝前一些必要的操作
#####install java
rpm -ivh jdk-7u75-linux-x64.rpm
echo "export JAVA_HOME=/usr/java/jdk1.7.0_75" >> /etc/profile.d/java.sh
echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile.d/java.sh
echo "export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar" >>/etc/profile.d/java.sh
. /etc/profile.d/java.sh
######verify java
java -version
一些必須的包
yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 ksh elfutils-libelf \
elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio \
libaio.i686 libaio-devel libaio-devel.i686 libgcc libstdc++ libstdc++.i686 \
libstdc++-devel libstdc++-devel.i686 make sysstat unixODBC unixODBC-devel unzip
然后是一些內核參數(shù)調整
########modify /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048576" >> /etc/sysctl.conf
/sbin/sysctl -p
然后是軟硬文件打開數(shù)
##############modify /etc/security/limits.conf
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
創(chuàng)建oracle用戶
#########create user oracle
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
passwd oracle
mkdir /u01/app -p
chown -R oracle:oinstall /u01
chmod 755 /u01/app
創(chuàng)建oracle清單文件
########create oraInventory
echo "inventory_loc=/u01/app/oraInventory" >> /etc/oraInst.loc
echo "inst_group=oinstall" >> /etc/oraInst.loc
chown -R oracle:oinstall /etc/oraInst.loc
chmod 755 /etc/oraInst.loc
添加登錄認證
########modify /etc/pam.d/login
#add
session required pam_limits.so
修改/etc/profile 限制其他用戶使用
############modify /etc/profile
# add follows to the end
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
然后切換oracle用戶進行操作
#########for oracle user
su - oracle
cd /home/oracle
file1:wget http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
file2:wget http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip
vim .bash_profile
export ORACLE_BASE=/u01/app
export ORACLE_SID=test
unzip linux.x64_11gR2_database_1of2.zip -d /u01/app
unzip linux.x64_11gR2_database_2of2.zip -d /u01/app
由于是使用靜默文件安裝oracle,所以必須創(chuàng)建修改響應文件(具體參數(shù)說明請參考官方網站)
cp /u01/app/database/response/db_install.rsp /home/oracle
chmod 700 /home/oracle/*.rsp
####add to rsp
修改以下值
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle11g
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/u01/app/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=test
oracle.install.db.config.starterdb.SID=test
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.password.ALL=redhat
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
準備工作就緒后,于是進行安裝
#######silent install oracle
cd /u01/app
./database/runInstaller -silent -responseFile /home/oracle/db_install.rsp
請根據(jù)屏幕上的輸出信息進行相應的措施(由于是阿里云主機,swap要求沒有達到)
swap內存做如下操作:
如果交換空間不夠:針對阿里云主機或者swap為0的主機
dd if=/dev/zero of=/test bs=1G count=4----》如果這種方法不行,請選擇下面
mkswap -f /test
swapon /test
free -m
設置2G的swap空間
[root@aliyun_test var]# dd if=/dev/zero of=/var/test bs=1G count=2
dd: memory exhausted
[root@aliyun_test var]# dd if=/dev/zero of=/var/test bs=1024 count=2097152
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB) copied, 38.0205 s, 56.5 MB/s
[root@aliyun_test var]# du -sh /var/test
2.1G /var/test
[root@aliyun_test var]# mkswap -f /var/test
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=d3ba4921-7d5e-47ae-810b-44f2369a24c2
[root@aliyun_test var]# swapon /var/test
[root@aliyun_test var]# free -m
total used free shared buffers cached
Mem: 994 930 63 0 31 809
-/+ buffers/cache: 89 905
Swap: 2047 0 2047
安裝到出現(xiàn)如下叫你使用root用戶執(zhí)行以下腳本
/u01/app/product/11.2.0/dbhome_1/root.sh
于是使用另一會話終端執(zhí)行
[root@aliyun_test ~]# /u01/app/product/11.2.0/dbhome_1/root.sh
Check /u01/app/product/11.2.0/dbhome_1/install/root_aliyun_test_2016-09-20_10-20-22.log for the output of root script
然后回到oracle用戶那個終端敲入enter鍵就安裝完成
然后繼續(xù)修改oracle家目錄下的環(huán)境文件如下
vim /home/oracle/.bash_profile
export ORACLE_HOME=/u01/app/product/11.2.0/dbhome_1
PATH=${ORACLE_HOME}/bin:$PATH:$HOME/bin
下一步就是配置監(jiān)聽服務,具體操作如下
啟動監(jiān)聽
###############modify netca.rsp
cp database/response/netca.rsp /home/oracle/
vim /home/oracle/netca.rsp
GENERAL]
RESPONSEFILE_VERSION="11.2"
CREATE_TYPE="CUSTOM"
INSTALL_TYPE=""custom" "安裝的類型("typical—典型","minimal—最小" or "custom—自定義")
LISTENER_NUMBER=1 監(jiān)聽器數(shù)量
LISTENER_NAMES={"test"} 監(jiān)聽器的名稱列表
LISTENER_PROTOCOLS={"TCP;1521"} 監(jiān)聽器使用的通訊協(xié)議列表
LISTENER_START=""test"" 監(jiān)聽器啟動的名稱
然后運行:
netca /silent /responsefile /home/oracle/netca.rsp
[oracle@aliyun_test app]$ netca /silent /home/oracle/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /opt/oracle/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Configuring Listener:test
Listener configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/product/11.2.0/dbhome_1/bin/lsnrctl start test
Listener Control complete.
Listener started successfully.
Profile configuration complete.
Oracle Net Services configuration successful. The exit code is 0
監(jiān)聽配置完,端口就會開啟,查看一下
[root@aliyun_test ~]# netstat -tunlp|grep 1521
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 17760/tnslsnr
/u01/app/product/11.2.0/dbhome_1/bin/tnslsnr test(這條命令啟動的)
最后創(chuàng)建單實例數(shù)據(jù)庫
靜默建立新庫
cp database/response/dbca.rsp /home/oracle/
vim /home/oracle/dbca.rsp
然后修改以下:
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0" //不能更改
OPERATION_TYPE = "createDatabase"
GDBNAME = "test" //全局數(shù)據(jù)庫的名字=SID+主機域名
SID= "test" //對應的實例名字
TEMPLATENAME = "General_Purpose.dbc" //建庫用的模板文件
SYSPASSWORD = "redhat" //SYS管理員密碼
SYSTEMPASSWORD = "redhat" //SYSTEM管理員密碼
DATAFILEDESTINATION = /u01/app/oradata //數(shù)據(jù)文件存放目錄
RECOVERYAREADESTINATION=/u01/app/flash_recovery_area //恢復數(shù)據(jù)存放目錄
CHARACTERSET = "AL32UTF8" //字符集,重要!!! 建庫后一般不能更改,所以建庫前要確定清楚。(CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "UTF8")
TOTALMEMORY = "380" //oracle內存
然后靜默建庫
dbca -silent -responseFile /home/oracle/dbca.rsp
如此之后數(shù)據(jù)庫創(chuàng)建完成,使用sqlplus命令操作,進行登錄
登錄的用戶采用的system密碼為redhat,上述操作都有記錄
至此靜默安裝oracle完成
啟動監(jiān)聽:
[oracle@oracle admin]$ lsnrctl start test
查看端口1521是否開啟
啟動數(shù)據(jù)庫:
[oracle@oracle admin]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 26 14:37:17 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 584568832 bytes
Fixed Size 2215544 bytes
Variable Size 490733960 bytes
Database Buffers 88080384 bytes
Redo Buffers 3538944 bytes
Database mounted.
Database opened.
連接數(shù)據(jù)庫:
[oracle@oracle admin]$ echo $ORACLE_SID
test
[oracle@oracle admin]$ sqlplus system/redhat@test
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 26 14:42:34 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 7 days
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
[oracle@oracle admin]$ echo $SERVICE_NAME
oracle.test
[oracle@oracle admin]$ sqlplus system/redhat@192.168.223.138:1521/oracle.test
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 26 14:44:02 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 7 days
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>