windows server 2008 r2 64位中,Index service问题

touda2 2011-11-09 02:51:39
使用的64位的windows server 2008 r2
在index service服务中设置了“C:\inetpub\wwwroot”的索引,使用了其它的测试程序测试过了,是成功的。


下面是对index service服务的测试程序的asp文件的代码。

<html>
<head>
<title>Index Server Demo</title>
</head>
<body>
<form method="POST" action="">
search:
<input type="text" name="txtQuery" size="16">
<input type="submit" value="yes">
<% If Request("txtQuery") <> "" Then
Dim objQuery
Dim rsQuerySet
objQuery = Server.CreateObject("ixsso.Query")'<===这块出错,提示错误是active X控件不能创建对象,这个对象的提供是ixsso.dll文件提供的,网上有说可能是dll文件的兼容性问题
objQuery.Query = Request("txtQuery")
objQuery.Columns="filename,vpath,DocTitle"
objQuery.Catalog = "C:\inetpub\wwwroot"
objQuery.MaxRecords = 50
Set rsQuery = objQuery.CreateRecordset("nonsequential")
If rsQuery.EOF Then %>
<font color="#FF0000">no</font>
<%
Else
%>
<table>
<% Do While Not rsQuery.EOF
If rsQuery("doctitle") <> "" Then
%>
<tr>
<td>
<a href="<% = rsQuery("vpath") %>">
<% = rsQuery("doctitle") %></a>
</td>
</tr>
<%
else
Response.Write "sucuess!!!"
End If

rsQuery.MoveNext
Loop
Response.Write "</table>"
End If
End If
%>
</form>
</body>
</html>
在网上找了一下,说是64位win 2008 中的ixsso.dll文件的兼容问题,我也查看了一下windows server2003的ixsso.dll文件和08系统的有差别,希望大家能提出解决方法。请使用asp代码修改可以使用其他方法,但必须是asp的不是.net的,希望大家能帮帮忙。
...全文
297 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lishichao1989 2012-01-10
  • 打赏
  • 举报
回复
请问那个datasource=web的web怎么配置?
[Quote=引用 5 楼 shadowlaser 的回复:]

本来希望高手能解决的,看来高手都躲起来。
问题已经解决了,解决方案如下:
在调查了问题后发现是ixsso.Query对象在windows server 2008 R2 x64 中执行会出错,进行ixsso.dll 32位版重新注册也是不成功的,在IIS7中一直使用application开启了32位模式,否
则整个asp网站都不能运行。
下面是替换的等价核心代码:
dim strsear……
[/Quote]
touda2 2011-11-10
  • 打赏
  • 举报
回复
本来希望高手能解决的,看来高手都躲起来。
问题已经解决了,解决方案如下:
在调查了问题后发现是ixsso.Query对象在windows server 2008 R2 x64 中执行会出错,进行ixsso.dll 32位版重新注册也是不成功的,在IIS7中一直使用application开启了32位模式,否
则整个asp网站都不能运行。
下面是替换的等价核心代码:
dim strsearch
set rssearch = server.createobject("adodb.recordset")
strconn = "provider=msidxs;datasource=web"
strsearch = "select doctitle, path, filename, characterization, size,write from scope() where contains ('" & SearchWord & "')"
rssearch.open strsearch,strconn
touda2 2011-11-09
  • 打赏
  • 举报
回复
什么权限,是IIS的吗,还是其它的,具体怎么解决呢?
[Quote=引用 2 楼 fmjwn 的回复:]
权限问题。
[/Quote]
touda2 2011-11-09
  • 打赏
  • 举报
回复
自己注册,重新注册过,没有用
[Quote=引用 1 楼 hefeng_aspnet 的回复:]
regsvr32 ixsso.dll注册组件

看看是不是环境问题
[/Quote]
fmjwn 2011-11-09
  • 打赏
  • 举报
回复
权限问题。
csdn_aspnet 2011-11-09
  • 打赏
  • 举报
回复
regsvr32 ixsso.dll注册组件

