Recently in database Category
/var/lib/pgsql/data/pg_hba.conf
host all all 172.16.1.0/24 md5
2.logon postgresql
su - postgres
$psql
or $psql -U postgres -h 127.0.0.1
postgres=# create user "2hei" with password 'pwd' nocreatedb;
postgres=# create database "test_db" with owner="2hei";
\lu
\q
3.test link
linux:
psql -U 2hei -h 172.16.1.100
windows
D:/soft/postgresql9/bin/psql.exe -h 172.16.1.100 -U 2hei -d test_db -p 5432 -c "\l"
4.set sys env (linux/windows)
PGPASSWORD
hostname:port:database:username:password
5copy without pwd:
D:\soft\postgresql9\bin\psql.exe -h localhost -U 2hei -d test_db -p 5432 -c "COPY test_tb(name,desc,comm1,comm2) FROM 'D:/upload.txt' WITH DELIMITER ',' NULL AS '' csv;"
cat upload.txt
1,2,3,4
2,3,4,5
------------
Oracle 9.0.1 supports:
* JDBC 2.0 Extensions except for: using both global and local transactions on the same connection.
Oracle 9.2.0 supports:
* Partial support for JDBC 3.0: transaction savepoints
* using both global and local transactions on the same connection.
Oracle 10.1.0 supports:
* Full support for JDBC 3.0 except for: retrieving auto-generated keys
* result-set holdability
* returning multiple result-sets.
Oracle 10.2.0 supports:
Full support for JDBC 3.0
* Note that there is no real change in the support for the following in the database. All that has changed is that some methods that previously threw SQLException now do something more reasonable instead. result-set holdability
* returning multiple result-sets.
Oracle 11.1.0 supports:
Full support for JDBC 3.0 in the JDK 1.5 drivers.
Full support for JDBC 4.0 in the JDK 1.6 drivers with the exception of SQLXML which is not supported
详细见:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#02_04
生活就是在折腾来折腾去,最后也没弄清楚到底在折腾啥,完事后对这镜子哈哈大笑,至少我还折腾过!
废话少说,步入正题。
好久没有装过oracle9了,以往的笔记都是在rhel4下面使用vnc来操作的。
据说oracle9i也可以在字符界面下安装,
./runInstaller –silent –responseFile /opt/oracle/product/responfile
responfile是参数文件,oracle在安装时读取相关参数。
不过有人说oracle9i不能完全自动安装,还需要手动指定一些参数和执行相关脚本,这个具体没有试过,所以还是想到了以往的经验使用vnc来安装。
#uname -a
Linux 2.4.25 #2 SMP Wed Apr 28 13:10:52 CST 2004 i686 i686 i386 GNU/Linux
系统版本 redhat9,很老的版本
使用 rpm -qa | grep vnc 查看后并没有安装vnc。
redhat9从2004年就不更新了,好些包都已经不好找,还好我们可以使用CentOS3的安装包。
理由有下面两点:
1、rhel 3 与redhat 9 最后更新后的软件版本绝大部分相同
2、CentOS 3是从Redhat Enterprise Linux 3源代码重新编译的,与rhel 3完全兼容。
http://isoredirect.centos.org/centos/3/os/i386/RedHat/RPMS/
下面有好多rpm包,可以尽情享用了。
有些郁闷的是在安装vnc的时候发现系统也没有安装Xwindows,导致vnc无法运行,原因是相互依赖的很多包都没有,哎,开始郁闷了。
经过多次的尝试和努力,一个包一个包的下载和安装,如下:
rpm -ivh vnc-3.3.3r2-47.i386.rpm
rpm -ivh vnc-server-3.3.3r2-47.i386.rpm
rpm -ivh XFree86-xauth-4.3.0-122.EL.i386.rpm
rpm -ivh xterm-179-6.EL3.i386.rpm
rpm -ivh XFree86-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-75dpi-fonts-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-twm-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-data-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-data-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-data-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-data-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-twm-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-libs-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-twm-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-100dpi-fonts-4.3.0-122.EL.i386.rpm
rpm -ivh XFree86-base-fonts-4.3.0-122.EL.i386.rpm
呵呵,你说我容易吗,最后终于我的vnc可以运行了
vncserver已经可以监听端口和配置登陆密码了!
赶快切到oracle用户,启动vnc,

