Oracle之静默安装
服务器采用的是阿里云,具体看下面
创新互联于2013年开始,是专业互联网技术服务公司,拥有项目做网站、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元乌鲁木齐做网站,已为上家服务,为乌鲁木齐各地企业和个人服务,联系电话: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的,所以这个需要自己创建,后面会提到如何创建
静默安装前一些必要的操作
#####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
然后是一些内核参数调整
########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
然后是软硬文件打开数
##############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
创建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
创建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,所以必须创建修改响应文件(具体参数说明请参考官方网站)
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
请根据屏幕上的输出信息进行相应的措施(由于是阿里云主机,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
安装到出现如下叫你使用root用户执行以下脚本
/u01/app/product/11.2.0/dbhome_1/root.sh
于是使用另一会话终端执行
[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键就安装完成
然后继续修改oracle家目录下的环境文件如下
vim /home/oracle/.bash_profile
export ORACLE_HOME=/u01/app/product/11.2.0/dbhome_1
PATH=${ORACLE_HOME}/bin:$PATH:$HOME/bin
下一步就是配置监听服务,具体操作如下
启动监听
###############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 监听器数量
LISTENER_NAMES={"test"} 监听器的名称列表
LISTENER_PROTOCOLS={"TCP;1521"} 监听器使用的通讯协议列表
LISTENER_START=""test"" 监听器启动的名称
然后运行:
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
监听配置完,端口就会开启,查看一下
[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(这条命令启动的)
最后创建单实例数据库
静默建立新库
cp database/response/dbca.rsp /home/oracle/
vim /home/oracle/dbca.rsp
然后修改以下:
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0" //不能更改
OPERATION_TYPE = "createDatabase"
GDBNAME = "test" //全局数据库的名字=SID+主机域名
SID= "test" //对应的实例名字
TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件
SYSPASSWORD = "redhat" //SYS管理员密码
SYSTEMPASSWORD = "redhat" //SYSTEM管理员密码
DATAFILEDESTINATION = /u01/app/oradata //数据文件存放目录
RECOVERYAREADESTINATION=/u01/app/flash_recovery_area //恢复数据存放目录
CHARACTERSET = "AL32UTF8" //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。(CHARACTERSET = "AL32UTF8"
NATIONALCHARACTERSET= "UTF8")
TOTALMEMORY = "380" //oracle内存
然后静默建库
dbca -silent -responseFile /home/oracle/dbca.rsp
如此之后数据库创建完成,使用sqlplus命令操作,进行登录
登录的用户采用的system密码为redhat,上述操作都有记录
至此静默安装oracle完成
启动监听:
[oracle@oracle admin]$ lsnrctl start test
查看端口1521是否开启
启动数据库:
[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.
连接数据库:
[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>
网页名称:Oracle之静默安装
文章来源:http://azwzsj.com/article/pgcdoc.html