看看是不是环境问题
软件运行环境: 操作系统:windows server 2008R2 企业版64位或以上版本 数据库:Microsoft SQL Server 2008 .NET:4.0 部署文件安装注意事项: 1.网站文件加要添加上传权限,添加NETWORK SERVICE和IIS_IUSRS,设置完全控制。 1.应用程序池设置兼容32位应用程序,设置经典模式。 2.数据库连接配置正确 3.DB.config主域配置一定要正确,否则学员无法登录,例如网址是k12.weisha100.net,add nane哪里就填weisha100.net,如果是用ip访问,主域哪里填ip。不用带端口。 数据库脚本执行注意事项: 1.新建的数据库名称要和脚本里的名称保持一致。(或者修改脚本里的名称。只要保持一致即可) 2.数据库要允许server身份登录。 3.如果使用sa登录,要启用sa用户。 详细的安装教程可登录 www.weisha100.net注册观看详细的视频教程。 网站初始管理信息: 管理员入口:网址/admin/index.ashx 账户:song 密码:1 学员入口:网址/student/index.ashx 账户:13223040250 密码:1 同教师账户 (学员和教师管理员后台可以添加初始账户可以删除) 超管入口:网址/manage/index.aspx 账户:admin 密码:1 (超管主要负责资金及第三方相关接口,不要随意配置里面得权限及管理员分组) 操作手册下载地址:http://vido.weisha100.net/使用手册.rar 源码下载地址:GitHub开源地址:https://github.com/weishakeji/LearningSystem 技术支持:1558453748 电话:15660957178
K12在线教育平台|pc+手机|视频点播+在线题库+模拟考试+在线考试|源码 源码描述: 一、主要功能 首先k12小学教育平台是一个集学、练、考于一体的在线教育平台,可以帮助小学教育机构建设网络课堂,用于同步课程、专题课堂、兴趣课堂等网络教育的课堂建设。 学员可以通过手机或者电脑登录网站随时随地学习平台课程,学习内容包括:视频点播、在线题库、模拟考试、在线考试四大模块。 点播模块:平台可以制作微课视频系列,学员可以自己在家通过看老师提前制作好的视频进行学习。 题库模块:试题可以和视频关联,每个视频都可以设置几道小题,学员看完视频后可以做相关练习题。 模拟考试:每个课程可以发布一些单元试卷,模拟试卷供学员平时自主练习,教师后台可以查看学员的成绩。 在线考试:平台可以定时组织一次水平测试,对学员的整体成绩情况进行考核。正式考试与模拟考试不同,每个学员只能考一次,客观题系统自动阅卷,主观题教师后台人工阅卷。 支付模块,系统集成了支付宝支付微信支付,学员可以自己充值购买自己需要的课程。 营销模块,系统自带三级分销功能,学员登录后转发任意链接分享到朋友圈,每个学员都有一个唯一的ID,通过转发链接注册的用户自动关联上级,下级用户消费,平台可以设置给以一定的佣金分润。 团购课程:管理员可以在后台设置学习卡,每张学习卡可以管理多个课程,针对一次购买多个课程的学员可以直接销售学习卡,学员登录后使用学习卡充值,可以自动批量开通关联课程。 三、注意事项 软件运行环境: 操作系统:windows server 2008R2 企业版64位或以上版本 数据库:Microsoft SQL Server 2008 , .NET:4.0 部署文件安装注意事项: 1.网站文件加要添加上传权限,添加NETWORK SERVICE和IIS_IUSRS,设置完全控制。 1.应用程序池设置兼容32位应用程序,设置经典模式。 2.数据库连接配置正确 3.DB.config主域配置一定要正确,否则学员无法登录,例如网址是k12.weisha100.net,add nane哪里就填weisha100.net,如果是用ip访问,主域哪里填ip。不用带端口。 数据库脚本执行注意事项: 1.新建的数据库名称要和脚本里的名称保持一致。(或者修改脚本里的名称。只要保持一致即可) 2.数据库要允许server身份登录。 3.如果使用sa登录,要启用sa用户。 详细的安装教程可登录 www.weisha100.net注册观看详细的视频教程。 网站初始管理信息: 管理员入口:网址/admin/index.ashx 账户:song 密码:1 学员入口:网址/student/index.ashx 账户:13223040250 密码:1 同教师账户 (学员和教师管理员后台可以添加初始账户可以删除) 超管入口:网址/manage/index.aspx 账户:admin 密码:1 (超管主要负责资金及第三方相关接口,不要随意配置里面得权限及管理员分组) 操作手册下载地址:http://vido.weisha100.net/%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C.rar
Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 This document contains the solutions to review questions and problems for the 5th edition of Computer Networking: A Top-Down Approach by Jim Kurose and Keith Ross. These solutions are being made available to instructors ONLY. Please do NOT copy or distribute this document to others (even other instructors). Please do not post any solutions on a publicly-available Web site. We’ll be happy to provide a copy (up-to-date) of this solution manual ourselves to anyone who asks. Acknowledgments: Over the years, several students and colleagues have helped us prepare this solutions manual. Special thanks goes to HongGang Zhang, Rakesh Kumar, Prithula Dhungel, and Vijay Annapureddy. Also thanks to all the readers who have made suggestions and corrected errors. All material © copyright 1996-2012 by J.F. Kurose and K.W. Ross. All rights reserved Chapter 1 Review Questions There is no difference. Throughout this text, the words “host” and “end system” are used interchangeably. End systems include PCs, workstations, Web servers, mail servers, PDAs, Internet-connected game consoles, etc. From Wikipedia: Diplomatic protocol is commonly described as a set of international courtesy rules. These well-established and time-honored rules have made it easier for nations and people to live and work together. Part of protocol has always been the acknowledgment of the hierarchical standing of all present. Protocol rules are based on the principles of civility. Standards are important for protocols so that people can create networking systems and products that interoperate. 1. Dial-up modem over telephone line: home; 2. DSL over telephone line: home or small office; 3. Cable to HFC: home; 4. 100 Mbps switched Ethernet: enterprise; 5. Wifi (802.11): home and enterprise: 6. 3G and 4G: wide-area wireless. HFC bandwidth is shared among the users. On the downstream channel, all packets emanate from a single source, namely, the head end. Thus, there are no collisions in the downstream channel. In most American cities, the current possibilities include: dial-up; DSL; cable modem; fiber-to-the-home. 7. Ethernet LANs have transmission rates of 10 Mbps, 100 Mbps, 1 Gbps and 10 Gbps. 8. Today, Ethernet most commonly runs over twisted-pair copper wire. It also can run over fibers optic links. 9. Dial up modems: up to 56 Kbps, bandwidth is dedicated; ADSL: up to 24 Mbps downstream and 2.5 Mbps upstream, bandwidth is dedicated; HFC, rates up to 42.8 Mbps and upstream rates of up to 30.7 Mbps, bandwidth is shared. FTTH: 2-10Mbps upload; 10-20 Mbps download; bandwidth is not shared. 10. There are two popular wireless Internet access technologies today: Wifi (802.11) In a wireless LAN, wireless users transmit/receive packets to/from an base station (i.e., wireless access point) within a radius of few tens of meters. The base station is typically connected to the wired Internet and thus serves to connect wireless users to the wired network. 3G and 4G wide-area wireless access networks. In these systems, packets are transmitted over the same wireless infrastructure used for cellular telephony, with the base station thus being managed by a telecommunications provider. This provides wireless access to users within a radius of tens of kilometers of the base station. 11. At time t0 the sending host begins to transmit. At time t1 = L/R1, the sending host completes transmission and the entire packet is received at the router (no propagation delay). Because the router has the entire packet at time t1, it can begin to transmit the packet to the receiving host at time t1. At time t2 = t1 + L/R2, the router completes transmission and the entire packet is received at the receiving host (again, no propagation delay). Thus, the end-to-end delay is L/R1 + L/R2. 12. A circuit-switched network can guarantee a certain amount of end-to-end bandwidth for the duration of a call. Most packet-switched networks today (including the Internet) cannot make any end-to-end guarantees for bandwidth. FDM requires sophisticated analog hardware to shift signal into appropriate frequency bands. 13. a) 2 users can be supported because each user requires half of the link bandwidth. b) Since each user requires 1Mbps when transmitting, if two or fewer users transmit simultaneously, a maximum of 2Mbps will be required. Since the available bandwidth of the shared link is 2Mbps, there will be no queuing delay before the link. Whereas, if three users transmit simultaneously, the bandwidth required will be 3Mbps which is more than the available bandwidth of the shared link. In this case, there will be queuing delay before the link. c) Probability that a given user is transmitting = 0.2 d) Probability that all three users are transmitting simultaneously = = (0.2)3 = 0.008. Since the queue grows when all the users are transmitting, the fraction of time during which the queue grows (which is equal to the probability that all three users are transmitting simultaneously) is 0.008. 14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying the traffic. By peering with each other directly, the two ISPs can reduce their payments to their provider ISPs. An Internet Exchange Points (IXP) (typically in a standalone building with its own switches) is a meeting point where multiple ISPs can connect and/or peer together. An ISP earns its money by charging each of the the ISPs that connect to the IXP a relatively small fee, which may depend on the amount of traffic sent to or received from the IXP. 15. Google's private network connects together all its data centers, big and small. Traffic between the Google data centers passes over its private network rather than over the public Internet. Many of these data centers are located in, or close to, lower tier ISPs. Therefore, when Google delivers content to a user, it often can bypass higher tier ISPs. What motivates content providers to create these networks? First, the content provider has more control over the user experience, since it has to use few intermediary ISPs. Second, it can save money by sending less traffic into provider networks. Third, if ISPs decide to charge more money to highly profitable content providers (in countries where net neutrality doesn't apply), the content providers can avoid these extra payments. 16. The delay components are processing delays, transmission delays, propagation delays, and queuing delays. All of these delays are fixed, except for the queuing delays, which are variable. 17. a) 1000 km, 1 Mbps, 100 bytes b) 100 km, 1 Mbps, 100 bytes 18. 10msec; d/s; no; no 19. a) 500 kbps b) 64 seconds c) 100kbps; 320 seconds 20. End system A breaks the large file into chunks. It adds header to each chunk, thereby generating multiple packets from the file. The header in each packet includes the IP address of the destination (end system B). The packet switch uses the destination IP address in the packet to determine the outgoing link. Asking which road to take is analogous to a packet asking which outgoing link it should be forwarded on, given the packet’s destination address. 21. The maximum emission rate is 500 packets/sec and the maximum transmission rate is 350 packets/sec. The corresponding traffic intensity is 500/350 =1.43 > 1. Loss will eventually occur for each experiment; but the time when loss first occurs will be different from one experiment to the next due to the randomness in the emission process. 22. Five generic tasks are error control, flow control, segmentation and reassembly, multiplexing, and connection setup. Yes, these tasks can be duplicated at different layers. For example, error control is often provided at more than one layer. 23. The five layers in the Internet protocol stack are – from top to bottom – the application layer, the transport layer, the network layer, the link layer, and the physical layer. The principal responsibilities are outlined in Section 1.5.1. 24. Application-layer message: data which an application wants to send and passed onto the transport layer; transport-layer segment: generated by the transport layer and encapsulates application-layer message with transport layer header; network-layer datagram: encapsulates transport-layer segment with a network-layer header; link-layer frame: encapsulates network-layer datagram with a link-layer header. 25. Routers process network, link and physical layers (layers 1 through 3). (This is a little bit of a white lie, as modern routers sometimes act as firewalls or caching components, and process Transport layer as well.) Link layer switches process link and physical layers (layers 1 through2). Hosts process all five layers. 26. a) Virus Requires some form of human interaction to spread. Classic example: E-mail viruses. b) Worms No user replication needed. Worm in infected host scans IP addresses and port numbers, looking for vulnerable processes to infect. 27. Creation of a botnet requires an attacker to find vulnerability in some application or system (e.g. exploiting the buffer overflow vulnerability that might exist in an application). After finding the vulnerability, the attacker needs to scan for hosts that are vulnerable. The target is basically to compromise a series of systems by exploiting that particular vulnerability. Any system that is part of the botnet can automatically scan its environment and propagate by exploiting the vulnerability. An important property of such botnets is that the originator of the botnet can remotely control and issue commands to all the nodes in the botnet. Hence, it becomes possible for the attacker to issue a command to all the nodes, that target a single node (for example, all nodes in the botnet might be commanded by the attacker to send a TCP SYN message to the target, which might result in a TCP SYN flood attack at the target). 28. Trudy can pretend to be Bob to Alice (and vice-versa) and partially or completely modify the message(s) being sent from Bob to Alice. For example, she can easily change the phrase “Alice, I owe you $1000” to “Alice, I owe you $10,000”. Furthermore, Trudy can even drop the packets that are being sent by Bob to Alice (and vise-versa), even if the packets from Bob to Alice are encrypted. Chapter 1 Problems Problem 1 There is no single right answer to this question. Many protocols would do the trick. Here's a simple answer below: Messages from ATM machine to Server Msg name purpose -------- ------- HELO Let server know that there is a card in the ATM machine ATM card transmits user ID to Server PASSWD User enters PIN, which is sent to server BALANCE User requests balance WITHDRAWL User asks to withdraw money BYE user all done Messages from Server to ATM machine (display) Msg name purpose -------- ------- PASSWD Ask user for PIN (password) OK last requested operation (PASSWD, WITHDRAWL) OK ERR last requested operation (PASSWD, WITHDRAWL) in ERROR AMOUNT sent in response to BALANCE request BYE user done, display welcome screen at ATM Correct operation: client server HELO (userid) --------------> (check if valid userid) <------------- PASSWD PASSWD --------------> (check password) <------------- AMOUNT WITHDRAWL --------------> check if enough $ to cover withdrawl (check if valid userid) <------------- PASSWD PASSWD --------------> (check password) <------------- AMOUNT WITHDRAWL --------------> check if enough $ to cover withdrawl <------------- BYE Problem 2 At time N*(L/R) the first packet has reached the destination, the second packet is stored in the last router, the third packet is stored in the next-to-last router, etc. At time N*(L/R) + L/R, the second packet has reached the destination, the third packet is stored in the last router, etc. Continuing with this logic, we see that at time N*(L/R) + (P-1)*(L/R) = (N+P-1)*(L/R) all packets have reached the destination. Problem 3 a) A circuit-switched network would be well suited to the application, because the application involves long sessions with predictable smooth bandwidth requirements. Since the transmission rate is known and not bursty, bandwidth can be reserved for each application session without significant waste. In addition, the overhead costs of setting up and tearing down connections are amortized over the lengthy duration of a typical application session. b) In the worst case, all the applications simultaneously transmit over one or more network links. However, since each link has sufficient bandwidth to handle the sum of all of the applications' data rates, no congestion (very little queuing) will occur. Given such generous link capacities, the network does not need congestion control mechanisms. Problem 4 Between the switch in the upper left and the switch in the upper right we can have 4 connections. Similarly we can have four connections between each of the 3 other pairs of adjacent switches. Thus, this network can support up to 16 connections. We can 4 connections passing through the switch in the upper-right-hand corner and another 4 connections passing through the switch in the lower-left-hand corner, giving a total of 8 connections. Yes. For the connections between A and C, we route two connections through B and two connections through D. For the connections between B and D, we route two connections through A and two connections through C. In this manner, there are at most 4 connections passing through any link. Problem 5 Tollbooths are 75 km apart, and the cars propagate at 100km/hr. A tollbooth services a car at a rate of one car every 12 seconds. a) There are ten cars. It takes 120 seconds, or 2 minutes, for the first tollbooth to service the 10 cars. Each of these cars has a propagation delay of 45 minutes (travel 75 km) before arriving at the second tollbooth. Thus, all the cars are lined up before the second tollbooth after 47 minutes. The whole process repeats itself for traveling between the second and third tollbooths. It also takes 2 minutes for the third tollbooth to service the 10 cars. Thus the total delay is 96 minutes. b) Delay between tollbooths is 8*12 seconds plus 45 minutes, i.e., 46 minutes and 36 seconds. The total delay is twice this amount plus 8*12 seconds, i.e., 94 minutes and 48 seconds. Problem 6 a) seconds. b) seconds. c) seconds. d) The bit is just leaving Host A. e) The first bit is in the link and has not reached Host B. f) The first bit has reached Host B. g) Want km. Problem 7 Consider the first bit in a packet. Before this bit can be transmitted, all of the bits in the packet must be generated. This requires sec=7msec. The time required to transmit the packet is sec= sec. Propagation delay = 10 msec. The delay until decoding is 7msec + sec + 10msec = 17.224msec A similar analysis shows that all bits experience a delay of 17.224 msec. Problem 8 a) 20 users can be supported. b) . c) . d) . We use the central limit theorem to approximate this probability. Let be independent random variables such that . “21 or more users” when is a standard normal r.v. Thus “21 or more users” . Problem 9 10,000 Problem 10 The first end system requires L/R1 to transmit the packet onto the first link; the packet propagates over the first link in d1/s1; the packet switch adds a processing delay of dproc; after receiving the entire packet, the packet switch connecting the first and the second link requires L/R2 to transmit the packet onto the second link; the packet propagates over the second link in d2/s2. Similarly, we can find the delay caused by the second switch and the third link: L/R3, dproc, and d3/s3. Adding these five delays gives dend-end = L/R1 + L/R2 + L/R3 + d1/s1 + d2/s2 + d3/s3+ dproc+ dproc To answer the second question, we simply plug the values into the equation to get 6 + 6 + 6 + 20+16 + 4 + 3 + 3 = 64 msec. Problem 11 Because bits are immediately transmitted, the packet switch does not introduce any delay; in particular, it does not introduce a transmission delay. Thus, dend-end = L/R + d1/s1 + d2/s2+ d3/s3 For the values in Problem 10, we get 6 + 20 + 16 + 4 = 46 msec. Problem 12 The arriving packet must first wait for the link to transmit 4.5 *1,500 bytes = 6,750 bytes or 54,000 bits. Since these bits are transmitted at 2 Mbps, the queuing delay is 27 msec. Generally, the queuing delay is (nL + (L - x))/R. Problem 13 The queuing delay is 0 for the first transmitted packet, L/R for the second transmitted packet, and generally, (n-1)L/R for the nth transmitted packet. Thus, the average delay for the N packets is: (L/R + 2L/R + ....... + (N-1)L/R)/N = L/(RN) * (1 + 2 + ..... + (N-1)) = L/(RN) * N(N-1)/2 = LN(N-1)/(2RN) = (N-1)L/(2R) Note that here we used the well-known fact: 1 + 2 + ....... + N = N(N+1)/2 It takes seconds to transmit the packets. Thus, the buffer is empty when a each batch of packets arrive. Thus, the average delay of a packet across all batches is the average delay within one batch, i.e., (N-1)L/2R. Problem 14 The transmission delay is . The total delay is Let . Total delay = For x=0, the total delay =0; as we increase x, total delay increases, approaching infinity as x approaches 1/a. Problem 15 Total delay . Problem 16 The total number of packets in the system includes those in the buffer and the packet that is being transmitted. So, N=10+1. Because , so (10+1)=a*(queuing delay + transmission delay). That is, 11=a*(0.01+1/100)=a*(0.01+0.01). Thus, a=550 packets/sec. Problem 17 There are nodes (the source host and the routers). Let denote the processing delay at the th node. Let be the transmission rate of the th link and let . Let be the propagation delay across the th link. Then . Let denote the average queuing delay at node . Then . Problem 18 On linux you can use the command traceroute www.targethost.com and in the Windows command prompt you can use tracert www.targethost.com In either case, you will get three delay measurements. For those three measurements you can calculate the mean and standard deviation. Repeat the experiment at different times of the day and comment on any changes. Here is an example solution: Traceroutes between San Diego Super Computer Center and www.poly.edu The average (mean) of the round-trip delays at each of the three hours is 71.18 ms, 71.38 ms and 71.55 ms, respectively. The standard deviations are 0.075 ms, 0.21 ms, 0.05 ms, respectively. In this example, the traceroutes have 12 routers in the path at each of the three hours. No, the paths didn’t change during any of the hours. Traceroute packets passed through four ISP networks from source to destination. Yes, in this experiment the largest delays occurred at peering interfaces between adjacent ISPs. Traceroutes from www.stella-net.net (France) to www.poly.edu (USA). The average round-trip delays at each of the three hours are 87.09 ms, 86.35 ms and 86.48 ms, respectively. The standard deviations are 0.53 ms, 0.18 ms, 0.23 ms, respectively. In this example, there are 11 routers in the path at each of the three hours. No, the paths didn’t change during any of the hours. Traceroute packets passed three ISP networks from source to destination. Yes, in this experiment the largest delays occurred at peering interfaces between adjacent ISPs. Problem 19 An example solution: Traceroutes from two different cities in France to New York City in United States In these traceroutes from two different cities in France to the same destination host in United States, seven links are in common including the transatlantic link. In this example of traceroutes from one city in France and from another city in Germany to the same host in United States, three links are in common including the transatlantic link. Traceroutes to two different cities in China from same host in United States Five links are common in the two traceroutes. The two traceroutes diverge before reaching China Problem 20 Throughput = min{Rs, Rc, R/M} Problem 21 If only use one path, the max throughput is given by: . If use all paths, the max throughput is given by . Problem 22 Probability of successfully receiving a packet is: ps= (1-p)N. The number of transmissions needed to be performed until the packet is successfully received by the client is a geometric random variable with success probability ps. Thus, the average number of transmissions needed is given by: 1/ps . Then, the average number of re-transmissions needed is given by: 1/ps -1. Problem 23 Let’s call the first packet A and call the second packet B. If the bottleneck link is the first link, then packet B is queued at the first link waiting for the transmission of packet A. So the packet inter-arrival time at the destination is simply L/Rs. If the second link is the bottleneck link and both packets are sent back to back, it must be true that the second packet arrives at the input queue of the second link before the second link finishes the transmission of the first packet. That is, L/Rs + L/Rs + dprop = L/Rs + dprop + L/Rc Thus, the minimum value of T is L/Rc  L/Rs . Problem 24 40 terabytes = 40 * 1012 * 8 bits. So, if using the dedicated link, it will take 40 * 1012 * 8 / (100 *106 ) =3200000 seconds = 37 days. But with FedEx overnight delivery, you can guarantee the data arrives in one day, and it should cost less than $100. Problem 25 160,000 bits 160,000 bits The bandwidth-delay product of a link is the maximum number of bits that can be in the link. the width of a bit = length of link / bandwidth-delay product, so 1 bit is 125 meters long, which is longer than a football field s/R Problem 26 s/R=20000km, then R=s/20000km= 2.5*108/(2*107)= 12.5 bps Problem 27 80,000,000 bits 800,000 bits, this is because that the maximum number of bits that will be in the link at any given time = min(bandwidth delay product, packet size) = 800,000 bits. .25 meters Problem 28 ttrans + tprop = 400 msec + 80 msec = 480 msec. 20 * (ttrans + 2 tprop) = 20*(20 msec + 80 msec) = 2 sec. Breaking up a file takes longer to transmit because each data packet and its corresponding acknowledgement packet add their own propagation delays. Problem 29 Recall geostationary satellite is 36,000 kilometers away from earth surface. 150 msec 1,500,000 bits 600,000,000 bits Problem 30 Let’s suppose the passenger and his/her bags correspond to the data unit arriving to the top of the protocol stack. When the passenger checks in, his/her bags are checked, and a tag is attached to the bags and ticket. This is additional information added in the Baggage layer if Figure 1.20 that allows the Baggage layer to implement the service or separating the passengers and baggage on the sending side, and then reuniting them (hopefully!) on the destination side. When a passenger then passes through security and additional stamp is often added to his/her ticket, indicating that the passenger has passed through a security check. This information is used to ensure (e.g., by later checks for the security information) secure transfer of people. Problem 31 Time to send message from source host to first packet switch = With store-and-forward switching, the total time to move message from source host to destination host = Time to send 1st packet from source host to first packet switch = . . Time at which 2nd packet is received at the first switch = time at which 1st packet is received at the second switch = Time at which 1st packet is received at the destination host = . After this, every 5msec one packet will be received; thus time at which last (800th) packet is received = . It can be seen that delay in using message segmentation is significantly less (almost 1/3rd). Without message segmentation, if bit errors are not tolerated, if there is a single bit error, the whole message has to be retransmitted (rather than a single packet). Without message segmentation, huge packets (containing HD videos, for example) are sent into the network. Routers have to accommodate these huge packets. Smaller packets have to queue behind enormous packets and suffer unfair delays. Packets have to be put in sequence at the destination. Message segmentation results in many smaller packets. Since header size is usually the same for all packets regardless of their size, with message segmentation the total amount of header bytes is more. Problem 32 Yes, the delays in the applet correspond to the delays in the Problem 31.The propagation delays affect the overall end-to-end delays both for packet switching and message switching equally. Problem 33 There are F/S packets. Each packet is S=80 bits. Time at which the last packet is received at the first router is sec. At this time, the first F/S-2 packets are at the destination, and the F/S-1 packet is at the second router. The last packet must then be transmitted by the first router and the second router, with each transmission taking sec. Thus delay in sending the whole file is To calculate the value of S which leads to the minimum delay, Problem 34 The circuit-switched telephone networks and the Internet are connected together at "gateways". When a Skype user (connected to the Internet) calls an ordinary telephone, a circuit is established between a gateway and the telephone user over the circuit switched network. The skype user's voice is sent in packets over the Internet to the gateway. At the gateway, the voice signal is reconstructed and then sent over the circuit. In the other direction, the voice signal is sent over the circuit switched network to the gateway. The gateway packetizes the voice signal and sends the voice packets to the Skype user.   Chapter 2 Review Questions The Web: HTTP; file transfer: FTP; remote login: Telnet; e-mail: SMTP; BitTorrent file sharing: BitTorrent protocol Network architecture refers to the organization of the communication process into layers (e.g., the five-layer Internet architecture). Application architecture, on the other hand, is designed by an application developer and dictates the broad structure of the application (e.g., client-server or P2P). The process which initiates the communication is the client; the process that waits to be contacted is the server. No. In a P2P file-sharing application, the peer that is receiving a file is typically the client and the peer that is sending the file is typically the server. The IP address of the destination host and the port number of the socket in the destination process. You would use UDP. With UDP, the transaction can be completed in one roundtrip time (RTT) - the client sends the transaction request into a UDP socket, and the server sends the reply back to the client's UDP socket. With TCP, a minimum of two RTTs are needed - one to set-up the TCP connection, and another for the client to send the request, and for the server to send back the reply. One such example is remote word processing, for example, with Google docs. However, because Google docs runs over the Internet (using TCP), timing guarantees are not provided. a) Reliable data transfer TCP provides a reliable byte-stream between client and server but UDP does not. b) A guarantee that a certain value for throughput will be maintained Neither c) A guarantee that data will be delivered within a specified amount of time Neither d) Confidentiality (via encryption) Neither SSL operates at the application layer. The SSL socket takes unencrypted data from the application layer, encrypts it and then passes it to the TCP socket. If the application developer wants TCP to be enhanced with SSL, she has to include the SSL code in the application. A protocol uses handshaking if the two communicating entities first exchange control packets before sending data to each other. SMTP uses handshaking at the application layer whereas HTTP does not. The applications associated with those protocols require that all application data be received in the correct order and without gaps. TCP provides this service whereas UDP does not. When the user first visits the site, the server creates a unique identification number, creates an entry in its back-end database, and returns this identification number as a cookie number. This cookie number is stored on the user’s host and is managed by the browser. During each subsequent visit (and purchase), the browser sends the cookie number back to the site. Thus the site knows when this user (more precisely, this browser) is visiting the site. Web caching can bring the desired content “closer” to the user, possibly to the same LAN to which the user’s host is connected. Web caching can reduce the delay for all objects, even objects that are not cached, since caching reduces the traffic on links. Telnet is not available in Windows 7 by default. to make it available, go to Control Panel, Programs and Features, Turn Windows Features On or Off, Check Telnet client. To start Telnet, in Windows command prompt, issue the following command > telnet webserverver 80 where "webserver" is some webserver. After issuing the command, you have established a TCP connection between your client telnet program and the web server. Then type in an HTTP GET message. An example is given below: Since the index.html page in this web server was not modified since Fri, 18 May 2007 09:23:34 GMT, and the above commands were issued on Sat, 19 May 2007, the server returned "304 Not Modified". Note that the first 4 lines are the GET message and header lines inputed by the user, and the next 4 lines (starting from HTTP/1.1 304 Not Modified) is the response from the web server. FTP uses two parallel TCP connections, one connection for sending control information (such as a request to transfer a file) and another connection for actually transferring the file. Because the control information is not sent over the same connection that the file is sent over, FTP sends control information out of band. The message is first sent from Alice’s host to her mail server over HTTP. Alice’s mail server then sends the message to Bob’s mail server over SMTP. Bob then transfers the message from his mail server to his host over POP3. 17. Received: from 65.54.246.203 (EHLO bay0-omc3-s3.bay0.hotmail.com) (65.54.246.203) by mta419.mail.mud.yahoo.com with SMTP; Sat, 19 May 2007 16:53:51 -0700 Received: from hotmail.com ([65.55.135.106]) by bay0-omc3-s3.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Sat, 19 May 2007 16:52:42 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 19 May 2007 16:52:41 -0700 Message-ID: Received: from 65.55.135.123 by by130fd.bay130.hotmail.msn.com with HTTP; Sat, 19 May 2007 23:52:36 GMT From: "prithula dhungel" To: prithula@yahoo.com Bcc: Subject: Test mail Date: Sat, 19 May 2007 23:52:36 +0000 Mime-Version: 1.0 Content-Type: Text/html; format=flowed Return-Path: prithuladhungel@hotmail.com Figure: A sample mail message header Received: This header field indicates the sequence in which the SMTP servers send and receive the mail message including the respective timestamps. In this example there are 4 “Received:” header lines. This means the mail message passed through 5 different SMTP servers before being delivered to the receiver’s mail box. The last (forth) “Received:” header indicates the mail message flow from the SMTP server of the sender to the second SMTP server in the chain of servers. The sender’s SMTP server is at address 65.55.135.123 and the second SMTP server in the chain is by130fd.bay130.hotmail.msn.com. The third “Received:” header indicates the mail message flow from the second SMTP server in the chain to the third server, and so on. Finally, the first “Received:” header indicates the flow of the mail messages from the forth SMTP server to the last SMTP server (i.e. the receiver’s mail server) in the chain. Message-id: The message has been given this number BAY130-F26D9E35BF59E0D18A819AFB9310@phx.gbl (by bay0-omc3-s3.bay0.hotmail.com. Message-id is a unique string assigned by the mail system when the message is first created. From: This indicates the email address of the sender of the mail. In the given example, the sender is “prithuladhungel@hotmail.com” To: This field indicates the email address of the receiver of the mail. In the example, the receiver is “prithula@yahoo.com” Subject: This gives the subject of the mail (if any specified by the sender). In the example, the subject specified by the sender is “Test mail” Date: The date and time when the mail was sent by the sender. In the example, the sender sent the mail on 19th May 2007, at time 23:52:36 GMT. Mime-version: MIME version used for the mail. In the example, it is 1.0. Content-type: The type of content in the body of the mail message. In the example, it is “text/html”. Return-Path: This specifies the email address to which the mail will be sent if the receiver of this mail wants to reply to the sender. This is also used by the sender’s mail server for bouncing back undeliverable mail messages of mailer-daemon error messages. In the example, the return path is “prithuladhungel@hotmail.com”. With download and delete, after a user retrieves its messages from a POP server, the messages are deleted. This poses a problem for the nomadic user, who may want to access the messages from many different machines (office PC, home PC, etc.). In the download and keep configuration, messages are not deleted after the user retrieves the messages. This can also be inconvenient, as each time the user retrieves the stored messages from a new machine, all of non-deleted messages will be transferred to the new machine (including very old messages). Yes an organization’s mail server and Web server can have the same alias for a host name. The MX record is used to map the mail server’s host name to its IP address. You should be able to see the sender's IP address for a user with an .edu email address. But you will not be able to see the sender's IP address if the user uses a gmail account. It is not necessary that Bob will also provide chunks to Alice. Alice has to be in the top 4 neighbors of Bob for Bob to send out chunks to her; this might not occur even if Alice provides chunks to Bob throughout a 30-second interval. Recall that in BitTorrent, a peer picks a random peer and optimistically unchokes the peer for a short period of time. Therefore, Alice will eventually be optimistically unchoked by one of her neighbors, during which time she will receive chunks from that neighbor. The overlay network in a P2P file sharing system consists of the nodes participating in the file sharing system and the logical links between the nodes. There is a logical link (an “edge” in graph theory terms) from node A to node B if there is a semi-permanent TCP connection between A and B. An overlay network does not include routers. Mesh DHT: The advantage is in order to a route a message to the peer (with ID) that is closest to the key, only one hop is required; the disadvantage is that each peer must track all other peers in the DHT. Circular DHT: the advantage is that each peer needs to track only a few other peers; the disadvantage is that O(N) hops are needed to route a message to the peer that is closest to the key. 25. File Distribution Instant Messaging Video Streaming Distributed Computing With the UDP server, there is no welcoming socket, and all data from different clients enters the server through this one socket. With the TCP server, there is a welcoming socket, and each time a client initiates a connection to the server, a new socket is created. Thus, to support n simultaneous connections, the server would need n+1 sockets. For the TCP application, as soon as the client is executed, it attempts to initiate a TCP connection with the server. If the TCP server is not running, then the client will fail to make a connection. For the UDP application, the client does not initiate connections (or attempt to communicate with the UDP server) immediately upon execution Chapter 2 Problems Problem 1 a) F b) T c) F d) F e) F Problem 2 Access control commands: USER, PASS, ACT, CWD, CDUP, SMNT, REIN, QUIT. Transfer parameter commands: PORT, PASV, TYPE STRU, MODE. Service commands: RETR, STOR, STOU, APPE, ALLO, REST, RNFR, RNTO, ABOR, DELE, RMD, MRD, PWD, LIST, NLST, SITE, SYST, STAT, HELP, NOOP. Problem 3 Application layer protocols: DNS and HTTP Transport layer protocols: UDP for DNS; TCP for HTTP Problem 4 The document request was http://gaia.cs.umass.edu/cs453/index.html. The Host : field indicates the server's name and /cs453/index.html indicates the file name. The browser is running HTTP version 1.1, as indicated just before the first pair. The browser is requesting a persistent connection, as indicated by the Connection: keep-alive. This is a trick question. This information is not contained in an HTTP message anywhere. So there is no way to tell this from looking at the exchange of HTTP messages alone. One would need information from the IP datagrams (that carried the TCP segment that carried the HTTP GET request) to answer this question. Mozilla/5.0. The browser type information is needed by the server to send different versions of the same object to different types of browsers. Problem 5 The status code of 200 and the phrase OK indicate that the server was able to locate the document successfully. The reply was provided on Tuesday, 07 Mar 2008 12:39:45 Greenwich Mean Time. The document index.html was last modified on Saturday 10 Dec 2005 18:27:46 GMT. There are 3874 bytes in the document being returned. The first five bytes of the returned document are : server agreed to a persistent connection, as indicated by the Connection: Keep-Alive field Problem 6 Persistent connections are discussed in section 8 of RFC 2616 (the real goal of this question was to get you to retrieve and read an RFC). Sections 8.1.2 and 8.1.2.1 of the RFC indicate that either the client or the server can indicate to the other that it is going to close the persistent connection. It does so by including the connection-token "close" in the Connection-header field of the http request/reply. HTTP does not provide any encryption services. (From RFC 2616) “Clients that use persistent connections should limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.” Yes. (From RFC 2616) “A client might have started to send a new request at the same time that the server has decided to close the "idle" connection. From the server's point of view, the connection is being closed while it was idle, but from the client's point of view, a request is in progress.” Problem 7 The total amount of time to get the IP address is . Once the IP address is known, elapses to set up the TCP connection and another elapses to request and receive the small object. The total response time is Problem 8 . . Problem 9 The time to transmit an object of size L over a link or rate R is L/R. The average time is the average size of the object divided by R:  = (850,000 bits)/(15,000,000 bits/sec) = .0567 sec The traffic intensity on the link is given by =(16 requests/sec)(.0567 sec/request) = 0.907. Thus, the average access delay is (.0567 sec)/(1 - .907)  .6 seconds. The total average response time is therefore .6 sec + 3 sec = 3.6 sec. The traffic intensity on the access link is reduced by 60% since the 60% of the requests are satisfied within the institutional network. Thus the average access delay is (.0567 sec)/[1 – (.4)(.907)] = .089 seconds. The response time is approximately zero if the request is satisfied by the cache (which happens with probability .6); the average response time is .089 sec + 3 sec = 3.089 sec for cache misses (which happens 40% of the time). So the average response time is (.6)(0 sec) + (.4)(3.089 sec) = 1.24 seconds. Thus the average response time is reduced from 3.6 sec to 1.24 sec. Problem 10 Note that each downloaded object can be completely put into one data packet. Let Tp denote the one-way propagation delay between the client and the server. First consider parallel downloads using non-persistent connections. Parallel downloads would allow 10 connections to share the 150 bits/sec bandwidth, giving each just 15 bits/sec. Thus, the total time needed to receive all objects is given by: (200/150+Tp + 200/150 +Tp + 200/150+Tp + 100,000/150+ Tp ) + (200/(150/10)+Tp + 200/(150/10) +Tp + 200/(150/10)+Tp + 100,000/(150/10)+ Tp ) = 7377 + 8*Tp (seconds) Now consider a persistent HTTP connection. The total time needed is given by: (200/150+Tp + 200/150 +Tp + 200/150+Tp + 100,000/150+ Tp ) + 10*(200/150+Tp + 100,000/150+ Tp ) =7351 + 24*Tp (seconds) Assuming the speed of light is 300*106 m/sec, then Tp=10/(300*106)=0.03 microsec. Tp is therefore negligible compared with transmission delay. Thus, we see that persistent HTTP is not significantly faster (less than 1 percent) than the non-persistent case with parallel download. Problem 11 Yes, because Bob has more connections, he can get a larger share of the link bandwidth. Yes, Bob still needs to perform parallel downloads; otherwise he will get less bandwidth than the other four users. Problem 12 Server.py from socket import * serverPort=12000 serverSocket=socket(AF_INET,SOCK_STREAM) serverSocket.bind(('',serverPort)) serverSocket.listen(1) connectionSocket, addr = serverSocket.accept() while 1: sentence = connectionSocket.recv(1024) print 'From Server:', sentence, '\n' serverSocket.close() Problem 13 The MAIL FROM: in SMTP is a message from the SMTP client that identifies the sender of the mail message to the SMTP server. The From: on the mail message itself is NOT an SMTP message, but rather is just a line in the body of the mail message. Problem 14 SMTP uses a line containing only a period to mark the end of a message body. HTTP uses “Content-Length header field” to indicate the length of a message body. No, HTTP cannot use the method used by SMTP, because HTTP message could be binary data, whereas in SMTP, the message body must be in 7-bit ASCII format. Problem 15 MTA stands for Mail Transfer Agent. A host sends the message to an MTA. The message then follows a sequence of MTAs to reach the receiver’s mail reader. We see that this spam message follows a chain of MTAs. An honest MTA should report where it receives the message. Notice that in this message, “asusus-4b96 ([58.88.21.177])” does not report from where it received the email. Since we assume only the originator is dishonest, so “asusus-4b96 ([58.88.21.177])” must be the originator. Problem 16 UIDL abbreviates “unique-ID listing”. When a POP3 client issues the UIDL command, the server responds with the unique message ID for all of the messages present in the user's mailbox. This command is useful for “download and keep”. By maintaining a file that lists the messages retrieved during earlier sessions, the client can use the UIDL command to determine which messages on the server have already been seen. Problem 17 a) C: dele 1 C: retr 2 S: (blah blah … S: ………..blah) S: . C: dele 2 C: quit S: +OK POP3 server signing off b) C: retr 2 S: blah blah … S: ………..blah S: . C: quit S: +OK POP3 server signing off C: list S: 1 498 S: 2 912 S: . C: retr 1 S: blah ….. S: ….blah S: . C: retr 2 S: blah blah … S: ………..blah S: . C: quit S: +OK POP3 server signing off Problem 18 For a given input of domain name (such as ccn.com), IP address or network administrator name, the whois database can be used to locate the corresponding registrar, whois server, DNS server, and so on. NS4.YAHOO.COM from www.register.com; NS1.MSFT.NET from ww.register.com Local Domain: www.mindspring.com Web servers : www.mindspring.com 207.69.189.21, 207.69.189.22, 207.69.189.23, 207.69.189.24, 207.69.189.25, 207.69.189.26, 207.69.189.27, 207.69.189.28 Mail Servers : mx1.mindspring.com (207.69.189.217) mx2.mindspring.com (207.69.189.218) mx3.mindspring.com (207.69.189.219) mx4.mindspring.com (207.69.189.220) Name Servers: itchy.earthlink.net (207.69.188.196) scratchy.earthlink.net (207.69.188.197) www.yahoo.com Web Servers: www.yahoo.com (216.109.112.135, 66.94.234.13) Mail Servers: a.mx.mail.yahoo.com (209.191.118.103) b.mx.mail.yahoo.com (66.196.97.250) c.mx.mail.yahoo.com (68.142.237.182, 216.39.53.3) d.mx.mail.yahoo.com (216.39.53.2) e.mx.mail.yahoo.com (216.39.53.1) f.mx.mail.yahoo.com (209.191.88.247, 68.142.202.247) g.mx.mail.yahoo.com (209.191.88.239, 206.190.53.191) Name Servers: ns1.yahoo.com (66.218.71.63) ns2.yahoo.com (68.142.255.16) ns3.yahoo.com (217.12.4.104) ns4.yahoo.com (68.142.196.63) ns5.yahoo.com (216.109.116.17) ns8.yahoo.com (202.165.104.22) ns9.yahoo.com (202.160.176.146) www.hotmail.com Web Servers: www.hotmail.com (64.4.33.7, 64.4.32.7) Mail Servers: mx1.hotmail.com (65.54.245.8, 65.54.244.8, 65.54.244.136) mx2.hotmail.com (65.54.244.40, 65.54.244.168, 65.54.245.40) mx3.hotmail.com (65.54.244.72, 65.54.244.200, 65.54.245.72) mx4.hotmail.com (65.54.244.232, 65.54.245.104, 65.54.244.104) Name Servers: ns1.msft.net (207.68.160.190) ns2.msft.net (65.54.240.126) ns3.msft.net (213.199.161.77) ns4.msft.net (207.46.66.126) ns5.msft.net (65.55.238.126) d) The yahoo web server has multiple IP addresses www.yahoo.com (216.109.112.135, 66.94.234.13) e) The address range for Polytechnic University: 128.238.0.0 – 128.238.255.255 f) An attacker can use the whois database and nslookup tool to determine the IP address ranges, DNS server addresses, etc., for the target institution. By analyzing the source address of attack packets, the victim can use whois to obtain information about domain from which the attack is coming and possibly inform the administrators of the origin domain. Problem 19 The following delegation chain is used for gaia.cs.umass.edu a.root-servers.net E.GTLD-SERVERS.NET ns1.umass.edu(authoritative) First command: dig +norecurse @a.root-servers.net any gaia.cs.umass.edu ;; AUTHORITY SECTION: edu. 172800 IN NS E.GTLD-SERVERS.NET. edu. 172800 IN NS A.GTLD-SERVERS.NET. edu. 172800 IN NS G3.NSTLD.COM. edu. 172800 IN NS D.GTLD-SERVERS.NET. edu. 172800 IN NS H3.NSTLD.COM. edu. 172800 IN NS L3.NSTLD.COM. edu. 172800 IN NS M3.NSTLD.COM. edu. 172800 IN NS C.GTLD-SERVERS.NET. Among all returned edu DNS servers, we send a query to the first one. dig +norecurse @E.GTLD-SERVERS.NET any gaia.cs.umass.edu umass.edu. 172800 IN NS ns1.umass.edu. umass.edu. 172800 IN NS ns2.umass.edu. umass.edu. 172800 IN NS ns3.umass.edu. Among all three returned authoritative DNS servers, we send a query to the first one. dig +norecurse @ns1.umass.edu any gaia.cs.umass.edu gaia.cs.umass.edu. 21600 IN A 128.119.245.12 The answer for google.com could be: a.root-servers.net E.GTLD-SERVERS.NET ns1.google.com(authoritative) Problem 20 We can periodically take a snapshot of the DNS caches in the local DNS servers. The Web server that appears most frequently in the DNS caches is the most popular server. This is because if more users are interested in a Web server, then DNS requests for that server are more frequently sent by users. Thus, that Web server will appear in the DNS caches more frequently. For a complete measurement study, see: Craig E. Wills, Mikhail Mikhailov, Hao Shang “Inferring Relative Popularity of Internet Applications by Actively Querying DNS Caches”, in IMC'03, October 27­29, 2003, Miami Beach, Florida, USA Problem 21 Yes, we can use dig to query that Web site in the local DNS server. For example, “dig cnn.com” will return the query time for finding cnn.com. If cnn.com was just accessed a couple of seconds ago, an entry for cnn.com is cached in the local DNS cache, so the query time is 0 msec. Otherwise, the query time is large. Problem 22 For calculating the minimum distribution time for client-server distribution, we use the following formula: Dcs = max {NF/us, F/dmin} Similarly, for calculating the minimum distribution time for P2P distribution, we use the following formula: Where, F = 15 Gbits = 15 * 1024 Mbits us = 30 Mbps dmin = di = 2 Mbps Note, 300Kbps = 300/1024 Mbps. Client Server N 10 100 1000 u 300 Kbps 7680 51200 512000 700 Kbps 7680 51200 512000 2 Mbps 7680 51200 512000 Peer to Peer N 10 100 1000 u 300 Kbps 7680 25904 47559 700 Kbps 7680 15616 21525 2 Mbps 7680 7680 7680 Problem 23 Consider a distribution scheme in which the server sends the file to each client, in parallel, at a rate of a rate of us/N. Note that this rate is less than each of the client’s download rate, since by assumption us/N ≤ dmin. Thus each client can also receive at rate us/N. Since each client receives at rate us/N, the time for each client to receive the entire file is F/( us/N) = NF/ us. Since all the clients receive the file in NF/ us, the overall distribution time is also NF/ us. Consider a distribution scheme in which the server sends the file to each client, in parallel, at a rate of dmin. Note that the aggregate rate, N dmin, is less than the server’s link rate us, since by assumption us/N ≥ dmin. Since each client receives at rate dmin, the time for each client to receive the entire file is F/ dmin. Since all the clients receive the file in this time, the overall distribution time is also F/ dmin. From Section 2.6 we know that DCS ≥ max {NF/us, F/dmin} (Equation 1) Suppose that us/N ≤ dmin. Then from Equation 1 we have DCS ≥ NF/us . But from (a) we have DCS ≤ NF/us . Combining these two gives: DCS = NF/us when us/N ≤ dmin. (Equation 2) We can similarly show that: DCS =F/dmin when us/N ≥ dmin (Equation 3). Combining Equation 2 and Equation 3 gives the desired result. Problem 24 Define u = u1 + u2 + ….. + uN. By assumption us <= (us + u)/N Equation 1 Divide the file into N parts, with the ith part having size (ui/u)F. The server transmits the ith part to peer i at rate ri = (ui/u)us. Note that r1 + r2 + ….. + rN = us, so that the aggregate server rate does not exceed the link rate of the server. Also have each peer i forward the bits it receives to each of the N-1 peers at rate ri. The aggregate forwarding rate by peer i is (N-1)ri. We have (N-1)ri = (N-1)(usui)/u = (us + u)/N Equation 2 Let ri = ui/(N-1) and rN+1 = (us – u/(N-1))/N In this distribution scheme, the file is broken into N+1 parts. The server sends bits from the ith part to the ith peer (i = 1, …., N) at rate ri. Each peer i forwards the bits arriving at rate ri to each of the other N-1 peers. Additionally, the server sends bits from the (N+1) st part at rate rN+1 to each of the N peers. The peers do not forward the bits from the (N+1)st part. The aggregate send rate of the server is r1+ …. + rN + N rN+1 = u/(N-1) + us – u/(N-1) = us Thus, the server’s send rate does not exceed its link rate. The aggregate send rate of peer i is (N-1)ri = ui Thus, each peer’s send rate does not exceed its link rate. In this distribution scheme, peer i receives bits at an aggregate rate of Thus each peer receives the file in NF/(us+u). (For simplicity, we neglected to specify the size of the file part for i = 1, …., N+1. We now provide that here. Let Δ = (us+u)/N be the distribution time. For i = 1, …, N, the ith file part is Fi = ri Δ bits. The (N+1)st file part is FN+1 = rN+1 Δ bits. It is straightforward to show that F1+ ….. + FN+1 = F.) The solution to this part is similar to that of 17 (c). We know from section 2.6 that Combining this with a) and b) gives the desired result. Problem 25 There are N nodes in the overlay network. There are N(N-1)/2 edges. Problem 26 Yes. His first claim is possible, as long as there are enough peers staying in the swarm for a long enough time. Bob can always receive data through optimistic unchoking by other peers. His second claim is also true. He can run a client on each host, let each client “free-ride,” and combine the collected chunks from the different hosts into a single file. He can even write a small scheduling program to make the different hosts ask for different chunks of the file. This is actually a kind of Sybil attack in P2P networks. Problem 27 Peer 3 learns that peer 5 has just left the system, so Peer 3 asks its first successor (Peer 4) for the identifier of its immediate successor (peer 8). Peer 3 will then make peer 8 its second successor. Problem 28 Peer 6 would first send peer 15 a message, saying “what will be peer 6’s predecessor and successor?” This message gets forwarded through the DHT until it reaches peer 5, who realizes that it will be 6’s predecessor and that its current successor, peer 8, will become 6’s successor. Next, peer 5 sends this predecessor and successor information back to 6. Peer 6 can now join the DHT by making peer 8 its successor and by notifying peer 5 that it should change its immediate successor to 6. Problem 29 For each key, we first calculate the distances (using d(k,p)) between itself and all peers, and then store the key in the peer that is closest to the key (that is, with smallest distance value). Problem 30 Yes, randomly assigning keys to peers does not consider the underlying network at all, so it very likely causes mismatches. Such mismatches may degrade the search performance. For example, consider a logical path p1 (consisting of only two logical links): ABC, where A and B are neighboring peers, and B and C are neighboring peers. Suppose that there is another logical path p2 from A to C (consisting of 3 logical links): ADEC. It might be the case that A and B are very far away physically (and separated by many routers), and B and C are very far away physically (and separated by many routers). But it may be the case that A, D, E, and C are all very close physically (and all separated by few routers). In other words, a shorter logical path may correspond to a much longer physical path. Problem 31 If you run TCPClient first, then the client will attempt to make a TCP connection with a non-existent server process. A TCP connection will not be made. UDPClient doesn't establish a TCP connection with the server. Thus, everything should work fine if you first run UDPClient, then run UDPServer, and then type some input into the keyboard. If you use different port numbers, then the client will attempt to establish a TCP connection with the wrong process or a non-existent process. Errors will occur. Problem 32 In the original program, UDPClient does not specify a port number when it creates the socket. In this case, the code lets the underlying operating system choose a port number. With the additional line, when UDPClient is executed, a UDP socket is created with port number 5432 . UDPServer needs to know the client port number so that it can send packets back to the correct client socket. Glancing at UDPServer, we see that the client port number is not “hard-wired” into the server code; instead, UDPServer determines the client port number by unraveling the datagram it receives from the client. Thus UDP server will work with any client port number, including 5432. UDPServer therefore does not need to be modified. Before: Client socket = x (chosen by OS) Server socket = 9876 After: Client socket = 5432 Problem 33 Yes, you can configure many browsers to open multiple simultaneous connections to a Web site. The advantage is that you will you potentially download the file faster. The disadvantage is that you may be hogging the bandwidth, thereby significantly slowing down the downloads of other users who are sharing the same physical links. Problem 34 For an application such as remote login (telnet and ssh), a byte-stream oriented protocol is very natural since there is no notion of message boundaries in the application. When a user types a character, we simply drop the character into the TCP connection. In other applications, we may be sending a series of messages that have inherent boundaries between them. For example, when one SMTP mail server sends another SMTP mail server several email messages back to back. Since TCP does not have a mechanism to indicate the boundaries, the application must add the indications itself, so that receiving side of the application can distinguish one message from the next. If each message were instead put into a distinct UDP segment, the receiving end would be able to distinguish the various messages without any indications added by the sending side of the application. Problem 35 To create a web server, we need to run web server software on a host. Many vendors sell web server software. However, the most popular web server software today is Apache, which is open source and free. Over the years it has been highly optimized by the open-source community. Problem 36 The key is the infohash, the value is an IP address that currently has the file designated by the infohash.   Chapter 3 Review Questions Call this protocol Simple Transport Protocol (STP). At the sender side, STP accepts from the sending process a chunk of data not exceeding 1196 bytes, a destination host address, and a destination port number. STP adds a four-byte header to each chunk and puts the port number of the destination process in this header. STP then gives the destination host address and the resulting segment to the network layer. The network layer delivers the segment to STP at the destination host. STP then examines the port number in the segment, extracts the data from the segment, and passes the data to the process identified by the port number. The segment now has two header fields: a source port field and destination port field. At the sender side, STP accepts a chunk of data not exceeding 1192 bytes, a destination host address, a source port number, and a destination port number. STP creates a segment which contains the application data, source port number, and destination port number. It then gives the segment and the destination host address to the network layer. After receiving the segment, STP at the receiving host gives the application process the application data and the source port number. No, the transport layer does not have to do anything in the core; the transport layer “lives” in the end systems. For sending a letter, the family member is required to give the delegate the letter itself, the address of the destination house, and the name of the recipient. The delegate clearly writes the recipient’s name on the top of the letter. The delegate then puts the letter in an envelope and writes the address of the destination house on the envelope. The delegate then gives the letter to the planet’s mail service. At the receiving side, the delegate receives the letter from the mail service, takes the letter out of the envelope, and takes note of the recipient name written at the top of the letter. The delegate then gives the letter to the family member with this name. No, the mail service does not have to open the envelope; it only examines the address on the envelope. Source port number y and destination port number x. An application developer may not want its application to use TCP’s congestion control, which can throttle the application’s sending rate at times of congestion. Often, designers of IP telephony and IP videoconference applications choose to run their applications over UDP because they want to avoid TCP’s congestion control. Also, some applications do not need the reliable data transfer provided by TCP. Since most firewalls are configured to block UDP traffic, using TCP for video and voice traffic lets the traffic though the firewalls. Yes. The application developer can put reliable data transfer into the application layer protocol. This would require a significant amount of work and debugging, however. Yes, both segments will be directed to the same socket. For each received segment, at the socket interface, the operating system will provide the process with the IP addresses to determine the origins of the individual segments. For each persistent connection, the Web server creates a separate “connection socket”. Each connection socket is identified with a four-tuple: (source IP address, source port number, destination IP address, destination port number). When host C receives and IP datagram, it examines these four fields in the datagram/segment to determine to which socket it should pass the payload of the TCP segment. Thus, the requests from A and B pass through different sockets. The identifier for both of these sockets has 80 for the destination port; however, the identifiers for these sockets have different values for source IP addresses. Unlike UDP, when the transport layer passes a TCP segment’s payload to the application process, it does not specify the source IP address, as this is implicitly specified by the socket identifier. Sequence numbers are required for a receiver to find out whether an arriving packet contains new data or is a retransmission. To handle losses in the channel. If the ACK for a transmitted packet is not received within the duration of the timer for the packet, the packet (or its ACK or NACK) is assumed to have been lost. Hence, the packet is retransmitted. A timer would still be necessary in the protocol rdt 3.0. If the round trip time is known then the only advantage will be that, the sender knows for sure that either the packet or the ACK (or NACK) for the packet has been lost, as compared to the real scenario, where the ACK (or NACK) might still be on the way to the sender, after the timer expires. However, to detect the loss, for each packet, a timer of constant duration will still be necessary at the sender. The packet loss caused a time out after which all the five packets were retransmitted. Loss of an ACK didn’t trigger any retransmission as Go-Back-N uses cumulative acknowledgements. The sender was unable to send sixth packet as the send window size is fixed to 5. When the packet was lost, the received four packets were buffered the receiver. After the timeout, sender retransmitted the lost packet and receiver delivered the buffered packets to application in correct order. Duplicate ACK was sent by the receiver for the lost ACK. The sender was unable to send sixth packet as the send win
ORACLE常用命令 一、ORACLE的启动和关闭 1、在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a、启动ORACLE系统 oracle>svrmgrl SVRMGR>connect internal SVRMGR>startup SVRMGR>quit b、关闭ORACLE系统 oracle>svrmgrl SVRMGR>connect internal SVRMGR>shutdown SVRMGR>quit 启动oracle9i数据库命令: $ sqlplus /nolog SQL*Plus: Release 9.2.0.1.0 - Production on Fri Oct 31 13:53:53 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> connect / as sysdba Connected to an idle instance. SQL> startup^C SQL> startup ORACLE instance started. 2、在双机环境下 要想启动或关闭ORACLE系统必须首先切换到root用户,如下 su - root a、启动ORACLE系统 hareg -y oracle b、关闭ORACLE系统 hareg -n oracle Oracle数据库有哪几种启动方式 说明: 有以下几种启动方式: 1、startup nomount 非安装启动,这种方式启动下可执行:重建控制文件、重建数据库 读取init.ora文件,启动instance,即启动SGA和后台进程,这种启动只需要init.ora文件。 2、startup mount dbname 安装启动,这种方式启动下可执行: 数据库日志归档、 数据库介质恢复、 使数据文件联机或脱机, 重新定位数据文件、重做日志文件。 执行“nomount”,然后打开控制文件,确认数据文件和联机日志文件的位置, 但此时不对数据文件和日志文件进行校验检查。 3、startup open dbname 先执行“nomount”,然后执行“mount”,再打开包括Redo log文件在内的所有数据库文件, 这种方式下可访问数据库的数据。 4、startup,等于以下三个命令 startup nomount alter database mount alter database open 5、startup restrict 约束方式启动 这种方式能够启动数据库,但只允许具有一定特权的用户访问 非特权用户访问时,会出现以下提示: ERROR: ORA-01035: ORACLE 只允许具有 RESTRICTED SESSION 权限的用户使用 6、startup force 强制启动方式 当不能关闭数据库时,可以用startup force来完成数据库的关闭 先关闭数据库,再执行正常启动数据库命令 7、startup pfile=参数文件名 带初始化参数文件的启动方式 先读取参数文件,再按参数文件的设置启动数据库 例:startup pfile=E:Oracleadminoradbpfileinit.ora 8、startup EXCLUSIVE 二、用户如何有效地利用数据字典  ORACLE的数据字典是数据库的重要组成部分之一,它随着数据库的产生而产生, 随着数据库的变化而变化, 体现为sys用户下的一些表和视图。数据字典名称是大写的英文字符。 数据字典里存有用户信息、用户的权限信息、所有数据对象信息、表的约束条件、统计分析数据库的视图等。 我们不能手工修改数据字典里的信息。   很多时候,一般的ORACLE用户不知道如何有效地利用它。   dictionary   全部数据字典表的名称和解释,它有一个同义词dict dict_column   全部数据字典表里字段名称和解释 如果我们想查询跟索引有关的数据字典时,可以用下面这条SQL语句: SQL>select * from dictionary where instr(comments,'index')>0; 如果我们想知道user_indexes表各字段名称的详细含义,可以用下面这条SQL语句: SQL>select column_name,comments from dict_columns where table_name='USER_INDEXES'; 依此类推,就可以轻松知道数据字典的详细名称和解释,不用查看ORACLE的其它文档资料了。 下面按类别列出一些ORACLE用户常用数据字典的查询使用方法。 1、用户 查看当前用户的缺省表空间 SQL>select username,default_tablespace from user_users; 查看当前用户的角色 SQL>select * from user_role_privs; 查看当前用户的系统权限和表级权限 SQL>select * from user_sys_privs; SQL>select * from user_tab_privs; 2、表 查看用户下所有的表 SQL>select * from user_tables; 查看名称包含log字符的表 SQL>select object_name,object_id from user_objects where instr(object_name,'LOG')>0; 查看某表的创建时间 SQL>select object_name,created from user_objects where object_name=upper('&table_name'); 查看某表的大小 SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&table_name'); 查看放在ORACLE的内存区里的表 SQL>select table_name,cache from user_tables where instr(cache,'Y')>0; 3、索引 查看索引个数和类别 SQL>select index_name,index_type,table_name from user_indexes order by table_name; 查看索引被索引的字段 SQL>select * from user_ind_columns where index_name=upper('&index_name'); 查看索引的大小 SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&index_name'); 4、序列号 查看序列号,last_number是当前值 SQL>select * from user_sequences; 5、视图 查看视图的名称 SQL>select view_name from user_views; 查看创建视图的select语句 SQL>set view_name,text_length from user_views; SQL>set long 2000; 说明:可以根据视图的text_length值设定set long 的大小 SQL>select text from user_views where view_name=upper('&view_name'); 6、同义词 查看同义词的名称 SQL>select * from user_synonyms; 7、约束条件 查看某表的约束条件 SQL>select constraint_name, constraint_type,search_condition, r_constraint_name from user_constraints where table_name = upper('&table_name'); SQL>select c.constraint_name,c.constraint_type,cc.column_name from user_constraints c,user_cons_columns cc where c.owner = upper('&table_owner') and c.table_name = upper('&table_name') and c.owner = cc.owner and c.constraint_name = cc.constraint_name order by cc.position; 8、存储函数和过程 查看函数和过程的状态 SQL>select object_name,status from user_objects where object_type='FUNCTION'; SQL>select object_name,status from user_objects where object_type='PROCEDURE'; 查看函数和过程的源代码 SQL>select text from all_source where owner=user and name=upper('&plsql_name'); 三、查看数据库的SQL 1、查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size from dba_tablespaces t, dba_data_files d where t.tablespace_name = d.tablespace_name group by t.tablespace_name; 2、查看表空间物理文件的名称及大小 select tablespace_name, file_id, file_name, round(bytes/(1024*1024),0) total_space from dba_data_files order by tablespace_name; 3、查看回滚段名称及大小 select segment_name, tablespace_name, r.status, (initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent, max_extents, v.curext CurExtent From dba_rollback_segs r, v$rollstat v Where r.segment_id = v.usn(+) order by segment_name ; 4、查看控制文件 select name from v$controlfile; 5、查看日志文件 select member from v$logfile; 6、查看表空间的使用情况 select sum(bytes)/(1024*1024) as free_space,tablespace_name from dba_free_space group by tablespace_name; SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE, (B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE" FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME; 7、查看数据库库对象 select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status; 8、查看数据库的版本 Select version FROM Product_component_version Where SUBSTR(PRODUCT,1,6)='Oracle'; 9、查看数据库的创建日期和归档方式 Select Created, Log_Mode, Log_Mode From V$Database; 四、ORACLE用户连接的管理 用系统管理员,查看当前数据库有几个用户连接: SQL> select username,sid,serial# from v$session; 如果要停某个连接用 SQL> alter system kill session 'sid,serial#'; 如果这命令不行,找它UNIX的进程数 SQL> select pro.spid from v$session ses,v$process pro where ses.sid=21 and ses.paddr=pro.addr; 说明:21是某个连接的sid数 然后用 kill 命令杀此进程号。 五、SQL*PLUS使用 a、近入SQL*Plus $sqlplus 用户名/密码 退出SQL*Plus SQL>exit b、在sqlplus下得到帮助信息 列出全部SQL命令和SQL*Plus命令 SQL>help 列出某个特定的命令的信息 SQL>help 命令名 c、显示表结构命令DESCRIBE SQL>DESC 表名 d、SQL*Plus的编辑命令 显示SQL缓冲区命令 SQL>L 修改SQL命令 首先要将待改正行变为当前行 SQL>n 用CHANGE命令修改内容 SQL>c/旧/新 重新确认是否已正确 SQL>L 使用INPUT命令可以在SQL缓冲区增加一行或多行 SQL>i SQL>输入内容 e、调用外部系统编辑器 SQL>edit 文件名 可以使用DEFINE命令设置系统变量EDITOR来改变文本编辑器的类型,在login.sql文件定义如下一行 DEFINE_EDITOR=vi f、运行命令文件 SQL>START test SQL>@test 常用SQL*Plus语句 a、表的创建、修改、删除 创建表的命令格式如下: create table 表名 (列说明列表); 为基表增加新列命令如下: ALTER TABLE 表名 ADD (列说明列表) 例:为test表增加一列Age,用来存放年龄 sql>alter table test add (Age number(3)); 修改基表列定义命令如下: ALTER TABLE 表名 MODIFY (列名 数据类型) 例:将test表的Count列宽度加长为10个字符 sql>alter atble test modify (County char(10)); b、将一张表删除语句的格式如下: DORP TABLE 表名; 例:表删除将同时删除表的数据和表的定义 sql>drop table test c、表空间的创建、删除 六、ORACLE逻辑备份的SH文件 完全备份的SH文件:exp_comp.sh rq=` date +"%m%d" ` su - oracle -c "exp system/manager full=y inctype=complete file=/oracle/export/db_comp$rq.dmp" 累计备份的SH文件:exp_cumu.sh rq=` date +"%m%d" ` su - oracle -c "exp system/manager full=y inctype=cumulative file=/oracle/export/db_cumu$rq.dmp" 增量备份的SH文件: exp_incr.sh rq=` date +"%m%d" ` su - oracle -c "exp system/manager full=y inctype=incremental file=/oracle/export/db_incr$rq.dmp" root用户crontab文件 /var/spool/cron/crontabs/root增加以下内容 0 2 1 * * /oracle/exp_comp.sh 30 2 * * 0-5 /oracle/exp_incr.sh 45 2 * * 6 /oracle/exp_cumu.sh 当然这个时间表可以根据不同的需求来改变的,这只是一个例子。 七、ORACLE 常用的SQL语法和数据对象 一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……); INSERT INTO 表名(字段名1, 字段名2, ……) SELECT (字段名1, 字段名2, ……) FROM 另外的表名; 字符串类型的字段值必须用单引号括起来, 例如: ’GOOD DAY’ 如果字段值里包含单引号’ 需要进行字符串转换, 我们把它替换成两个单引号''. 字符串类型的字段值超过定义的长度会出错, 最好在插入前进行长度校验. 日期字段的字段值可以用当前数据库的系统时间SYSDATE, 精确到秒 或者用字符串转换成日期型函数TO_DATE(‘2001-08-01’,’YYYY-MM-DD’) TO_DATE()还有很多种日期格式, 可以参看ORACLE DOC. 年-月-日 小时:分钟:秒 的格式YYYY-MM-DD HH24:MI:SS INSERT时最大可操作的字符串长度小于等于4000个单字节, 如果要插入更长的字符串, 请考虑字段用CLOB类型, 方法借用ORACLE里自带的DBMS_LOB程序包. INSERT时如果要用到从1开始自动增长的序列号, 应该先建立一个序列号 CREATE SEQUENCE 序列号的名称 (最好是表名+序列号标记) INCREMENT BY 1 START WITH 1 MAXVALUE 99999 CYCLE NOCACHE; 其最大的值按字段的长度来定, 如果定义的自动增长的序列号 NUMBER(6) , 最大值为999999 INSERT 语句插入这个字段值为: 序列号的名称.NEXTVAL 2.DELETE (删除数据表里记录的语句) DELETE FROM表名 WHERE 条件; 注意:删除记录并不能释放ORACLE里被占用的数据块表空间. 它只把那些被删除的数据块标成unused. 如果确实要删除一个大表里的全部记录, 可以用 TRUNCATE 命令, 它可以释放占用的数据块表空间 TRUNCATE TABLE 表名; 此操作不可回退. 3.UPDATE (修改数据表里记录的语句) UPDATE表名 SET 字段名1=值1, 字段名2=值2, …… WHERE 条件; 如果修改的值N没有赋值或定义时, 将把原来的记录内容清为NULL, 最好在修改前进行非空校验; 值N超过定义的长度会出错, 最好在插入前进行长度校验.. 注意事项: A. 以上SQL语句对表都加上了行级锁, 确认完成后, 必须加上事物处理结束的命令 COMMIT 才能正式生效, 否则改变不一定写入数据库里. 如果想撤回这些操作, 可以用命令 ROLLBACK 复原. B. 在运行INSERT, DELETE 和 UPDATE 语句前最好估算一下可能操作的记录范围, 应该把它限定在较小 (一万条记录) 范围内,. 否则ORACLE处理这个事物用到很大的回退段. 程序响应慢甚至失去响应. 如果记录数上十万以上这些操作, 可以把这些SQL语句分段分次完成, 其间加上COMMIT 确认事物处理. 二.数据定义 (DDL) 部分 1.CREATE (创建表, 索引, 视图, 同义词, 过程, 函数, 数据库链接等) ORACLE常用的字段类型有 CHAR 固定长度的字符串 VARCHAR2 可变长度的字符串 NUMBER(M,N) 数字型M是位数总长度, N是小数的长度 DATE 日期类型 创建表时要把较小的不为空的字段放在前面, 可能为空的字段放在后面 创建表时可以用文的字段名, 但最好还是用英文的字段名 创建表时可以给字段加上默认值, 例如 DEFAULT SYSDATE 这样每次插入和修改时, 不用程序操作这个字段都能得到动作的时间 创建表时可以给字段加上约束条件 例如 不允许重复 UNIQUE, 关键字 PRIMARY KEY 2.ALTER (改变表, 索引, 视图等) 改变表的名称 ALTER TABLE 表名1 TO 表名2; 在表的后面增加一个字段 ALTER TABLE表名 ADD 字段名 字段名描述; 修改表里字段的定义描述 ALTER TABLE表名 MODIFY字段名 字段名描述; 给表里的字段加上约束条件 ALTER TABLE 表名 ADD CONSTRAINT 约束名 PRIMARY KEY (字段名); ALTER TABLE 表名 ADD CONSTRAINT 约束名 UNIQUE (字段名); 把表放在或取出数据库的内存区 ALTER TABLE 表名 CACHE; ALTER TABLE 表名 NOCACHE; 3.DROP (删除表, 索引, 视图, 同义词, 过程, 函数, 数据库链接等) 删除表和它所有的约束条件 DROP TABLE 表名 CASCADE CONSTRAINTS; 4.TRUNCATE (清空表里的所有记录, 保留表的结构) TRUNCATE 表名; 三.查询语句 (SELECT) 部分 SELECT字段名1, 字段名2, …… FROM 表名1, [表名2, ……] WHERE 条件; 字段名可以带入函数 例如: COUNT(*), MIN(字段名), MAX(字段名), AVG(字段名), DISTINCT(字段名), TO_CHAR(DATE字段名,'YYYY-MM-DD HH24:MI:SS') NVL(EXPR1, EXPR2)函数 解释: IF EXPR1=NULL RETURN EXPR2 ELSE RETURN EXPR1 DECODE(AA﹐V1﹐R1﹐V2﹐R2....)函数 解释: IF AA=V1 THEN RETURN R1 IF AA=V2 THEN RETURN R2 ..… ELSE RETURN NULL LPAD(char1,n,char2)函数 解释: 字符char1按制定的位数n显示,不足的位数用char2字符串替换左边的空位 字段名之间可以进行算术运算 例如: (字段名1*字段名1)/3 查询语句可以嵌套 例如: SELECT …… FROM (SELECT …… FROM表名1, [表名2, ……] WHERE 条件) WHERE 条件2; 两个查询语句的结果可以做集合操作 例如: 并集UNION(去掉重复记录), 并集UNION ALL(不去掉重复记录), 差集MINUS, 交集INTERSECT 分组查询 SELECT字段名1, 字段名2, …… FROM 表名1, [表名2, ……] GROUP BY字段名1 [HAVING 条件] ; 两个以上表之间的连接查询 SELECT字段名1, 字段名2, …… FROM 表名1, [表名2, ……] WHERE 表名1.字段名 = 表名2. 字段名 [ AND ……] ; SELECT字段名1, 字段名2, …… FROM 表名1, [表名2, ……] WHERE 表名1.字段名 = 表名2. 字段名(+) [ AND ……] ; 有(+)号的字段位置自动补空值 查询结果集的排序操作, 默认的排序是升序ASC, 降序是DESC SELECT字段名1, 字段名2, …… FROM 表名1, [表名2, ……] ORDER BY字段名1, 字段名2 DESC; 字符串模糊比较的方法 INSTR(字段名, ‘字符串’)>0 字段名 LIKE ‘字符串%’ [‘%字符串%’] 每个表都有一个隐含的字段ROWID, 它标记着记录的唯一性. 四.ORACLE里常用的数据对象 (SCHEMA) 1.索引 (INDEX) CREATE INDEX 索引名ON 表名 ( 字段1, [字段2, ……] ); ALTER INDEX 索引名 REBUILD; 一个表的索引最好不要超过三个 (特殊的大表除外), 最好用单字段索引, 结合SQL语句的分析执行情况, 也可以建立多字段的组合索引和基于函数的索引 ORACLE8.1.7字符串可以索引的最大长度为1578 单字节 ORACLE8.0.6字符串可以索引的最大长度为758 单字节 2.视图 (VIEW) CREATE VIEW 视图名AS SELECT …. FROM …..; ALTER VIEW视图名 COMPILE; 视图仅是一个SQL查询语句, 它可以把表之间复杂的关系简洁化. 3.同义词 (SYNONMY) CREATE SYNONYM同义词名FOR 表名; CREATE SYNONYM同义词名FOR 表名@数据库链接名; 4.数据库链接 (DATABASE LINK) CREATE DATABASE LINK数据库链接名CONNECT TO 用户名 IDENTIFIED BY 密码 USING ‘数据库连接字符串’; 数据库连接字符串可以用NET8 EASY CONFIG或者直接修改TNSNAMES.ORA里定义. 数据库参数global_name=true时要求数据库链接名称跟远端数据库名称一样 数据库全局名称可以用以下命令查出 SELECT * FROM GLOBAL_NAME; 查询远端数据库里的表 SELECT …… FROM 表名@数据库链接名; 五.权限管理 (DCL) 语句 1.GRANT 赋于权限 常用的系统权限集合有以下三个: CONNECT(基本的连接), RESOURCE(程序开发), DBA(数据库管理) 常用的数据对象权限有以下五个: ALL ON 数据对象名, SELECT ON 数据对象名, UPDATE ON 数据对象名, DELETE ON 数据对象名, INSERT ON 数据对象名, ALTER ON 数据对象名 GRANT CONNECT, RESOURCE TO 用户名; GRANT SELECT ON 表名 TO 用户名; GRANT SELECT, INSERT, DELETE ON表名 TO 用户名1, 用户名2; 2.REVOKE 回收权限 REVOKE CONNECT, RESOURCE FROM 用户名; REVOKE SELECT ON 表名 FROM 用户名; REVOKE SELECT, INSERT, DELETE ON表名 FROM 用户名1, 用户名2; 查询数据库第63号错误: select orgaddr,destaddr from sm_histable0116 where error_code='63'; 查询数据库开户用户最大提交和最大下发数: select MSISDN,TCOS,OCOS from ms_usertable; 查询数据库各种错误代码的总和: select error_code,count(*) from sm_histable0513 group by error_code order by error_code; 查询报表数据库话单统计种类查询。 select sum(Successcount) from tbl_MiddleMt0411 where ServiceType2=111 select sum(successcount),servicetype from tbl_middlemt0411 group by servicetype 原文地址:http://www.cnoug.org/viewthread.php?tid=60293 //创建一个控制文件命令到跟踪文件 alter database backup controlfile to trace; //增加一个新的日志文件组的语句 connect internal as sysdba alter database add logfile group 4 (’/db01/oracle/CC1/log_1c.dbf’, ’/db02/oracle/CC1/log_2c.dbf’) size 5M; alter database add logfile member ’/db03/oracle/CC1/log_3c.dbf’ to group 4; //在Server Manager上MOUNT并打开一个数据库: connect internal as sysdba startup mount ORA1 exclusive; alter database open; //生成数据字典 @catalog @catproc //在init.ora 备份数据库的位置 log_archive_dest_1 = ’/db00/arch’ log_archive_dest_state_1 = enable log_archive_dest_2 = "service=stby.world mandatory reopen=60" log_archive_dest_state_2 = enable //对用户的表空间的指定和管理相关的语句 create user USERNAME identified by PASSWORD default tablespace TABLESPACE_NAME; alter user USERNAME default tablespace TABLESPACE_NAME; alter user SYSTEM quota 0 on SYSTEM; alter user SYSTEM quota 50M on TOOLS; create user USERNAME identified by PASSWORD default tablespace DATA temporary tablespace TEMP; alter user USERNAME temporary tablespace TEMP; //重新指定一个数据文件的大小 : alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 200M; //创建一个自动扩展的数据文件: create tablespace DATA datafile ’/db05/oracle/CC1/data01.dbf’ size 200M autoextend ON next 10M maxsize 250M; //在表空间上增加一个自动扩展的数据文件: alter tablespace DATA add datafile ’/db05/oracle/CC1/data02.dbf’ size 50M autoextend ON maxsize 300M; //修改参数: alter database datafile ’/db05/oracle/CC1/data01.dbf’ autoextend ON maxsize 300M; //在数据文件移动期间重新命名: alter database rename file ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter tablespace DATA rename datafile ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter database rename file ’/db05/oracle/CC1/redo01CC1.dbf’ to ’/db02/oracle/CC1/redo01CC1.dbf’; alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 80M; //创建和使用角色: create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; grant APPLICATION_USER to username; //回滚段的管理 create rollback segment SEGMENT_NAME tablespace RBS; alter rollback segment SEGMENT_NAME offline; drop rollback segment SEGMENT_NAME; alter rollback segment SEGMENT_NAME online; //回滚段上指定事务 commit; set transaction use rollback segment ROLL_BATCH; insert into TABLE_NAME select * from DATA_LOAD_TABLE; commit; //查询回滚段的 大小和优化参数 select * from DBA_SEGMENTS where Segment_Type = ’ROLLBACK’; select N.Name, /* rollback segment name */ S.OptSize /* rollback segment OPTIMAL size */ from V$ROLLNAME N, V$ROLLSTAT S where N.USN=S.USN; //回收回滚段 alter rollback segment R1 shrink to 15M; alter rollback segment R1 shrink; //例子 set transaction use rollback segment SEGMENT_NAME alter tablespace RBS default storage (initial 125K next 125K minextents 18 maxextents 249) create rollback segment R4 tablespace RBS storage (optimal 2250K); alter rollback segment R4 online; select Sessions_Highwater from V$LICENSE; grant select on EMPLOYEE to PUBLIC; //用户和角色 create role ACCOUNT_CREATOR; grant CREATE SESSION, CREATE USER, ALTER USER to ACCOUNT_CREATOR; alter user THUMPER default role NONE; alter user THUMPER default role CONNECT; alter user THUMPER default role all except ACCOUNT_CREATOR; alter profile DEFAULT limit idle_time 60; create profile LIMITED_PROFILE limit FAILED_LOGIN_ATTEMPTS 5; create user JANE identified by EYRE profile LIMITED_PROFILE; grant CREATE SESSION to JANE; alter user JANE account unlock; alter user JANE account lock; alter profile LIMITED_PROFILE limit PASSWORD_LIFE_TIME 30; alter user jane password expire; //创建操作系统用户 REM Creating OPS$ accounts create user OPS$FARMER identified by SOME_PASSWORD default tablespace USERS temporary tablespace TEMP; REM Using identified externally create user OPS$FARMER identified externally default tablespace USERS temporary tablespace TEMP; //执行ORAPWD ORAPWD FILE=filename PASSWORD=password ENTRIES=max_users create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; create role DATA_ENTRY_CLERK; grant select, insert on THUMPER.EMPLOYEE to DATA_ENTRY_CLERK; grant select, insert on THUMPER.TIME_CARDS to DATA_ENTRY_CLERK; grant select, insert on THUMPER.DEPARTMENT to DATA_ENTRY_CLERK; grant APPLICATION_USER to DATA_ENTRY_CLERK; grant DATA_ENTRY_CLERK to MCGREGOR; grant DATA_ENTRY_CLERK to BPOTTER with admin option; //设置角色 set role DATA_ENTRY_CLERK; set role NONE; //回收权利: revoke delete on EMPLOYEE from PETER; revoke all on EMPLOYEE from MCGREGOR; //回收角色: revoke ACCOUNT_CREATOR from HELPDESK; drop user USERNAME cascade; grant SELECT on EMPLOYEE to MCGREGOR with grant option; grant SELECT on THUMPER.EMPLOYEE to BPOTTER with grant option; revoke SELECT on EMPLOYEE from MCGREGOR; create user MCGREGOR identified by VALUES ’1A2DD3CCEE354DFA’; alter user OPS$FARMER identified by VALUES ’no way’; //备份与恢复 使用 export 程序 exp system/manager file=expdat.dmp compress=Y owner=(HR,THUMPER) exp system/manager file=hr.dmp owner=HR indexes=Y compress=Y imp system/manager file=hr.dmp full=Y buffer=64000 commit=Y //备份表 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES) //备份分区 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES:Part1) //输入例子 imp system/manager file=expdat.dmp imp system/manager file=expdat.dmp buffer=64000 commit=Y exp system/manager file=thumper.dat owner=thumper grants=N indexes=Y compress=Y rows=Y imp system/manager file=thumper.dat FROMUSER=thumper TOUSER=flower rows=Y indexes=Y imp system/manager file=expdat.dmp full=Y commit=Y buffer=64000 imp system/manager file=expdat.dmp ignore=N rows=N commit=Y buffer=64000 //使用操作系统备份命令 REM TAR examples tar -cvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 tar -rvf /dev/rmt/0hc /orasw/app/oracle/CC1/pfile/initcc1.ora tar -rvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 /orasw/app/oracle/CC1/pfile/initcc1.ora //离线备份的shell脚本 ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database archivelog; archive log start; alter database open; //在Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database noarchivelog; alter database open; select Name, Value from V$PARAMETER where Name like ’log_archive%’; //联机备份的脚本 # # Sample Hot Backup Script for a UNIX File System database # # Set up environment variables: ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <INDEXES tablespace REM alter tablespace INDEXES begin backup; !tar -rvf /dev/rmt/0hc /db04/oracle/CC1/indexes01.dbf alter tablespace INDEXES end backup; REM REM 备份 TEMP tablespace REM alter tablespace TEMP begin backup; !tar -rvf /dev/rmt/0hc /db05/oracle/CC1/temp01.dbf alter tablespace TEMP end backup; REM REM Follow the same pattern to back up the rest REM of the tablespaces. REM REM REM Step 2. 备份归档日志文件. archive log stop REM REM Exit Server Manager, using the indicator set earlier. exit EOFarch1 # # Record which files are in the destination directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Now go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl <Server Manager using the indicator set earlier. exit EOFarch1 # # Step 2: Record which files are in the destination # directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Step 3: Go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl < create catalog tablespace rcvcat; // 在(NT)下创建恢复目录 RMAN> create catalog tablespace "RCVCAT"; //连接描述符范例 (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=HQ) (PORT=1521)) (CONNECT DATA= (SID=loc))) // listener.ora 的条目entry // listener.ora 的条目entry LISTENER = (ADDRESS_LIST = (ADDRESS= (PROTOCOL=IPC) (KEY= loc.world) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = loc) (ORACLE_HOME = /orasw/app/oracle/product/8.1.5.1) ) ) // tnsnames.ora 的条目 LOC= (DESCRIPTION= (ADDRESS = (PROTOCOL = TCP) (HOST = HQ) (PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = loc) (INSTANCE_NAME = loc) ) ) //连接参数的设置(sql*net) LOC =(DESCRIPTION= (ADDRESS= (COMMUNITY=TCP.HQ.COMPANY) (PROTOCOL=TCP) (HOST=HQ) (PORT=1521)) (CONNECT DATA= (SID=loc))) //参数文件配置范例 // tnsnames.ora HQ =(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=HQ) (PORT=1521)) (CONNECT DATA= (SID=loc))) // listener.ora LISTENER = (ADDRESS_LIST = (ADDRESS= (PROTOCOL=IPC) (KEY= loc) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = loc) (ORACLE_HOME = /orasw/app/oracle/product/8.1.5.1) ) ) // Oracle8I tnsnames.ora LOC= (DESCRIPTION= (ADDRESS = (PROTOCOL = TCP) (HOST = HQ) (PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = loc) (INSTANCE_NAME = loc) ) ) //使用 COPY 实现数据库之间的复制 copy from remote_username/remote_password@service_name to username/password@service_name [append|create|insert|replace] TABLE_NAME using subquery; REM COPY example set copycommit 1 set arraysize 1000 copy from HR/PUFFINSTUFF@loc - create EMPLOYEE - using - select * from EMPLOYEE //监视器的管理 lsnrctl start lsnrctl start my_lsnr lsnrctl status lsnrctl status hq 检查监视器的进程 ps -ef | grep tnslsnr //在 lsnrctl 内停止监视器 set password lsnr_password stop //在lsnrctl 内列出所有的服务 set password lsnr_password services //启动或停止一个NT的listener net start OracleTNSListener net stop OracleTNSListener // tnsnames.ora 文件的内容 fld1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = server1.fld.com)(PORT = 1521)) ) (CONNECT_DATA = (SID = fld1) ) ) //操作系统网络的管理 telnet host_name ping host_name /etc/hosts 文件 130.110.238.109 nmhost 130.110.238.101 txhost 130.110.238.102 azhost arizona //oratab 表项 loc:/orasw/app/oracle/product/8.1.5.1:Y cc1:/orasw/app/oracle/product/8.1.5.1:N old:/orasw/app/oracle/product/8.1.5.0:Y //创建一个控制文件命令到跟踪文件 alter database backup controlfile to trace; //增加一个新的日志文件组的语句 connect internal as sysdba alter database add logfile group 4 (’/db01/oracle/CC1/log_1c.dbf’, ’/db02/oracle/CC1/log_2c.dbf’) size 5M; alter database add logfile member ’/db03/oracle/CC1/log_3c.dbf’ to group 4; //在Server Manager上MOUNT并打开一个数据库: connect internal as sysdba startup mount ORA1 exclusive; alter database open; //生成数据字典 @catalog @catproc //在init.ora 备份数据库的位置 log_archive_dest_1 = ’/db00/arch’ log_archive_dest_state_1 = enable log_archive_dest_2 = "service=stby.world mandatory reopen=60" log_archive_dest_state_2 = enable //对用户的表空间的指定和管理相关的语句 create user USERNAME identified by PASSWORD default tablespace TABLESPACE_NAME; alter user USERNAME default tablespace TABLESPACE_NAME; alter user SYSTEM quota 0 on SYSTEM; alter user SYSTEM quota 50M on TOOLS; create user USERNAME identified by PASSWORD default tablespace DATA temporary tablespace TEMP; alter user USERNAME temporary tablespace TEMP; //重新指定一个数据文件的大小 : alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 200M; //创建一个自动扩展的数据文件: create tablespace DATA datafile ’/db05/oracle/CC1/data01.dbf’ size 200M autoextend ON next 10M maxsize 250M; //在表空间上增加一个自动扩展的数据文件: alter tablespace DATA add datafile ’/db05/oracle/CC1/data02.dbf’ size 50M autoextend ON maxsize 300M; //修改参数: alter database datafile ’/db05/oracle/CC1/data01.dbf’ autoextend ON maxsize 300M; //在数据文件移动期间重新命名: alter database rename file ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter tablespace DATA rename datafile ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter database rename file ’/db05/oracle/CC1/redo01CC1.dbf’ to ’/db02/oracle/CC1/redo01CC1.dbf’; alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 80M; //创建和使用角色: create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; grant APPLICATION_USER to username; //回滚段的管理 create rollback segment SEGMENT_NAME tablespace RBS; alter rollback segment SEGMENT_NAME offline; drop rollback segment SEGMENT_NAME; alter rollback segment SEGMENT_NAME online; //回滚段上指定事务 commit; set transaction use rollback segment ROLL_BATCH; insert into TABLE_NAME select * from DATA_LOAD_TABLE; commit; //查询回滚段的 大小和优化参数 select * from DBA_SEGMENTS where Segment_Type = ’ROLLBACK’; select N.Name, /* rollback segment name */ S.OptSize /* rollback segment OPTIMAL size */ from V$ROLLNAME N, V$ROLLSTAT S where N.USN=S.USN; //回收回滚段 alter rollback segment R1 shrink to 15M; alter rollback segment R1 shrink; //例子 set transaction use rollback segment SEGMENT_NAME alter tablespace RBS default storage (initial 125K next 125K minextents 18 maxextents 249) create rollback segment R4 tablespace RBS storage (optimal 2250K); alter rollback segment R4 online; select Sessions_Highwater from V$LICENSE; grant select on EMPLOYEE to PUBLIC; //用户和角色 create role ACCOUNT_CREATOR; grant CREATE SESSION, CREATE USER, ALTER USER to ACCOUNT_CREATOR; alter user THUMPER default role NONE; alter user THUMPER default role CONNECT; alter user THUMPER default role all except ACCOUNT_CREATOR; alter profile DEFAULT limit idle_time 60; create profile LIMITED_PROFILE limit FAILED_LOGIN_ATTEMPTS 5; create user JANE identified by EYRE profile LIMITED_PROFILE; grant CREATE SESSION to JANE; alter user JANE account unlock; alter user JANE account lock; alter profile LIMITED_PROFILE limit PASSWORD_LIFE_TIME 30; alter user jane password expire; //创建操作系统用户 REM Creating OPS$ accounts create user OPS$FARMER identified by SOME_PASSWORD default tablespace USERS temporary tablespace TEMP; REM Using identified externally create user OPS$FARMER identified externally default tablespace USERS temporary tablespace TEMP; //执行ORAPWD ORAPWD FILE=filename PASSWORD=password ENTRIES=max_users create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; create role DATA_ENTRY_CLERK; grant select, insert on THUMPER.EMPLOYEE to DATA_ENTRY_CLERK; grant select, insert on THUMPER.TIME_CARDS to DATA_ENTRY_CLERK; grant select, insert on THUMPER.DEPARTMENT to DATA_ENTRY_CLERK; grant APPLICATION_USER to DATA_ENTRY_CLERK; grant DATA_ENTRY_CLERK to MCGREGOR; grant DATA_ENTRY_CLERK to BPOTTER with admin option; //设置角色 set role DATA_ENTRY_CLERK; set role NONE; //回收权利: revoke delete on EMPLOYEE from PETER; revoke all on EMPLOYEE from MCGREGOR; //回收角色: revoke ACCOUNT_CREATOR from HELPDESK; drop user USERNAME cascade; grant SELECT on EMPLOYEE to MCGREGOR with grant option; grant SELECT on THUMPER.EMPLOYEE to BPOTTER with grant option; revoke SELECT on EMPLOYEE from MCGREGOR; create user MCGREGOR identified by VALUES ’1A2DD3CCEE354DFA’; alter user OPS$FARMER identified by VALUES ’no way’; //备份与恢复 使用 export 程序 exp system/manager file=expdat.dmp compress=Y owner=(HR,THUMPER) exp system/manager file=hr.dmp owner=HR indexes=Y compress=Y imp system/manager file=hr.dmp full=Y buffer=64000 commit=Y //备份表 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES) //备份分区 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES:Part1) //输入例子 imp system/manager file=expdat.dmp imp system/manager file=expdat.dmp buffer=64000 commit=Y exp system/manager file=thumper.dat owner=thumper grants=N indexes=Y compress=Y rows=Y imp system/manager file=thumper.dat FROMUSER=thumper TOUSER=flower rows=Y indexes=Y imp system/manager file=expdat.dmp full=Y commit=Y buffer=64000 imp system/manager file=expdat.dmp ignore=N rows=N commit=Y buffer=64000 //使用操作系统备份命令 REM TAR examples tar -cvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 tar -rvf /dev/rmt/0hc /orasw/app/oracle/CC1/pfile/initcc1.ora tar -rvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 /orasw/app/oracle/CC1/pfile/initcc1.ora //离线备份的shell脚本 ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database archivelog; archive log start; alter database open; //在Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database noarchivelog; alter database open; select Name, Value from V$PARAMETER where Name like ’log_archive%’; //联机备份的脚本 # # Sample Hot Backup Script for a UNIX File System database # # Set up environment variables: ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <INDEXES tablespace REM alter tablespace INDEXES begin backup; !tar -rvf /dev/rmt/0hc /db04/oracle/CC1/indexes01.dbf alter tablespace INDEXES end backup; REM REM 备份 TEMP tablespace REM alter tablespace TEMP begin backup; !tar -rvf /dev/rmt/0hc /db05/oracle/CC1/temp01.dbf alter tablespace TEMP end backup; REM REM Follow the same pattern to back up the rest REM of the tablespaces. REM REM REM Step 2. 备份归档日志文件. archive log stop REM REM Exit Server Manager, using the indicator set earlier. exit EOFarch1 # # Record which files are in the destination directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Now go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl <Server Manager using the indicator set earlier. exit EOFarch1 # # Step 2: Record which files are in the destination # directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Step 3: Go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl < create catalog tablespace rcvcat; // 在(NT)下创建恢复目录 RMAN> create catalog tablespace "RCVCAT"; //连接描述符范例 (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=HQ) (PORT=1521)) (CONNECT DATA= (SID=loc))) // listener.ora 的条目entry //创建一个控制文件命令到跟踪文件 alter database backup controlfile to trace; //增加一个新的日志文件组的语句 connect internal as sysdba alter database add logfile group 4 (’/db01/oracle/CC1/log_1c.dbf’, ’/db02/oracle/CC1/log_2c.dbf’) size 5M; alter database add logfile member ’/db03/oracle/CC1/log_3c.dbf’ to group 4; //在Server Manager上MOUNT并打开一个数据库: connect internal as sysdba startup mount ORA1 exclusive; alter database open; //生成数据字典 @catalog @catproc //在init.ora 备份数据库的位置 log_archive_dest_1 = ’/db00/arch’ log_archive_dest_state_1 = enable log_archive_dest_2 = "service=stby.world mandatory reopen=60" log_archive_dest_state_2 = enable //对用户的表空间的指定和管理相关的语句 create user USERNAME identified by PASSWORD default tablespace TABLESPACE_NAME; alter user USERNAME default tablespace TABLESPACE_NAME; alter user SYSTEM quota 0 on SYSTEM; alter user SYSTEM quota 50M on TOOLS; create user USERNAME identified by PASSWORD default tablespace DATA temporary tablespace TEMP; alter user USERNAME temporary tablespace TEMP; //重新指定一个数据文件的大小 : alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 200M; //创建一个自动扩展的数据文件: create tablespace DATA datafile ’/db05/oracle/CC1/data01.dbf’ size 200M autoextend ON next 10M maxsize 250M; //在表空间上增加一个自动扩展的数据文件: alter tablespace DATA add datafile ’/db05/oracle/CC1/data02.dbf’ size 50M autoextend ON maxsize 300M; //修改参数: alter database datafile ’/db05/oracle/CC1/data01.dbf’ autoextend ON maxsize 300M; //在数据文件移动期间重新命名: alter database rename file ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter tablespace DATA rename datafile ’/db01/oracle/CC1/data01.dbf’ to ’/db02/oracle/CC1/data01.dbf’; alter database rename file ’/db05/oracle/CC1/redo01CC1.dbf’ to ’/db02/oracle/CC1/redo01CC1.dbf’; alter database datafile ’/db05/oracle/CC1/data01.dbf’ resize 80M; //创建和使用角色: create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; grant APPLICATION_USER to username; //回滚段的管理 create rollback segment SEGMENT_NAME tablespace RBS; alter rollback segment SEGMENT_NAME offline; drop rollback segment SEGMENT_NAME; alter rollback segment SEGMENT_NAME online; //回滚段上指定事务 commit; set transaction use rollback segment ROLL_BATCH; insert into TABLE_NAME select * from DATA_LOAD_TABLE; commit; //查询回滚段的 大小和优化参数 select * from DBA_SEGMENTS where Segment_Type = ’ROLLBACK’; select N.Name, /* rollback segment name */ S.OptSize /* rollback segment OPTIMAL size */ from V$ROLLNAME N, V$ROLLSTAT S where N.USN=S.USN; //回收回滚段 alter rollback segment R1 shrink to 15M; alter rollback segment R1 shrink; //例子 set transaction use rollback segment SEGMENT_NAME alter tablespace RBS default storage (initial 125K next 125K minextents 18 maxextents 249) create rollback segment R4 tablespace RBS storage (optimal 2250K); alter rollback segment R4 online; select Sessions_Highwater from V$LICENSE; grant select on EMPLOYEE to PUBLIC; //用户和角色 create role ACCOUNT_CREATOR; grant CREATE SESSION, CREATE USER, ALTER USER to ACCOUNT_CREATOR; alter user THUMPER default role NONE; alter user THUMPER default role CONNECT; alter user THUMPER default role all except ACCOUNT_CREATOR; alter profile DEFAULT limit idle_time 60; create profile LIMITED_PROFILE limit FAILED_LOGIN_ATTEMPTS 5; create user JANE identified by EYRE profile LIMITED_PROFILE; grant CREATE SESSION to JANE; alter user JANE account unlock; alter user JANE account lock; alter profile LIMITED_PROFILE limit PASSWORD_LIFE_TIME 30; alter user jane password expire; //创建操作系统用户 REM Creating OPS$ accounts create user OPS$FARMER identified by SOME_PASSWORD default tablespace USERS temporary tablespace TEMP; REM Using identified externally create user OPS$FARMER identified externally default tablespace USERS temporary tablespace TEMP; //执行ORAPWD ORAPWD FILE=filename PASSWORD=password ENTRIES=max_users create role APPLICATION_USER; grant CREATE SESSION to APPLICATION_USER; create role DATA_ENTRY_CLERK; grant select, insert on THUMPER.EMPLOYEE to DATA_ENTRY_CLERK; grant select, insert on THUMPER.TIME_CARDS to DATA_ENTRY_CLERK; grant select, insert on THUMPER.DEPARTMENT to DATA_ENTRY_CLERK; grant APPLICATION_USER to DATA_ENTRY_CLERK; grant DATA_ENTRY_CLERK to MCGREGOR; grant DATA_ENTRY_CLERK to BPOTTER with admin option; //设置角色 set role DATA_ENTRY_CLERK; set role NONE; //回收权利: revoke delete on EMPLOYEE from PETER; revoke all on EMPLOYEE from MCGREGOR; //回收角色: revoke ACCOUNT_CREATOR from HELPDESK; drop user USERNAME cascade; grant SELECT on EMPLOYEE to MCGREGOR with grant option; grant SELECT on THUMPER.EMPLOYEE to BPOTTER with grant option; revoke SELECT on EMPLOYEE from MCGREGOR; create user MCGREGOR identified by VALUES ’1A2DD3CCEE354DFA’; alter user OPS$FARMER identified by VALUES ’no way’; //备份与恢复 使用 export 程序 exp system/manager file=expdat.dmp compress=Y owner=(HR,THUMPER) exp system/manager file=hr.dmp owner=HR indexes=Y compress=Y imp system/manager file=hr.dmp full=Y buffer=64000 commit=Y //备份表 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES) //备份分区 exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES:Part1) //输入例子 imp system/manager file=expdat.dmp imp system/manager file=expdat.dmp buffer=64000 commit=Y exp system/manager file=thumper.dat owner=thumper grants=N indexes=Y compress=Y rows=Y imp system/manager file=thumper.dat FROMUSER=thumper TOUSER=flower rows=Y indexes=Y imp system/manager file=expdat.dmp full=Y commit=Y buffer=64000 imp system/manager file=expdat.dmp ignore=N rows=N commit=Y buffer=64000 //使用操作系统备份命令 REM TAR examples tar -cvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 tar -rvf /dev/rmt/0hc /orasw/app/oracle/CC1/pfile/initcc1.ora tar -rvf /dev/rmt/0hc /db0[1-9]/oracle/CC1 /orasw/app/oracle/CC1/pfile/initcc1.ora //离线备份的shell脚本 ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database archivelog; archive log start; alter database open; //在Server Manager上设置为archivelog mode: connect internal as sysdba startup mount cc1; alter database noarchivelog; alter database open; select Name, Value from V$PARAMETER where Name like ’log_archive%’; //联机备份的脚本 # # Sample Hot Backup Script for a UNIX File System database # # Set up environment variables: ORACLE_SID=cc1; export ORACLE_SID ORAENV_ASK=NO; export ORAENV_ASK . oraenv svrmgrl <INDEXES tablespace REM alter tablespace INDEXES begin backup; !tar -rvf /dev/rmt/0hc /db04/oracle/CC1/indexes01.dbf alter tablespace INDEXES end backup; REM REM 备份 TEMP tablespace REM alter tablespace TEMP begin backup; !tar -rvf /dev/rmt/0hc /db05/oracle/CC1/temp01.dbf alter tablespace TEMP end backup; REM REM Follow the same pattern to back up the rest REM of the tablespaces. REM REM REM Step 2. 备份归档日志文件. archive log stop REM REM Exit Server Manager, using the indicator set earlier. exit EOFarch1 # # Record which files are in the destination directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Now go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl <Server Manager using the indicator set earlier. exit EOFarch1 # # Step 2: Record which files are in the destination # directory. # Do this by setting an environment variable that is # equal to the directory listing for the destination # directory. # For this example, the log_archive_dest is # /db01/oracle/arch/CC1. # FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES # # Step 3: Go back into Server Manager and restart the # archiving process. Set an indicator (called EOFarch2 # in this example). # svrmgrl < create catalog tablespace rcvcat; // 在(NT)下创建恢复目录 RMAN> create catalog tablespace "RCVCAT"; //连接描述符范例 (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=HQ) (PORT=1521)) (CONNECT DATA= (SID=loc))) // listener.ora 的条目entry ……………………………………………………………………………………

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