客户端vnc登陆后,
在解开的Disk1下,运行./runInstaller,呵呵呵,久违的oracle GUI安装界面映入眼帘,(具体9204的补丁及安装设置略,请见相关文档)
一路安装下去颇为顺利,很快装完。
最后要感谢铁岭电视台、感谢cctv、也要感谢提供软件的centos ...
[Wed Nov 12 14:15:38 CST 2008][MysqlDb.connectDB]java.sql.SQLException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
搜了一下,好多人遇到此问题,大致是mysql版本不通造成的,以下是解决办法:
mysql>UPDATE mysql.user SET Password = OLD_PASSWORD('yourpass') WHERE Host = 'localhost' AND User = 'username';
mysql>FLUSH PRIVILEGES;
这里是mysql官方的解释!
http://dev.mysql.com/doc/refman/5.0/en/old-client.html
i meet a problem:
[MysqlDb.connectDB]java.sql.SQLException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
this is a problem of mysql update version 4.1 and more!
to sovle it , we can do this
1st:
mysql> SET PASSWORD FOR
-> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
2nd:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
-> WHERE Host = 'some_host' AND User = 'some_user';
mysql> FLUSH PRIVILEGES;
以前也一直在用sqlldr进行oracle的数据导入工作,但由于数据表结构比较简单,数据格式比较规范,所以简单的脚本即可完成任务,没有仔细的进行研究。
最近因为项目需要,要处理一个稍微复杂一点的表,涉及到日期字段,还有自增序列,字段比较复杂不规则,有很多空列,经过一番研究后,终于搞定,特此总结一下。
1. 空字段处理: TRAILING NULLCOLS 但是整行不能全空,否则整行无法插入
2. 日期字段处理:格式化处理 AddDate "to_date(:AddDate,'''yyyy-mm-dd hh24:mi:ss''')"
3. 自定义字段分割符 “|”
4. 采用触发器来处理自增字段,具体的建立方法可参考我的另一篇关于触发器的介绍带有条件的触发器trigger
ldr脚本如下:
vi sql.ctl
LOAD DATA
INFILE '/home/oracle/data/table.data'
APPEND INTO TABLE table
fields terminated by '|'
TRAILING NULLCOLS
(
ID,
USERNAME,
PASSWORD,
AddDate "to_date(:AddDate,'''yyyy-mm-dd hh24:mi:ss''')"
)
数据文件样式 table.data
|test|test|2008-03-20 18:09:10
|2hei|2hei|2008-03-20 18:09:10
|admin|admin|2008-03-20 18:09:10
loader 脚本运行方式:
切换到oracle用户 su - oracle
或者root下执行 su -l oracle -c "sqlldr userid=2hei/2hei control=/home/oracle/data/sql.ctl log=/home/oracle/log/sql.log bad=/home/oracle/log/bad.log"
执行后可以查表,看看字段的插入情况。
如果有问题可以看执行后的log 或者 bad文件。
proxool 介绍请看:
http://proxool.sourceforge.net/
you can download here!
http://proxool.sourceforge.net/download.html
我的hibernate采用properties方式配置,下面介绍我做的两种配置:
========================
配置一:使用proxool.properties
设置proxool的监控servlet
web.xml
<servlet>
<servlet-name>ServletConfigurator</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
<init-param>
<param-name>propertyFile</param-name>
<param-value>WEB-INF/classes/Proxool.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Admins</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Admins</servlet-name>
<url-pattern>/Admins</url-pattern>
</servlet-mapping>
2.hibernate.properties
使用 proxool.properties 配置:
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
connection.useUnicode=true
connection.characterEncoding=UTF-8
hibernate.show_sql=false
hibernate.connection.provider_class=org.hibernate.connection.ProxoolConnectionProvider
hibernate.proxool.pool_alias DBPool
hibernate.proxool.properties proxool.properties
proxool.properties
jdbc-1.proxool.alias=DBPool
jdbc-1.proxool.driver-class=oracle.jdbc.driver.OracleDriver
jdbc-1.proxool.driver-url=jdbc:oracle:thin:@172.10.0.111:1521:2hei
jdbc-1.user=2hei
jdbc-1.password=2hei.net
jdbc-1.proxool.maximum-connection-count=20
jdbc-1.proxool.prototype-count=4
jdbc-1.proxool.house-keeping-test-sql=select sysdate from DUAL
jdbc-1.proxool.verbose=true
jdbc-1.proxool.statistics=10s,1m,1d
jdbc-1.proxool.statistics-log-level=ERROR
配置二:使用proxool.xml
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory
connection.useUnicode=true
connection.characterEncoding=UTF-8
hibernate.show_sql=false
hibernate.connection.provider_class=org.hibernate.connection.ProxoolConnectionProvider
hibernate.proxool.pool_alias DBPool
hibernate.proxool.xmlproxool.xml ### 与配置的区别
vi classes/proxool.xml
<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
<proxool>
<alias>DBPool</alias>
<driver-url>jdbc:oracle:thin:@172.10.0.111:1521:2hei</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="2hei"/>
<property name="password" value="2hei.net"/>
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<maximum-new-connections>20</maximum-new-connections>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
<house-keeping-test-sql>select sysdate from dual</house-keeping-test-sql>
</proxool>
</something-else-entirely>
下面是监控记录:
看到active connection 数量始终为0,以为自己的配置有些问题,
后来采用了压力测试软件,施加点压力(50*10),感觉连接池对数据的压力还是比较敏感,
管理界面显示当available connection 达到最大值后,不会立即消失,而是保持一段时间,
此时的连接数保持较大的数量也应该对服务器不会产生坏影响。
问题总是会有的,有时候解决问题也是一种乐趣,而处理问题的关键是“不抛弃、不放弃”。
症状:
FC6( kernel 2.6.18-1)上安装的Oracle10g
修改了IP地址,从原来的192.168.1.* 到 172.16.0.*
系统重启后,发现oracle监听无法启动。
提示:
ORA-00600: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]
oracle数据库也无法启动,提示数据库无法连接。
看似很简单的问题,以下是曲折的问题解决过程:
googleing : keywords: ORA-00600: internal error code, arguments:
翻了一通,说是什么头晕眼花,没有收获。
查询oracle的监听(listener.ora)配置。
# listener.ora Network Configuration File: /opt/oracle/product/10g/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10g)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
发现没有任何改动。
里面只有host配置,并没有具体指定某个IP。
重新修改网卡的IP地址:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# nVidia Corporation MCP61 Ethernet
DEVICE=eth0
HWADDR=10:c0:f8:b9:1c:30
IPADDR=172.16.0.252
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=172.16.0.1
TYPE=Ethernet
Reboot Server 。。。
一分钟过后,oralce监听仍然无法启动。
#setup
直接配置网卡的设置
这里出现了错误,修改完ip后,无法save 只有quit。
提示如下:
出现一个未解决的异常。这极可能是一个程序错误,请将其崩溃组合码转储入一个文件,
然后在 https://bugzilla.redhat.com/bugzilla 提交一份关于 system-config-network 的详细错误报告。
Component: system-config-network
Version: 1.3.95
Summary: TB /usr/lib/python2.4/sre.py:227:_compile:error: multiple repeat
Traceback (most recent call last):
File "/usr/sbin/system-config-network-tui", line 277, in ?
plist.save()
File "/usr/share/system-config-network/netconfpkg/NCProfileList.py", line 394, in save
del hoconf[i]
File "/usr/lib/python2.4/site-packages/rhpl/Conf.py", line 581, in __delitem__
while self.findnextline('^\S*[' + self.separators + ']+' + varname):
File "/usr/lib/python2.4/site-packages/rhpl/Conf.py", line 198, in findnextline
elif re.search(regexp, self.lines[self.line]):
File "/usr/lib/python2.4/sre.py", line 134, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python2.4/sre.py", line 227, in _compile
raise error, v # invalid expression
error: multiple repeat
> /usr/lib/python2.4/sre.py(227)_compile()
-> raise error, v # invalid expression
(Pdb)
googleing 。。。。。。。。。。。
未果。
郁闷中。难道让我重装oracle?
虽然作为一台测试服务器,重装oracle也是一件比较让人不爽的事情啊。
接着google。。。。。。 keywords: erverything (先看了会娱乐八卦再说。)
无果。。。
我无语了。。。
半小时后。
偶然发现Linux下面的提示如下:
[root@bogon]#
这个bogon是什么东东哩?
是不是中毒了,这台机器的防范可是超级薄弱啊,所有口令都是12345678,哈哈
赶紧看/var/log
看了一遍所有日志,和配置等等,没有发现异常。
使用了chkrootkit http://www.chkrootkit.org下载 chkrootkit.tar.gz 最新版本 chkrootkit-0.48
./chkrootkit > result.txt
vi result.txt
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... not infected
Checking `cron'... not infected
Checking `crontab'... not infected
Checking `date'... not infected
Checking `du'... not infected
Checking `dirname'... not infected
Checking `echo'... not infected
Checking `egrep'... not infected
Checking `env'... not infected
...
Searching for suspect PHP files... nothing found
Searching for anomalies in shell history files... nothing found
Checking `asp'... not infected
Checking `bindshell'... not infected
Checking `lkm'... chkproc: nothing detected
chkdirs: nothing detected
Checking `rexedcs'... not found
Checking `sniffer'... eth0: not promisc and no PF_PACKET sockets
Checking `w55808'... not infected
Checking `wted'... chkwtmp: nothing deleted
Checking `scalper'... not infected
Checking `slapper'... not infected
Checking `z2'... chklastlog: nothing deleted
Checking `chkutmp'... chkutmp: nothing deleted
没有发现异常。
#hostname
bogon
继续google... keywords: hostname bogon
解释说可能是内网防火墙所致,跟IP段或许有关系。
bogon是指那些不该出现在internet路由表中的地址
这些地址应该包括:
1,私有地址如10,172.16-32,192.168.....
2,还未正式分配出去的地址
Bogons are prefixes that should never appear in the Internet routing table, and obviously should not appear as the source address in any packets you receive.
联系起来最近的操作,恰恰证实了这一点。
昨天刚刚把ISA2004架设好,内网网段从192.168.1.0/24 改到了 172.16.0.1/24
但是究竟是什么修改了Linux的hostname了呢?
先不管他,修改hostname,改为原来的hostname。
#hostname localhost.localdomain
vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
172.16.0.252 localhost.localdomain localhost
#reboot
系统重启后提示变为:[root@localhost]
#hostname
localhost.localdomain
正常了,跟oracle中监听的配置一致。
切换到oracle用户。
[oracle@localhost admin]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 04-MAR-2008 13:40:44
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10g/network/admin/listener.ora
Log messages written to /opt/oracle/product/10g/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 04-MAR-2008 13:40:44
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/10g/network/admin/listener.ora
Listener Log File /opt/oracle/product/10g/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
启动数据库。
[oracle@localhost admin]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 4 13:40:57 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 88082000 bytes
Database Buffers 192937984 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
oracle启动正常。
总结:
如果您的oracle有这样的错误
ORA-00600: internal error code, arguments:
先看看是不是hostname被修改了??
从oracle9i 中导出的数据导入到oracle 10g中,经过程序的调用后,发现都是乱码,
开始以为是RHEL5系统字符集的事情,修改了几次后,发觉还是数据库的字符集有问题。
以下是用dba进入后查看拿的实际情况:
select * from V$NLS_PARAMETERS ;
NLS_LANGUAGE SIMPLIFIED CHINESE
NLS_TERRITORY CHINA
NLS_CURRENCY RMB
NLS_ISO_CURRENCY CHINA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE SIMPLIFIED CHINESE
NLS_CHARACTERSET WE8ISO8859P1
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY RMB
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
select userenv('language') from dual;
SIMPLIFIED CHINESE_CHINA.WE8ISO8859P1
select * from sys.props$ WHERE NAME='NLS_CHARACTERSET';
-----------------------
参考了网上的几个解决方法,都没有解决,最后还是使用了这样的方法解决了问题:
UPDATE sys.PROPS$ SET value$='ZHS16GBK' WHERE NAME='NLS_CHARACTERSET';
这样把WE8ISO8859P1改变成'ZHS16GBK' 。
但是原来已经导入的数据都需要重新导入。
*******需要说明的是 上面的这种方法有些问题,尽量不要使用这种方法
下面是正确的修改字符集的方法:
sqlplus "/as sydba"
shutdown immediate
Startup restrict
ALTER DATABASE CHARACTER SET ZHS16GBK;
有时候会遇到如下错误:
ORA-12712: new character set must be a superset of old character set
可以执行如下: 跳过超集的检查
ALTER DATABASE character set INTERNAL_USE zhs16gbk;
然后重启数据库即可,不过最好先做备份哦!




