Month: August 2014
Linux Administration
Important commands for NFS
showmount -e : Shows the available shares on your local machine
showmount -e <server-ip or hostname>: Lists the available shares at the remote server
showmount -d : Lists all the sub directories
exportfs -v : Displays a list of shares files and options on a server
exportfs -a : Exports all shares listed in /etc/exports, or given name
exportfs -u : Unexports all shares listed in /etc/exports, or given name
exportfs -r : Refresh the server’s list after modifying /etc/exports
NFS server configuration commands:
#rpm –qa | grep nfs
#ifconfig
#pwd
[root@nfsserver ~]# mkdir /nfsshare
#cd nfsshare
#touch f1 f2 f3
#vi /etc/exports
Edit the file with line:
/root/nfsshare client’s ip address(rw,sync,no_root_squash)
Save file.
NFS Options
Some other options we can use in “/etc/exports” file for file sharing is as follows.
- ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
- rw: This option allows the client server to both read and write access within the shared directory.
- sync: Sync confirms requests to the shared directory only once the changes have been committed.
- no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
- no_root_squash: This phrase allows root to connect to the designated directory.
#service nfs restart
Setting Up the NFS Client
After configuring the NFS server, we need to mount that shared directory or partition in the client server.
Mount Shared Directories on NFS Client
Now at the NFS client end, we need to mount that directory in our server to access it locally. To do so, first we need to find out that shares available on the remote server or NFS Server
root@nfsclient ~]# showmount -e 192.168.0.100
Export list for 192.168.0.100:/nfsshare 192.168.0.101
Note: here 192.168.0.100 is server’s ip address while 192.168.0.101 is client’s ip address.
Above command shows that a directory named “nfsshare” is available at “192.168.0.100” to share with your server.
Mount Shared NFS Directory
To mount that shared NFS directory we can use following mount command.
root@nfsclient ~]# mount -t nfs 192.168.0.100:/nfsshare /mnt/nfsshare
The above command will mount that shared directory in “/mnt/nfsshare” on the client server. You can verify it following command.
[root@nfsclient ~]# mount | grep nfs sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)nfsd on /proc/fs/nfsd type nfsd (rw)192.168.0.100:/nfsshare on /mnt type nfs (rw,addr=192.168.0.100)
The above mount command mounted the nfs shared directory on to nfs client temporarily, to mount an NFS directory permanently on your system across the reboots, we need to make an entry in “/etc/fstab“.
Testing NFS mount:
#cd /mnt/nfsshare
#ls
f1 f2 f3
Removing the NFS Mount
If you want to unmount that shared directory from your server after you are done with the file sharing, you can simply unmount that particular directory with “umount” command. See this example below.
root@nfsclient ~]# umount /mnt/nfsshare
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
ASP.NET – Directives
ASP.NET – Directives
- Net directives are instructions to specify optional settings, such as registering a custom control and page language. These settings describe how the web forms (.aspx) or user controls (.ascx) pages are processed by the .Net framework.
- The syntax for declaring a directive is:
<%@ directive_name attribute=value [attribute=value] %>
- The Application Directive
- The Application directive defines application-specific attributes. It is provided at the top of the aspx file.
- The basic syntax for a sample Application directive is:
<%@ Application Language=”C#” %>
- The attributes of the Application directive are:
Attributes |
Description |
Inherits |
the name of the class from which to inherit |
Description |
text description of the application. Parsers and compilers ignore this |
Language |
language used in code blocks |
- The Assembly Directive
- The Assembly directive links an assembly to the page or the application at parse time.
- This could appear either in the asax file for application-wide linking or in the page file or a user control file for linking to a page or user control.
- The basic syntax for a sample Assembly directive is:
<%@ Assembly Name =”myassembly” %>
- The attributes of the Assembly directive are:
Attributes |
Description |
Name |
the name of the assembly to be linked |
Src |
the path to the source file to be linked and compiled dynamically |
- The Control Directive
- The Control directive is used with the user controls and appears in the user control (.ascx) files.
- The basic syntax for a sample Control directive is:
<%@ Control Language=”C#” EnableViewState=”false” %>
- The attributes of the Control directive are:
Attributes |
Description |
AutoEventWireup |
the Boolean value that enables or disables automatic association of events to handlers |
ClassName |
file name for the control |
Debug |
the Boolean value that enables or disables compiling with debug symbols |
Description |
text description of the control page, ignored by compiler |
EnableViewState |
the Boolean value that indicates whether view state is maintained across page requests |
Explicit |
for VB language, tells the compiler to use Option Explicit mode |
Inherits |
the class from which the control page inherits |
Language |
language for code and script |
Src |
the filename for the code-behind class |
Strict |
for VB language, tells the compiler to use the Option Strict mode |
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
Normalization
NORMALIZATION
Second Normal Form (2NF)
- A relation is said to be in 2NF f if it is already in 1NF and each and every attribute fully depends on the primary key of the relation. Speaking inversely, if a table has some attributes which is not dependant on the primary key of that table, and then it is not in 2NF.
- Emp-Id is the primary key of the above relation. Emp-Name, Month, Sales and Bank-Name all depend upon Emp-Id. But the attribute Bank-Name depends on Bank-Id, which is not the primary key of the table.
- So the table is in 1NF, but not in 2NF. If this position can be removed into another related relation, it would come to 2NF.
Emp-Id |
Emp-Name |
Month |
Sales |
Bank-Id |
E01 |
AA |
JAN |
1000 |
B01 |
E01 |
AA |
FEB |
1200 |
B01 |
E01 |
AA |
MAR |
850 |
B01 |
E02 |
BB |
JAN |
2200 |
B02 |
E02 |
BB |
FEB |
2500 |
B02 |
E03 |
CC |
JAN |
1700 |
B01 |
E03 |
CC |
FEB |
1800 |
B01 |
E03 |
CC |
MAR |
1850 |
B01 |
E03 |
CC |
APR |
1726 |
B01 |
Bank-Id |
Bank-Name |
B01 |
SBI |
B02 |
UTI |
- After removing the portion into another relation we store lesser amount of data in two relations without any loss information. There is also a significant reduction in redundancy.
Third Normal Form (3NF)
- A relation is said to be in 3NF, if it is already in 2NF and there exists notransitive dependency in that relation.
- Speaking inversely, if a table contains transitive dependency, then it is not in 3NF, and the table must be split to bring it into 3NF.
A → B [B depends on A]
And
B → C [C depends on B]
Then we may derive
A → C[C depends on A]
Such derived dependencies hold well in most of the situations. For example if we have
Roll → Marks
And
Marks → Grade
Then we may safely derive
Roll → Grade.
- This third dependency was not originally specified but we have derived it.
- The derived dependency is called a transitive dependency when such dependency becomes improbable. For example we have been given
Roll → City
And
City → STDCode
If we try to derive Roll → STDCode it becomes a transitive dependency, because obviously the STDCode of a city cannot depend on the roll number issued by a school or college. In such a case the relation should be broken into two, each containing one of these two dependencies:
Roll → City
And
City → STD code
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
VIRTUAL FUNCTIONS AND POLYMORPHISM
For the students of FYBSc (IT), SYBSc (CS), SYBCA
VIRTUAL FUNCTIONS AND POLYMORPHISM
- The wordpolymorphism means having many forms and it occurs when there is a hierarchy of classes and they are related by inheritance.
- C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
- Consider the following example where a base class has been derived by other two classes:
include <iostream>
class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{ width = a;
height = b; }
int area()
{ cout << “Parent class area :” <<endl;
return 0; }};
class Rectangle: public Shape{
public:
Rectangle( int a=0, int b=0):Shape(a, b) { }
int area ()
{ cout << “Rectangle class area :” <<endl;
return (width * height); }};
class Triangle: public Shape{
public:
Triangle( int a=0, int b=0):Shape(a, b) { }
int area ()
{ cout << “Triangle class area :” <<endl;
return (width * height / 2); }};
// Main function for the program
void main( )
{
Shape *shape;
Rectangle rec(10,7);
Triangle tri(10,5);
// store the address of Rectangle
shape = &rec;
// call rectangle area.
shape->area();
// store the address of Triangle
shape = &tri;
// call triangle area.
shape->area(); }
When the above code is compiled and executed, it produces the following result:
Parent class areaParent class area
- The reason for the incorrect output is that the call of the function area() is being set once by the compiler as the version defined in the base class. This is calledstatic resolution of the function call, or static linkage – the function call is fixed before the program is executed.
- This is also sometimes called early bindingbecause the area() function is set during the compilation of the program.
- The declaration of area() in the Shape class with the keywordvirtual as follows –
class Shape {
protected:
int width, height;
public:
Shape( int a=0, int b=0)
{ width = a;
height = b; }
virtual int area()
{ cout << “Parent class area :” <<endl;
return 0; }};
After this slight modification, when the previous example code is compiled and executed, it produces the following result:
Rectangle class area
Triangle class area
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
ASP.NET CORE SERVICES
- NET CORE SERVICES
- It includes features, such as output caching and session-state storage. The benefits of the net core services are as follows:
- Refactoring of web.config file: specifies that in this version of .net, the most of the configuration elements of the web.config file have been placed to the machine.config file. This shows that the web.config file in this new version of asp.net is either empty or consists of some of the basic code, which specifies the version of the .net framework the application is targeting.
- Output caching: enables to configure one or more output cache providers. The output caching feature in NET enables the developers to store the generated output of controls and HTTP responses in the memory. This is very helpful as in case of subsequent web requests, the content can be retrieved from the output cache.
- Auto-start web applications: it provides a better way for starting an NET application, and accepting HTTP requests. In the earlier versions of ASP.NET, while loading large amount of data or performing advanced initializing processing needed to run initialization code in the Application_start() method in the Global.asax file.
- Redirecting page: removes the unnecessary redirects of the browser. In the previous versions, the Response.Redirect () method was used to forward a request to a new URL. The Response.Redirect () method uses the HTTP302 response, which results in an extra HTTP round trip.
- Compressing session state: reduces the size of session-state. In ASP.NET, there are two options that help in storing session state in a web First option, the session-state provider invokes an out-of-process session-state server. Second option, the session-state provider stores the data in Microsoft SQL Server database.
Range of allowable URLs: refers to the increase in the size of application URLs. In the previous versions of ASP.NET, the maximum length of the URL path was 260 characters. In ASP.NET4.0, increase the URL path length by using the new httpRuntime configuration attribute such as max RequestPathLength attribute.
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
Normalization
NORMALIZATION
- While designing a database out of an entity–relationship model, the main problem existing in that “raw” database is redundancy.
- Redundancy is storing the same data item in more one place. A redundancy creates several problems like the following:
- Extra storage space: storing the same data in many places takes large amount of disk space.
- Entering same data more than once during data insertion.
- Deleting data from more than one place during deletion.
- Modifying data in more than one place.
- Anomalies may occur in the database if insertion, deletion, modification etc are no done properly. It creates inconsistency and unreliability in the database.
- To solve this problem, the “raw” database needs to be normalized. This is a step by step process of removing different kinds of redundancy and anomaly at each step.
- At each step a specific rule is followed to remove specific kind of impurity in order to give the database a slim and clean look.
Un-Normalized Form (UNF)
- If a table contains non-atomic values at each row, it is said to be in UNF. Anatomic value is something that cannot be further decomposed. A non-atomic value, as the name suggests, can be further decomposed and simplified.
- Consider the following table:
Emp-Id |
Emp-Name |
Month |
Sales |
Bank-Id |
Bank-Name |
E01 |
AA |
Jan |
1000 |
B01 |
SBI |
Feb |
1200 |
||||
Mar |
850 |
||||
E02 |
BB |
Jan |
2200 |
B02 |
UTI |
Feb |
2500 |
||||
E03 |
CC |
Jan |
1700 |
B01 |
SBI |
Feb |
1800 |
||||
Mar |
1850 |
||||
Apr |
1725 |
- In the sample table above, there are multiple occurrences of rows under each key Emp-Id. Although considered to be the primary key, Emp-Id cannot give us the unique identification facility for any single row.
- Further, each primary key points to a variable length record (3 for E01, 2 for E02 and 4 for E03).
First Normal Form (1NF)
- A relation is said to be in 1NF if it contains no non-atomic values and each row can provide a unique combination of values.
- The above table in UNF can be processed to create the following table in 1NF.
Emp-Id |
Emp-Name |
Month |
Sales |
Bank-Id |
Bank-Name |
E01 |
AA |
Jan |
1000 |
B01 |
SBI |
E01 |
AA |
Feb |
1200 |
B01 |
SBI |
E01 |
AA |
Mar |
850 |
B01 |
SBI |
E02 |
BB |
Jan |
2200 |
B02 |
UTI |
E02 |
BB |
Feb |
2500 |
B02 |
UTI |
E03 |
CC |
Jan |
1700 |
B01 |
SBI |
E03 |
CC |
Feb |
1800 |
B01 |
SBI |
E03 |
CC |
Mar |
1850 |
B01 |
SBI |
E03 |
CC |
Apr |
1725 |
B01 |
SBI |
- As you can see now, each row contains unique combination of values.
- Unlike in UNF, this relation contains only atomic values, i.e. the rows cannot be further decomposed, so the relation is now in 1NF.
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
THE THIS POINTER
THE THIS POINTER
- Every object in C++ has access to its own address through an important pointer called this pointer.
- This pointer is an implicit parameter to all member functions. Therefore, inside a member function, this may be used to refer to the invoking object.
- The following example to understand the concept of this pointer:
#include <iostream.h>
class Box
{
public:
// Constructor definition
Box(double l=2.0, double b=2.0, double h=2.0)
{
cout <<“Constructor called.” << endl;
length = l;
breadth = b;
height = h; }
double Volume()
{
return length * breadth * height; }
int compare(Box box)
{
return this->Volume() > box.Volume();
}
private:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box};
void main()
{ Box Box1(3.3, 1.2, 1.5); // Declare box1
Box Box2(8.5, 6.0, 2.0); // Declare box2
if(Box1.compare(Box2))
{
cout << “Box2 is smaller than Box1” <<endl;
}
else
{
cout << “Box2 is equal to or larger than Box1” <<endl;
}}
When the above code is compiled and executed, it produces the following result:
Constructor called.
Constructor called.
Box2 is equal to or larger than Box1
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
Namespaces
NAMESPACE
- Namespace is a collection of different classes. At times you need to create an application that uses various classes belongs to other application also. Some of these classes can be having the same name.
- To avoid the problem of same name, .NET uses namespaces that are the collections of classes. All the applications that are created in .NET are developed using classes from the system namespace.
- This is the parent namespace of all the namespaces used in .NET. Table 2 describes some fundamental namespaces used in .NET.
- Below table shows a List of Namespaces –
Namespaces |
Description |
Using System |
Provides the classes for commonly used data types, events, and exceptions |
Collections |
provides different types of classes and interfaces to create collection of objects, such as list, queues, hash tables, and arrays |
Data |
provides the classes that enable you to handle data from different data sources, such SQL or Oracle |
Data.oleDB |
provides the classes that support the OLEDB .NET provider |
Data.Sqlclient |
provides the classes that support the SQL server .NET provider |
Diagnostics |
provides the classes that allow you to debug your application step by step |
Drawing |
provides the classes that allow you to draw on a control or image |
Globalization |
provides the classes that specify culture-related information |
IO |
provides the classes that are used for data access with files |
NET |
provides interface to the protocols that are used on the internet |
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
DBMS Data Backup
USEFULL FOR FYBSC (IT) & TYBSC (CS) STUDENTS
Failure with loss of Non-Volatile storage
- What would happen if the non-volatile storage like RAM abruptly crashes? All transaction, which are being executed are kept in main memory. All active logs, disk buffers and related data is stored in non-volatile storage.
- When storage like RAM fails, it takes away all the logs and active copy of database. It makes recovery almost impossible as everything to help recover is also lost. Following techniques may be adopted in case of loss of non-volatile storage.
- A mechanism like checkpoint can be adopted which makes the entire content of database be saved periodically.
- State of active database in non-volatile memory can be dumped onto stable storage periodically, which may also contain logs and active transactions and buffer blocks.
- <dump> can be marked on log file whenever the database contents are dumped from non-volatile memory to a stable one.
Recovery:
- When the system recovers from failure, it can restore the latest dump.
- It can maintain redo-list and undo-list as in checkpoints.
- It can recover the system by consulting undo-redo lists to restore the state of all transaction up to last checkpoint.
Database backup & recovery from catastrophic failure
So far we have not discovered any other planet in our solar system, which may have life on it, and our own earth is not that safe. In case of catastrophic failure like alien attack, the database administrator may still be forced to recover the database.
Remote backup, described next, is one of the solutions to save life. Alternatively, whole database backups can be taken on magnetic tapes and stored at a safer place. This backup can later be restored on a freshly installed database and bring it to the state at least at the point of backup.
Grown up databases are too large to be frequently backed-up. Instead, we are aware of techniques where we can restore a database by just looking at logs. So backup of logs at frequent rate is more feasible than the entire database. Database can be backed-up once a week and logs, being very small can be backed-up every day or as frequent as every hour.
Remote Backup
Remote backup provides a sense of security and safety in case the primary location where the database is located gets destroyed. Remote backup can be offline or real-time and online. In case it is offline it is maintained manually.
Online backup systems are more real-time and lifesavers for database administrators and investors. An online backup system is a mechanism where every bit of real-time data is backed-up simultaneously at two distant place. One of them is directly connected to system and other one is kept at remote place as backup.
As soon as the primary database storage fails, the backup system sense the failure and switch the user system to the remote storage. Sometimes this is so instant the users even can’t realize a failure.
Posted By-: Vissicomp Technology Pvt. Ltd.
Website -: http://www.vissicomp.com
You must be logged in to post a comment.