INformIX-OnLine client server structure creation and standalone operation

Source: Internet
Author: User
Tags informix
Article Title: INformIX-OnLine client server structure creation and single-host operation. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   1. Create an application based on the client server structure
INFORMIX-OnLine 7.1 is a high-performance database system that supports decision-making applications for large-scale OnLine transaction processing. It not only supports distributed data processing, but also supports applications with the client server structure.
  
The server we use is the HP E25 minicomputer, the operating system is HP_UX 9.04, and OnLine 7.1 is installed. Because OnLine 6.0 and above are embedded with Star, you do not have to install it again. The client is HP NetServer LD, & 127; the operating system is SCO OpenServer 5.04, and the OnLine 5.0 and transmission module INFORMIX-Net are installed. The client runs a business program written in ESQL/C and uses such a statement to open the database cbdb: & 127; $ database icbd @ bacct_qz; on the server ;.
  
Acct_qz is the host name of the server, and then calls the Stored Procedure stored in the database system table to implement the entire business system, & 127; using the stored procedure can reduce the amount of network transmission, of course, you can also directly use SQL statements to operate databases. The icbacct user must be set up on both the server and the client as the trusted user. The user ID can be different. The client uses the sqlrmtlitcp program provided by the INFORMIX transmission module. The environment variable & 127; SQLEXEC = $ INFORMIXDIR/lib/sqlrmtlitcp should be output in the. profile file of your icbacct.
  
Because the security performance of the INFORMIX-OnLine Database system depends on the TCP/IP network protocol, the server should not be in/etc/hosts. configure the client host name in the equiv file. You can only make the icbacct user on the client a trusted user by using the server's icbacct user root directory. in the rhosts file, register the client's host name acct_ha, and under the icbacct user root directory on the client. the rhosts File registers the server's host name acct_qz. In this way, you can log on to the client as an icbacct user and run the business program. You can also use isql to directly access the database. Other users, such as informix, cannot access the database because they are not trusted users. Because TCP/IP checks trusted users. the rhosts file is appended to/etc/hosts. the equiv file is determined together, So if you use icbacct on the server. the content of the rhosts file is changed to the following:
  
"Acct_ha informix" enables clients to access the database as well as informix users of acct_ha.
  
The database name can be in either of the following formats: "Database Name @ server host name", which is used on the client. For example, after you log on to the client as an icbacct user and use isql to modify data, enter the database name "icbdb @ acct_qz". acct_qz is the host name of the server. The second is "Database Name @ database server name", which is used on the server acct_qz. For example, if the name of the database server running on the server is acct_online, the database name is icbdb @ acct_online. The. profile file of the server user icbacct needs to output the environment variable INFORMIXSERVER = acct_online.
  
The above two database names actually refer to the same database.
  
From the above analysis, it is not difficult to see that the customer server structure also has a security risk. When the data of all county branches is concentrated in the city bank, you can use isql to directly modify data in other rows on clients of any county row. Of course, you must log on to a trusted user, such as an icbacct user.
  
┌ ── ─ ┐ Data server name: acct_online
│ ONLINE 7.1 │ Host Name: acct_qz
│ (Embedded Star) │ (server)
└ ┬ ── ┘ DDN, TCP/IP
── ┘ └ ── ─ ┐
── ┴ ┐ ── ┐
│ ONLINE 5.0 │ Host Name: acct_ha │ ONLINE 5.0 │ Host Name: acct_xx
│ I-Net │ (Client 1) │ I-Net │ (Client 2)
── ─ ┘ └ ── ─ ┘
  
Network topology of the customer server structure
  
For example, if a server is connected to two clients through a TCP/IP network (), set up the database server cct_online on the server and name it in the $ INFORMIXDIR/etc/sqlhosts file. The/etc/services file defines the service name sqlexec, the port number occupied by the service, and the protocol type used. For example, 2000/tcp indicates that port 2000 is occupied, and the protocol type is TCP. The following uses acct_qz as an example to describe the Server Host:
① File/etc/hosts:
# Net address hostname host alias
10.168.100.3 acct_qz host=alias
10.168.106.1 acct_ha host2_alias
10.168.107.1 acct_xx host3_alias
  
② File $ INFORMIXDIR/etc/sqlhosts:
# Dbservername nettype hostname servicename
Acct_online onsoctcp acct_qz sqlexec
  
③ File/etc/services:
# Service_name port #/procotol aliases
Sqlexec 2000/tcp
  
Like the Common Client Communication Software, the sqlrmtlitcp Program establishes a connection with the server through the port number 2000 corresponding to the sqlexec service. Therefore, the port number 2000 must be globally consistent. The contents of the three files on the client acct_ha and acct_xx are basically the same as those on the server acct_qz.
  
   2. Run the client server application on a single machine
