远程访问数据库,远程访问Oracle数据库

下载oracle客户端,net服务名与主机的数据库相同,主机名就是主机的ip,记着没试下主机的监听程序是否打开(在命令行下远行lsnrctl start)。本机连接字符串用strConn.Format(_T("Provider=OraOLEDB.Oracle;Password=%s;User ID=%s;Data Source=%s;Persist Security Info=true;"),m_szPassword,m_szUserID,m_szDataSoure);
如有问题,可在UserID后加上server=ipaddress项。
启动监听:lsnrctl start
查看监听:lsnrctl status
停止监听:lsnrctl stop
1、oracle 数据服务器包括:实例进程和数据库;
实例进程包括:memory structure(sga)以及background process(pmon(进程监控)、smon(系统监控system monitor,空间整理3秒)、dbwr(脏数据处理)、lgwr(将redo buffer文件写会log),ckpt(checkpoint,同步数据,先写日志、脏数据)等进程);
数据库包括:数据文件、控制文件,redo log 文件,三者是必须的,至于 参数文件、密码文件、归档文件是可选的,根据数据库的状态而定;
2、pga:包括user process 和server process,user process通过server process来与oracle的实例进行进行通信。
3、sga=share pool+database buffer cache+redo log buffer + other structures(large pool,java pool可选)
shared_pool=library cache(sql共享,缓冲sql的执行计划,采用最近最少使用算法) + data dictionary cache(row cache,数据字典);
database buffer cache(db_cache_size):oracle以block size最为基本的数据读写单位
redo log buffer cache:
4、改变参数:
alter system set shared_pool_size=64m;
alter system set db_cache_size=64m;
alter system set large_pool_size=64m;
5、os验证用户:
create user id
create group (ora_dba,ora_databasename_dba,ora_oper,ora_databasename_oper)
add user id to group id
edit sqlnet.ora (sqlnet.authentication_services=(nts))
6、忘记system/sys的密码:
删掉E:\oracle\product\10.2.0\db_1\database\pwdtestdb.ora;
使用命令:orapwd file=d:\pwdtestdb.ora password=admin1 entries=10;将密码设置为admin1;
或则:
sqlplus /@testdb as sysdba
alter user sys identified by 新密码;
alter user system identified by 新密码;
7、block(块) extend(盘区) segment(段) tablespace(表空间)
8、网络服务的配置信息在D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora文件中记录
数据库的启动命令
1、启动TNS监听
C:\Documents and Settings\Administrator>lsnrctl start
2、启动Oracle Services
C:\Documents and Settings\Administrator>net start OracleServiceOrcl
3、以sysdba身份登录
SQL> connect system as sysdba
4、启动isqlplus
C:\Documents and Settings\Administrator>isqlplusctl start
5、启动database control
C:\Documents and Settings\Administrator>emctl start dbconsole
如果启动错误,很可能是ip地址进行了修改,可采取如下措施:
set oracle_hostname=主机名
emca -config dbcontrol db,进行相应的配置。
6、http://localhost:1158/em/
<打开控制台输出>
1、show all
serveroutput OFF
2、set serveroutput _disibledevent=>
带初始化参数文件的启动方式
先读取参数文件,再按参数文件中的设置启动数据库
例:startup pfile=E:\Oracle\admin\oradb\pfile\init.ora
8、startup EXCLUSIVE
============================================
有三种启动方式:
1、shutdown normal
正常方式关闭数据库。
2、shutdown immediate
立即方式关闭数据库。
在SVRMGRL中执行shutdown immediate,数据库并不立即关闭,
而是在Oracle执行某些清除工作后才关闭(终止会话、释放会话资源),
当使用shutdown不能关闭数据库时,shutdown immediate可以完成数据库关闭的操作。
3、shutdown abort
直接关闭数据库,正在访问数据库的会话会被突然终止,
如果数据库中有大量操作正在执行,这时执行shutdown abort后,重新启动数据库需要很长时间
Tags: 

延伸阅读

最新评论

发表评论