Archive for the ‘Oracle’ Category

更改oracle的监听端口

Posted on 七月 30th, 2007 in Oracle | No Comments »

参考http://www.wangwa.com/info/2006-09/32453.htm

三、修改了监听端口, 怎样保证 DB Control 正常运行
1. 修改 listener.ora 和tnsnames.ora 这两个文件:
tnsnames.ora 中需要加入:

listener_1 =
(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxx)(PORT = 新的端口))

然后启动数据库:

SQL> show parameter local_listener ;
SQL> alter system set local_listener='listener_1' scope=spfile;

重启数据库使得修改生效

2. 修改 $ORACLE_HOME\hostname_sid\sysman\config
下的emoms.properties文件:

oracle.sysman.eml.mntr.emdRepPort=新的端口
oracle.sysman.eml.mntr.emdRepConnectDescriptor =(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=xxx)(PORT\= 新的端口)))(CONNECT_DATA\=(SERVICE_NAME\=xxx)))

3. 最后,还要修改 $ORACLE_HOME\hostname_sid\sysman\emd
下的targets.xml:

4. 重新启动监听器和dbconsole 服务.

5. 如果嫌上面的操作麻烦,可以用emca这个命令行工具:
emca -h 查看所有可用的命令
emca -r 跳过资料档案库的创建.

oracle更改IP地址

Posted on 四月 15th, 2007 in Oracle | No Comments »

oracle数据库更改IP地址后,发现无法连接。需要修改一下对应的文件:
network/admin/listener.ora
network/admin/tnsnames.ora
把其中对应的IP地址进行修改后再重新启动oracle就可以解决问题了。

em中文乱码

Posted on 十二月 14th, 2006 in Linux, Oracle | 1 Comment »

在安装过程中也有乱码,不过可以使用LC_ALL=en_US ./runInstaller 来安装,但是em和isqlplus中文也都显示成方框,这个感觉比较烦。
服务器是debian testing(etch),locale是zh_CN.utf8
问题一直没有解决。在JRE 1.5下应该很好就能解决了,不过oracle自带的jre 1.4,而且好像有多个拷贝,最后也没有解决。(为何不用一个拷贝?为何不用系统的拷贝?)
参考:

http://www.linuxsir.org/bbs/showthread.php?t=98591

http://bbs.linuxunion.net/showthread.php?p=281

debian testing上安装oracle 10g

Posted on 十月 16th, 2006 in Linux, Oracle | 1 Comment »

安装10g express一直有问题,决定安装oracle 10g版本。
这个安装要比xe版复杂得多。

一、安装前的准备

1.硬件要求

Oracle建议内存为512MB或以上,至少1G交换分区,并且需要400MB的临时目录空间。
使用以下的命令查看你的内存和交换分区大小:

# grep MemTotal /proc/meminfo
# grep SwapTotal /proc/meminfo

你可以使用以下方法添加临时交换分区:

su - root
dd if=/dev/zero of=tmpswap bs=1k count=900000
chmod 600 tmpswap
mkswap tmpswap
swapon tmpswap

可以通过以下命令查看临时空间大小:

#df /tmp

可以自己新建临时目录,安装完后再删除

#su - root
#mkdir /opt/tmp
#chown root.root /opt/tmp/
# chmod 1777 /opt/tmp
# echo TEMP
# export TEMP=/opt/tmp
# export TEMPDIR=/opt/tmp

对硬盘空间大小的限制,建议预留3G空间。

2.系统参数调整

修改/etc/sysctl.conf,添加

#我的机器只有1G内存
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

执行
#/sbin/sysctl -p

设置shell限制,在/etc/security/limits.conf添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

修改login设置,修改 /etc/pam.d/login,添加
session required /lib/security/pam_limits.so

在/etc/profile中添加以下语句:

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

3、安装设置

确保你已经安装了下列软件

sudo apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio1 libstdc++5 gawk
确保你的系统中有以下组和用户,方法:

#grep dba /etc/group
#grep oinstall /etc/group
#grep nobody /etc/group

#id oracle
#id nobody

切换到root,添加oralce帐户

#su - root
#groupadd dba # group of users to be granted SYSDBA system privilege
#groupadd oinstall # group owner of Oracle files
#useradd -c "Oracle software owner" -g oinstall -G dba -d /opt/oracle oracle
#passwd oracle
输入oracle密码

debian中需要额外的添加nobody用户组:
#groupadd nobody
系统nogroup组中已经有nobody用户,把nobody用户添加到新建的nobody组中,
#usermod -G nobody nobody