The hui'an County branch recently adopted the new accounting application program based on the INFORMIX-OnLine client server structure promoted by the Municipal bank. Due to the need of maintenance work, it is necessary to learn and be familiar with this new application, but it is unable to achieve this because the Unit does not have another slave network operating environment for the customer server. Later, the author finally found a clever way to install the entire application on a machine. In addition, it is useful to convert the client server structure into a single machine during development and research, when the network conditions of the customer server are not met, the application of the customer server structure can also be written on a single machine. It is precisely because the database name supports two formats that make it possible to run a single machine. Run sco unix 3.2 and OnLine 5.0 on a single machine without installing Net or Star.
  
2.1 create a database server
  
Create a database server with the same name as the server host (acct_qz) on a single machine: acct_qz. This is the most important and is the key for the entire application to run on a single machine. An icbacct user must also be created on a single machine. The. profile file must output the variable INFORMIXSERVER = acct_qz.
  
2.2 create large enough database space files and logical logs
Modify several parameters of tbconfig:
ROOTPATH/dev/online1
ROOTSIZE 50000
LOGFILES 20
LOGSIZE 500
LTAPEDEV/dev/null
DBSERVERNAME acct_qz
Change the system parameter SHMMAX to 1048576 and SHMMNI to 500. Then run the following command under the root user:
# Cat/dev/null>/dev/online1
# Chown icbacct/dev/online1
# Chgrp informix/dev/online1
Finally, run tbinit-I under the icbacct user to create the database space.
  
2.3 use ESQL/C to generate a stored procedure
  
Because OnLine 5.0 cannot use isql to directly use SQL statements to generate stored procedures, ESQL/C is generally used to write a special C language program to add or replace a stored procedure.
  
$ Drop procedure tb2;
$ Create procedure from "/usr/icbacct/proc/tb2. SQL ";
The preceding two statements first Delete the existing Stored Procedure tb2 and then generate a new stored procedure. Otherwise, the stored procedure cannot be generated. Because we cannot write a special C Language Program for each stored procedure, but the drop statement cannot run with variable parameters. For example, the following statement is not supported: $ drop procedure $ spname ;, therefore, you have to write a program to delete all stored procedures and a program to generate all stored procedures. Each time you want to replace a stored procedure, You have to delete all stored procedures and then regenerate them, I think this is a bad method. Therefore, I have compiled a C language program to add or replace a stored procedure, which can run with command line parameters. The method is to directly run aproc on a client or a single machine. <存储过程名> To add or replace a stored procedure on the server. For example, if tb2u. SQL generates the Stored Procedure tb2, the command line is as follows: aproc tb2 tb2u. An SQL file is a *. SQL file that generates a stored procedure. The file name can be omitted with the suffix ". SQL" and stored in a directory.
  
The sqlcmdtxt structure comes from the aproc generated during esql compilation. c intermediate file, which also gives us some inspiration. There are many things worth learning and studying in the c language Intermediate program, when you encounter problems that are hard to solve with ESQL/C, you may wish to look at the C language Intermediate Program, which may be inspired. For example, the statement for opening a database is:
  
$ Datebase icbdb @ acct_qz;
You can also directly write it as: _ iqdbase ("icbdb @ acct_qz", 0 );, this means that when the client program needs to operate databases on multiple servers, the database name can be flexibly selected. The ESQL/C program on a single machine can use the following statement to open the database: $ database icbdb @ acct_qz;. In this case, the second format of the database name is used, when the program runs on the client, it becomes the first format. acct_qz is no longer the database server name (DBSERVERNAME) but the server host name. The source program aproc. ec is as follows:
  
# Include
$ Include sqlca;
$ Include sqlda;
$ Char s_ SQL [50], s_spname [50];
Static char * sqlcmdtxt [] = {
"Drop procedure tb2", 0
};
Static _ SQSTMT _ SQ0 = {0 };
Main (argc, argv)
Char * argv [];
{
$ Database icbdb @ acct_qz;
$ Begin work;
Sprintf (s_spname, "/usr/icbacct/proc/% s. SQL", argv [2]);
Sprintf (s_ SQL, "drop procedure % s", argv [1]);
Strcpy (sqlcmdtxt [0], s_ SQL );
_ Iq1_nt (& _ SQ0, sqlcmdtxt, 0, (char *) 0, (char *) 0 );
$ Create procedure from $ s_procname;
$ Commit work;
$ Close database;
}
OnLine 7.1 stores stored procedures in the system database sysmasters as records. OnLine 5.0 does not have a system database, but there are more than 20 system tables starting with sys, therefore, you can also use isql to query the stored procedure by selecting Form/Generate and directly entering the table name sysprocbody and sysprocedures. The stored procedure is also stored in these two tables as a record.
  
2.4 data output and import
  
To run applications on a single machine, it is necessary to pour data from the database on the server into the database on the single machine. Run the "dbexport icbdb @ acct_qz" command on the client to output the database data on the server. After the command is run successfully, dbexport is generated in the current directory. out file and icbdb@acct_qz.exp directory, where dbexport. out contains SQL statements that generate databases and database tables and create all the indexes, and the inverted data is stored in the icbdb@acct_qz.exp directory. Compress the file dbexport. out and icbdb@acct_qz.exp directories and copy them to a single machine.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.