今天弄了一天,过程很艰辛,在此分享一下安装的整个过程,一部分是贴的公司的文档,一部分是安装过程中报的错。
- 系统时rhel6.2,64位。(2G内存)
首先挂载了rhel6-2的iso文件,便于安装一些依赖包。做好本地源后,用yum安装
yum–y install binutils elfutils-libelf elfutils-libelf-devel gcc ksh libstdc++ libstdc++-devel libgcc glibc glibc-devel libaio libaio-devel make sysstat unixODBC unixODBC-devel libstdc++44-devel compat-libstdc++(centos6.5 安装时需要安装)
因为系统是64位的,需要安装glibc-devel的32包,可通过本地光盘获取,
rpm -ivh glibc-devel-2.12-1.47.el6.i686.rpm
/etc/hosts文件需要写,安装过程中设置了一个主机名myorcl,ip为192.168.4.121
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.4.121 node1.example.com
不添加第一行发现在启动监听时报错
创建用户 执行以下命令 #groupadd oinstall #groupadd dba #useradd -g oinstall -G dba oracle #passwd oracle echo"fs.aio-max-nr = 1048576">> /etc/sysctl.conf echo"fs.file-max = 6815744">> /etc/sysctl.conf echo"kernel.shmall = 2097152" >> /etc/sysctl.conf(2g) echo"kernel.shmmax = 536870912" >> /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 = 1048586" >> /etc/sysctl.conf -- 如果安装时ORA-27125报错echo"vm.hugetlb_shm_group = 501" >> /etc/sysctl.conf #sysctl -p
添加一下参数
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 加入以下配置 Session required pam_limits.so 加入以下配置 if[ $USER = "oracle" ]; then if[ $SHELL = "/bin/ksh" ]; then ulimit-p 16384 ulimit-n 65536 else ulimit-u 16384 -n 65536 fi fi 执行以下命令: #mkdir -p /u01/app/ #chown -R oracle:oinstall /u01/app/ #chmod -R 775 /u01/app/ 其中/u01为任意挂在点 #mkdir /disk1 /disk2 执行以下命令: #unzip /root/linux.x64_11gR2_database_1of2.zip-d /disk1 #unzip /root/linux.x64_11gR2_database_2of2.zip-d /disk2 #cp -r /disk2/database/stage/Components/*/disk1/database/stage/Components/ 以上全部都是一些前期准备工作,
#su - oracle $echo "umask 022" >> ~/.bash_profile $chmod 755 .bash_profile $. /.bash_profile 执行以下命令: $ORACLE_BASE=/u01/app/oracle $ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 $ORACLE_SID=orcl $LD_LIBRARY_PATH=$ORACLE_HOME/lib $exportORACLE_BASE ORACLE_HOMEORACLE_SID PATH 执行以下命令 $unset ORACLE_HOME $unset TNS_ADMIN 我用的客户端软件是xmanager,可以通过xshell连接到服务器安装 需要用oracle用户登录Redhat的图形界面, 图形图形界面乱码执行exportLANG="en_US" 执行安装脚本,在终端程序内执行命令:
$/disk1/database/runInstaller
脚本将运行图形化安装界面,依照提示完成以下步骤,即完成安装 ConfigureSecurity Updates SelectInstallation Option
SystemClass GridInstallation Options SelectInstall Type TypicalInstall Configuration CreateInventory PerformPrerequistite Checks Summary Installproduct Finish 忽略电子邮件和安全更新,点击“Next”。 选择“Createand configure a database”,点击“Next”。 选择“ServerClass”,点击“Next”。 选择“Singleinstance database installation”,点击“Next”。
“Globaldatabase name”处填qatest(根据实际情况修改),为数据库名。 该名对应于平台部署时需要更改的数据链接地址。如: <propertyname="url"value="jdbc:oracle:thin:@192.168.2.93:1521:qatest"/> “Administrativepassword”为sys用户的密码,安装好数据库后登录管理用的。 密码Pukka2013
安装过程中可能会报错swap分区不够,增加swap分区的方法
1、检查当前的分区情况: [iyunv@localhost]#free-m 2、增加交换分区文件及大小,如果要增加2G大小的交换分区,则命令写法如下,其中的count等于想要的块大小。
[iyunv@localhost]#dd if=/dev/zero of=/home/swap bs=1024 count=2048000 3、设置交换文件:
[iyunv@localhost]#mkswap /home/swap 4、立即启用交换分区文件
[iyunv@localhost]#swapon /home/swap 5、如果要在引导时自动启用,则编辑/etc/fstab文件,添加行: /home/swapswap swap defaults 0 0 安装信息,点击“Finish”。 安装程序结束
打开终端,切换到root帐户,执行脚本。 #/u01/app/oraInventory/orainstRoot.sh #/u01/app/oracle/product/11.2.0/dbhome_1/root.sh 点”ok”,结束安装 现在可以通过浏览器访问数据库管理后台,https://IP:1158/em 用户名:sys 密码:“Administrativepassword” 切换到oracle用户,执行以下命令:
注意:此例为orcl为列子 $echo"export ORACLE_SID=orcl">> ~/.bashrc $echo"export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin">> ~/.bashrc $echo"export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1/">> ~/.bashrc $echo"export ORACLE_BASE=/u01/app/oracle" >> ~/.bashrc
$echo"export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1">> ~/.bashrc $echo"export TNS_ADMIN=$ORACLE_HOME/network/admin" >>~/.bashrc $echo"export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin" >>~/.bashrc $echo"export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin">> ~/.bashrc $echo"export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib">> ~/.bashrc $echo"exportLD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib">> ~/.bashrc $echo"export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib64:/usr/lib64">> ~/.bashrc $echo"export ODBCINI=/etc/odbc.ini" >> ~/.bashrc
修改/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 注意:SERVICE_NAME为安装时设置的“Globaldatabase name”,此例为orcl。 PORT为数据库连接端口 配置如下: LISTENER= (DESCRIPTION_LIST= (DESCRIPTION= (ADDRESS= (PROTOCOL = IPC)(KEY = EXTPROC1522)) (CONNECT_DATA= (SERVICE_NAME=orcl)) (ADDRESS= (PROTOCOL = TCP)(HOST = localhost)(PORT= 1522)) ) ) ADR_BASE_LISTENER= /u01/app/oracle
启动关闭数据库
$sqlplus / as sysdba SQL>startup; #启动 QL>shutdownimmediate;#关闭
注:commandnot found处理 [oracle@dg1~]$ sqlplus /nolog bash:sqlplus: command not found [oracle@dg1~]$ ln -s $ORACLE_HOME/bin/sqlplus /usr/bin ln:creating symbolic link `/usr/bin/sqlplus' to `/bin/sqlplus':Permission deni ed [oracle@dg1~]$ su - root Password: [iyunv@dg1~]# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin [iyunv@dg1~]# su - oracle [oracle@dg1~]$ sqlplus /nolog SQL>conn / as sysdba Connectedto an idle instance. SQL>startup ORACLEinstance started.
启动关闭监听器
$lsnrctl start #启动 $lsnrctl stop #关闭 $lsnrctl status #查看状态 启动监听时报错
TNS-12546: TNS:permission denied 15. TNS-12560: TNS:protocol adapter error 16. TNS-00516: Permission denied 17. Linux Error: 13: Permission denied
查看下 /var/tmp/.oracle、/tmp/.oracle 这两个目录的权限访问。
更改权限为777
注(ServicesSummary... Service"itvnet" has 1 instance(s). Instance"itvnet", status READY, has 1 handler(s) for thisservice... Service"itvnetXDB" has 1 instance(s). Instance"itvnet", status READY, has 1 handler(s) for thisservice... Thecommand completed successfully)
$netstat-tan | grep 1521 #验证 注(tcp 0 0 :::1521 :::* LISTEN )
修改/etc/oratab,内容为orcl:/u01/app/oracle/product/11.2/dbhome_1:Y #chmod 755 /etc/rc.d/init.d/oracle 启动:serviceoracle start 关闭:serviceoracle stop
#chkconfig -add /etc/rc.d/init.d/oracle #chkconfig oracle on #chkconfig --list oracle oracle 0:off 1:off 2:on 3:on 4:on 5:on 6:off 脚本内容如下: #!/bin/bash #chkconfig: 2345 90 10 #oracle: Start/Stop Oracle Database 11g R2 #description: The Oracle Database is an Object-Relational DatabaseManagement System. # #processname: oracle ./etc/rc.d/init.d/functions LOCKFILE=/var/lock/subsys/oracle ORACLE_HOME=/usr/oracle/app/product/11.2.0/dbhome_1 ORACLE_USER=oracle case"$1" in 'start') if[ -f $LOCKFILE ]; then echo$0 already running. exit1 fi echo-n $"Starting Oracle Database:" su- $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start" su- $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" su- $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole" touch$LOCKFILE ;; 'stop') if[ ! -f $LOCKFILE ]; then echo$0 already stopping. exit1 fi echo-n $"Stopping Oracle Database:" su- $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop" su- $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut" su- $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole" rm-f $LOCKFILE ;; 'restart') $0stop $0start ;; 'status') if[ -f $LOCKFILE ]; then echo$0 started. else echo$0 stopped. fi ;; *) echo"Usage: $0 [start|stop|status]" exit1 esac exit0
|