建立oracle目录
#su root
#mkdir /opt/oracle
#chown -R oralce.oinstall /opt/oracle
mkdir -p /u01/app
chown -R oracle.oinstall /u01/app
debian需要额外的做以下操作:
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/rpm /bin/rpm
# ln -s /usr/bin/basename /bin/basename
# ln -s /etc /etc/rc.d

模拟redhat-3进行安装,新建一个文件/etc/redhat-release,写入以下内容:
Red Hat Enterprise Linux AS release 3 (Taroon)

二、开始安装

你可以从http://mirrors.cn99.com上下载oracle 10g,按以下方法进行解压:
su - oracle
wget http://mirrors.cn99.com/oracle/10g/10201_database_linux32.zip
unzip 10210_database_linux32.zip
若是远程连接到服务器,则需要这样操作:
ssh -X oracle@your_server_ip
export ORACLE_BASE=/u01/app
export ORACLE_SID=orcl #你可以自己命名sid
#确保此时环境中没有ORACLE_HOME 和TNS_ADMIN
$ unset ORACLE_HOME
$ unset TNS_ADMIN

可以将这些写进.bash_profile
export ORACLE_BASE=/opt/oracle
export ORACLE_SID=oralin
unset ORACLE_HOME
unset TNS_ADMIN

umask 022

执行
cd database
LC_ALL=en_US ./runInstaller

三、安装后

oracle启动脚本/etc/init.d/oracle

su
nano /etc/init.d/oracle

#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface

export ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/db_1/
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin

ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c $ORACLE_HOME/bin/dbstart
touch /var/lock/oracle

su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
su $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl start"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctl stop"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/oracle

echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0

chmod 755 /etc/init.d/oracledb
update-rc.d oracledb defaults 99

可以通过/etc/init.d/oracle start来启动oracle.

参考:
1 http://sysop.com.cn/system5504,1.html
2 https://help.ubuntu.com/community/Oracle10g
3 http://mirrors.cn99.com/oracle/10g/

修改oracle 10g的字符集

Posted on 十月 16th, 2006 in Oracle | 2 Comments »

修改数据库字符集为:ZHS16GBK
查看服务器端字符集
SQL > select * from V$NLS_PARAMETERS
修改:
$sqlplus /nolog
SQL>conn / as sysdba;
若此时数据库服务器已启动,则先执行 SHUTDOWN IMMEDIATE 命
令关闭数据库服务器,然后执行以下命令:
SQL>shutdown immediate;
SQL>STARTUP MOUNT;
SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL>ALTER DATABASE OPEN;
SQL>ALTER DATABASE CHARACTER SET ZHS16GBK;
*
ERROR at line 1:
ORA-12721: operation cannot execute when other sessions are active
若出现上面的错误,使用下面的办法进行修改,使用INTERNAL_USE可以跳过超集的检查:
SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK;
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP

emctl无法启动

Posted on 十月 11th, 2006 in Oracle | No Comments »

安装完以后,emctl无法启动,试验了多种办法也未解决,最后才发现是hostname的问题。
这台机器的hostname和hosts名称不一样,导致出现怪异的问题。
修改/etc/hostname,/etc/hosts,使二者一致。
修改$ORACLE_HOME/sysman/config/emd.properties,修正其中和hostname相关的部分。
修正network/admin/*.ora文件,注意hostname和port。(我用了1521 port)
重建数据库:
emca -config dbcontrol db -repos recreate

dbstart无法启动

Posted on 十月 10th, 2006 in Linux, Oracle | No Comments »

安装完成后一直有问题,
su oracle
dbstart
提示:
"Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr"
解决办法:

To solve this problem please follow the steps.

Step 1 Edit $ORACLE_HOME/bin/dbstart
Step 2 Goto line 78
Step 3 Replace the line with
ORACLE_HOME_LISTNER=$ORACLE_HOME
Step 4 Save and exit the editor.
Step 5 Now reexecute the dbstart

见:http://forums.oracle.com/forums/thread.jspa?messageID=1094708􋐴

在debian上安装oracle 10g express

Posted on 十月 2nd, 2006 in Linux, Oracle | No Comments »

若是要安装oracle10G,可能要麻烦些,但若是安装oracle 10g express的话,那就很简单:
1、修改/etc/apt/source.list,添加oracle的源:
deb http://oss.oracle.com/debian unstable main non-free
2、进行更新和安装
aptitude update
aptitude install oracle-xe-universal
3、进行初始的密码设置
/etc/init.d/oracle-xe configure
若服务器无GUI,可以这样远程管理
ssh -L 8080:localhost:8080 user@IP_of_your_server
firefox http://localhost:8080/apex/

参考:

https://help.ubuntu.com/community/Oracle10g