SinoDB 安装与手动创建实例

安装环境说明

SinoDB 是一款典型的事务型数据库,类似于Oracle,MySQL等。这款数据库对安装环境要求不高,完全可以在虚拟机上安装和学习。

操作系统的安装

我安装的操作系统是CentOS 7.3。在安装时,选择的是开发和创新工作站,安装后,大概有1500多个rpm包。安装后,关闭了SELinux和防火墙。在使用这样的操作系统安装时,可以非常顺利的进行 SinoDB 的安装。对于采用最小化安装操作系统的同学,可能需要手动安装jre环境和unzip命令:

yum install -y java-1.8. 0-openjdk.x86_ 64
yum install -y unzip-6.0-16.e17 .x86_ 64 

使用yum安装软件包时,需要做一些基本的配置,具体方法可以自行在网上查看。
手动安装成功后,可以通过下面的命令确认。

[root@vm84145 ~]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
[root@vm84145 ~]# which unzip
/usr/bin/unzip
[root@vm84145 ~]# 

至此,我们就准备好了安装 SinoDB 的软件环境。其实说这句话,我还是比较心虚的。SinoDB 需要下面列出的rpm包,不过这些rpm在使用最小化安装操作系统时,已经全部安装过了。喜欢使用Docker的同学,需要认真检查一下,这些rpm包是不是真的已经安装成功。

audit-libs-2.6.5-3.el7.x86_ 64
elfutils-libelf-0.166-2.e17.x86_ 64
expat-2.1.0-8.e17.x86_ 64
fontconfig-2.10. 95-10.el7.x86_ 64
freetype-2.4.11-12.el7.x86_ 64
glibc-2.17-157.e17.x86_ _64
libcap-ng-0.7.5-4.e17 .x86_ 64
1ibgcc-4.8.5-11.el7.x86_ 64
libstdc++-4.8.5-11.el7.x86_ 64
libX11-1.6.3-3.el7.x86_ _64
libXau-1.0.8-2.1.e17.x86_ 64
libxcb-1.11-4.e17.x86_ _64
libXext-1.3.3-3.e17.x86_ _64
libXrender-0.9.8-2.1.e17.x86_ 64
ncurses-libs-5.9-13. 20130511.e17.x86_ 64
nss-softokn-freebl-3.16.2.3-14.4.el7.x86_ _64
pam-1.1.8-18.el7.x86_ 64
readline-6.2-9.e17.x86_ 64
zlib-1.2.7-17.el7.x86_ 64
unzip-6.0-16.e17 .x86_ 64
java-1.8.0-openjdk. x86_ _64

安装程序需要的命令有很多,都是一些基础的Linux命令,如rm,grep,gzip,cut,md5sum,echo,awk,ls,tar,tr,eval,expr等,我还没有时间认真的统计一下。不过这些命令在操作系统安装时,多数已经安装成功(除了unzip),大家在安装时,基本不会因为这些命令不存在而导致安装失败。

硬件环境检查

SinoDB 的数据库组件安装完成后,大约有500M,但存储物理日志,逻辑日志,智能大对象,临时数据和业务数据都需要使用磁盘存储空间,建议至少有10G以上的磁盘空闲空间。当希望练习一些需要数据量较大的操作时,这一点尤为重要。
我演示用的安装环境,是一台安装了CentOS Linux release 7.6.1810 (Core) 操作系统的VMware虚拟机,4核CPU,8G内存,千兆网卡,预分配了160G的磁盘空间。

1.查看服务器内存

[root@vm84145 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7821         314        3921         629        3585        6511
Swap:          8063           0        8063
[root@vm84145 ~]# 

2.查看可用磁盘空间

[root@vm84145 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  142G  8.3G  133G   6% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  410M  3.5G  11% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  180M  835M  18% /boot
tmpfs                    783M     0  783M   0% /run/user/0
[root@vm84145 ~]# 

3.查看网络配置

[root@vm84145 ~]# ifconfig
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.84.145  netmask 255.255.255.0  broadcast 192.168.84.255
        inet6 fe80::202c:2cec:a1d4:cc7b  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:90:6b:b5  txqueuelen 1000  (Ethernet)
        RX packets 1554357768  bytes 139750362790 (130.1 GiB)
        RX errors 0  dropped 74254  overruns 0  frame 0
        TX packets 548139  bytes 38868845 (37.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10374  bytes 1101618 (1.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10374  bytes 1101618 (1.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:91:ad:10  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@vm84145 ~]# 

4.查看操作系统版本

[root@vm84145 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@vm84145 ~]# 

安装前的准备

创建用户和组

SinoDB安装,需要一个名称为informix的用户和组,做为数据库的超级管理员。

[root@vm84145 ~]# groupadd informix
[root@vm84145 ~]# useradd -g informix -d /home/informix -s /bin/bash -m informix
[root@vm84145 ~]# 

上传安装包和解压缩

可以通过ftp或其它第三方工具,将安装包上传到root用户下的一个目录中。

[root@vm84145 tmp]# ls
iif.12.10.FC8.linux-x86_64-GIT-4bcde202b.tar
[root@vm84145 tmp]# 

数据库安装路径目录准备( /home/informix/sinodb)

[root@vm84145 ~]# mkdir /home/informix/sinodb
[root@vm84145 ~]# 

数据库的数据文件目录准备( /home/informix/dbs )

[root@vm84145 ~]# mkdir /home/informix/dbs
[root@vm84145 ~]# 

修改目录文件权限

[root@vm84145 ~]# ll /home/informix/
total 0
drwxr-xr-x 2 root root 6 Feb 14 18:32 dbs
drwxr-xr-x 2 root root 6 Feb 14 18:32 sinodb
[root@vm84145 ~]# chown -Rf informix:informix /home/informix
[root@vm84145 ~]# ll /home/informix/
total 0
drwxr-xr-x 2 informix informix 6 Feb 14 18:32 dbs
drwxr-xr-x 2 informix informix 6 Feb 14 18:32 sinodb

为后续的OAT配置更新目录权限:

[root@vm84145 ~]# chmod 755 /home/informix
[root@vm84145 ~]# ll /home/informix/
total 0
drwxr-xr-x 2 informix informix 6 Feb 14 18:32 dbs
drwxr-xr-x 2 informix informix 6 Feb 14 18:32 sinodb

使用root用户将安装包接解压到sinodb目录中

[root@vm84145 ~]# tar -xvf /tmp/iif.12.10.FC8.linux-x86_64-GIT-4bcde202b.tar -C /home/informix/sinodb
bundle.properties
CSDK/
CSDK/UNIX/
CSDK/UNIX/doc/
CSDK/UNIX/doc/Libcpp_machine_notes_4.10.txt
CSDK/UNIX/doc/Glsapi_machine_notes_4.10.txt
CSDK/UNIX/doc/oat_readme_3.16.html
CSDK/UNIX/doc/ESQLC_machine_notes_4.10.txt
CSDK/UNIX/doc/Odbc_machine_notes_4.10.txt
CSDK/UNIX/doc/oat_relnotes_3.16.html
ICONNECT/
ICONNECT/UNIX/
ICONNECT/UNIX/doc/
ICONNECT/UNIX/doc/Libcpp_machine_notes_4.10.txt
ICONNECT/UNIX/doc/Glsapi_machine_notes_4.10.txt
ICONNECT/UNIX/doc/ESQLC_machine_notes_4.10.txt
ICONNECT/UNIX/doc/Odbc_machine_notes_4.10.txt
ids_install
JDBC/
JDBC/properties/
JDBC/properties/version/
JDBC/properties/version/IBM_Informix_JDBC_Driver_Embedded_SQL-4.10.0.swtag
README.html
SERVER/
SERVER/onsecurity
SERVER/doc/
SERVER/doc/ids_machine_notes_12.10.txt
SERVER/doc/swa_relnotes_1.1.html
[root@vm84145 ~]# cd /home/informix/sinodb/
[root@vm84145 sinodb]# ll
total 384408
-rw-r--r-- 1 root bin     10201 Aug 16  2017 bundle.properties
drwxr-xr-x 3 root bin        18 Aug 16  2017 CSDK
drwxr-xr-x 3 root bin        18 Aug 16  2017 ICONNECT
-rwxr-xr-x 1 root bin 393620552 Aug 16  2017 ids_install
drwxr-xr-x 3 root bin        24 Aug 16  2017 JDBC
-rw-r--r-- 1 root bin         0 Aug 16  2017 README.html
drwxr-xr-x 3 root bin        35 Aug 16  2017 SERVER
[root@vm84145 sinodb]# 

安装SinoDB

[root@vm84145 sinodb]# pwd
/home/informix/sinodb
[root@vm84145 sinodb]# ls
bundle.properties  CSDK  ICONNECT  ids_install  JDBC  README.html  SERVER
[root@vm84145 sinodb]# ./ids_install 
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...

Launching installer...

安装SinoDB 数据库组件

下面通过控制台命令行的方式,演示SinoDB的安装。
使用root用户进入安装目录,执行ids_install命令。

This application  will guide you through the installation of Sinoregal SinoDB 
Software Bundle.
Copyright Sinoregal Corporation 1996, 2022. All rights reserved.
1. Release Notes
The Release Notes can be found in
/home/informix/sinodb/SERVER/doc/ids_unix_relnotes_12.10.html

2. Installation Guide
Please view the Installation / Quick Beginnings Guide at
/home/informix/sinodb/SERVER/doc/ids_unix_installg_12.10.pdf

3. Launch Information Center
Access the Sinoregal SinoDB 12.10 Information Center at
http://sinoregal.cn/infocenter/SinoDB/v121/

To Begin Installation,Respond to each prompt to proceed to the next step in 
the installation.If you want to change something on a previous step, type 
'back'.
You may cancel this installation at any time by typing 'quit'.

PRESS <ENTER> TO CONTINUE: 

确认License,按回车确认
License Agreement

Installation and Use of Sinoregal SinoDB Software Bundle Requires Acceptance 
of the Following License Agreement:

Dummy License - Version 1.0.0 and later

COPYRIGHT AND PERMISSION NOTICE

Copyright (c) 1995-2006 International Business Machines Corporation and  
others

All rights reserved.

THIS IS A DUMMY COPYRIGHT FILE. CHANGE TO CORRESPONDING TERM ACCORDINGLY.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 
IN NO EVENT  SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE 
LIABLE FOR ANY  CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR 
ANY DAMAGES  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
IN AN ACTION OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION  WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not  
be used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization of the copyright holder.

PRESS <ENTER> TO CONTINUE: 

输入y,按回车
All trademarks and registered trademarks mentioned herein are the property of their respective owners.

DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): 

安装程序询问软件的安装路径,默认为/opt/SinoDB_Software_Bundle,我们需要指定自己的安装目录/home/informix/sinodb,回车并输入y,回车确认该目录。

DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y

Installation Location

Choose location for software installation

  Default Install Folder: /opt/SinoDB_Software_Bundle

ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
      : /home/informix/sinodb                        

INSTALL FOLDER IS: /home/informix/sinodb
   IS THIS CORRECT? (Y/N):                  

安装程序提示,选择安装类型,默认为1-典型安装,我们这里使用典型安装,所以直接回车即可。如果需要自定义安装,则输入2后,再回车。

Installation or Distribution
----------------------------

Select the installation type.

Typical: This installation is pre-configured, and requires
a minimal number of configuration choices.
Features for common business needs are installed. Includes:
** Client Software Development Kit (CSDK).
** Java Database Connectivity (JDBC).
** Open Admin Tool (OAT).

Custom: This installation requires greater knowledge of
Sinoregal SinoDB technology. You can select features
and custom server configurations for your
specific business needs.

Legacy : Run an installation command to extract SinoDB
media files that you can redistribute by scripts.

RPM: Create a custom RPM Package Manager image
that you can deploy as a silent installation.

Optionally install a configured database server instance.
Minimum disk space required: 75 MB (without a server instance)

  ->1- Typical installation
    2- Custom installation
    3- Extract the product files (-DLEGACY option)
    4- Create a RPM package for redistribution

ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 

输入主机名称,默认为当前主机名称,回车即可。

Host Name
---------

Enter the host name for your machine.

Host Name: (Default: vm84145): 




===============================================================================

指定OAT端口号,默认为8080,可以按需要定义要用的端口号。这里采用默认端口号,回车即可。

===============================================================================
Specify Apache Port Number
--------------------------

Please specify the port number for the Apache webserver.

Specify the port number for the Apache web server.

Port Number (Default: 8080): 

是否启用OAT密码保护,默认yes(启用),回车即可。

Security Features
-----------------

With OAT password protection, only OAT administrators can add  and  edit 
connection groups and change OAT configurations. Other users can   manage 
Sinoregal database servers, but they cannot modify connection groups and OAT 
configurations.

Enable OAT Password Protection? (Default: yes): 

设置OAT用户与密码,默认用户(User name)为admin,回车即可,然后设置密码

===============================================================================
OAT Administrator login setup
-----------------------------

Enter the user name and password for accessing the OAT Admin pages.

User name: (Default: admin): 


===============================================================================



Password: 



===============================================================================


Retype the password: 

CSDk的License授权,回车确认

License Agreement
-----------------

Installation and Use of SinoDB Client-SDK Requires Acceptance of the Following
License Agreement:

Dummy License - Version 1.0.0 and later

COPYRIGHT AND PERMISSION NOTICE

Copyright (c) 1995-2006 International Business Machines Corporation and  
others

All rights reserved.

THIS IS A DUMMY COPYRIGHT FILE. CHANGE TO CORRESPONDING TERM ACCORDINGLY.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 
IN NO EVENT  SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE 
LIABLE FOR ANY  CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR 
ANY DAMAGES  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 
IN AN ACTION OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION  WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Except as contained in this notice, the name of a copyright holder shall not  
be used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization of the copyright holder.

PRESS <ENTER> TO CONTINUE: 

输入y,按回车

All trademarks and registered trademarks mentioned herein are the  property of  their respective owners.
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y

安装程序询问是否在安装时,创建一个数据库实例。安装时创建的实例,不满足我们的学习要求,且由于创建实例时,会根据服务器硬件,配置相关参数。这可能导致创建的实例分配并初始化较大的磁盘空间,耗时较长,因此我们一定要选择2- No - do not create an instance,记住,一定要选择不创建实例。
输入2,回车确认。

===============================================================================
Server Instance
---------------

Type 'back' to go to the previous step or 'quit' to cancel the installation.

Create a database server instance?



  ->1- Yes - create a server instance
    2- No - do not create a server instance

ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:: 2



===============================================================================
Installation Summary
--------------------

Please review the following before continuing:

Product Name:
    Sinoregal SinoDB Software Bundle

Install Folder:
    /home/informix/sinodb

Product Features:
    Sinoregal SinoDB database server,
    Base Server,
    Extensions and tools,
    J/Foundation,
    Database extensions,
    Conversion and reversion support,
    XML publishing,
    Demonstration database scripts,
    Enterprise Replication,
    Data loading utilities,
    onunload and onload utilities,
    dbload utility,
    High-Performance Loader,
    Backup and Restore,
    archecker utility,
    ON-Bar utility,
    Interface to Tivoli Storage Manager,
    Administrative utilities,
    Performance monitoring utilities,
    Miscellaneous monitoring utilities,
    Auditing utilities,
    Database import and export utilities,
    JSON Client Support,
    Sinoregal SinoDB Client SDK,
    Sinoregal SinoDB Object Interface for C++,
    Sinoregal SinoDB Object Interface for C++ Demos,
    Sinoregal SinoDB ESQL/C,
    Sinoregal SinoDB ESQL/C demos,
    7.2 application compatibility module,
    Sinoregal SinoDB LIBDMI for client applications,
    Sinoregal SinoDB ODBC Driver,
    Sinoregal SinoDB ODBC Driver demos,
    Global Language Support (GLS),
    West European and Americas,
    Chinese,
    Sinoregal SinoDB JDBC,
    Sinoregal SinoDB OpenAdmin Tool,
    Replication Plug-in for OpenAdmin Tool,
    Schema Manager Plug-in for OpenAdmin Tool,
    TimeSeries Plug-in for OpenAdmin Tool,
    Health Advisor Plug-in for OpenAdmin Tool,
    JSON Plug-in for OpenAdmin Tool

Disk Space Information (for Installation Target): 
    Required:  694,860,904 Bytes
    Available: 142,038,863,872 Bytes

PRESS <ENTER> TO CONTINUE: 

回车继续安装

PRESS <ENTER> TO CONTINUE: 



===============================================================================
Ready To Install
----------------

InstallAnywhere is now ready to install Sinoregal SinoDB Software Bundle onto 
your system at the following location:

   /home/informix/sinodb

PRESS <ENTER> TO INSTALL: 

确认安装目录,回车继续安装

===============================================================================
Installing...
-------------

 [==================|==================|==================|==================]
 [------------------|------------------|------------------|------------------]



===============================================================================
Installation Complete
---------------------

The installation of Sinoregal SinoDB Software Bundle is complete, but some 
errors occurred during the install.
   Please see the installation log for details.  Click 'Done' to exit the 
installation process.

Product install status:
SinoDB Dynamic Server: Successful
SinoDB Client-SDK: Successful
SinoDB JDBC Driver: Successful
OpenAdmin Tool: Successful


For more information about using SinoDB products, see the Sinoregal SinoDB 12.
10 Information Center at http://sinoregal.cn/infocenter/SinoDB/v121/.

PRESS <ENTER> TO EXIT THE INSTALLER: 
[root@vm84145 sinodb]# 

安装程序开始安装工作。大概经过1分钟多一点时间,即可完成数据库程序的安装。
安装完成后,回车退出安装程序。记得在显示PRESS TO EXIT THE INSTALLER时,再次回车。
至此,数据库程序安装完成。

创建数据库实例

如果你想更深入的了解 SinoDB 数据库,可以学习如果手动安装一个数据库实例。采用这样的方式可能会让你暂时遇到一点点困难,但这项技能很重要,为了掌握这个方法付出努力是值得的。理解如何手动部署实例,让我们后面学习单机多实例部署,基于共享存储的高可用集群部署和多机的同城灾备集群部署更轻松。

使用informix用户进行数据库实例的创建操作,手动创建数据库实例的步骤主要有:

1.配置环境变量
2.配置sqlhosts
3.配置onconfig
4.初始化数据库实例
5.创建数据库空间
6.将逻辑日志从根数据库空间,迁移到正式的逻辑日志空间。
7.将物理日志从根数据库空间,迁移到正式的物理日志空间。
8.根据创建的数据库空间,更新onconfig

规划数据库空间

在正式开始创建数据库实例前,我们先规划一下我们的数据库。
SinoDB 中可以创建多种类型的数据库空间

本次实验我们规划创建的数据库空间如下(注意:使用informix用户进行操作):

[informix@vm84145 dbs]$ pwd
/home/informix/dbs
[informix@vm84145 dbs]$ ll
total 0
[informix@vm84145 dbs]$ touch rootdbs llogdbs plogdbs tempdbs1 tempdbs2 tempdbs3 datadbs1-1  datadbs2-1  datadbs3-1  datadbs4-1  datadbs5-1 sbdbs1 bindbs1
[informix@vm84145 dbs]$ ls -a
.  ..  datadbs1-1  datadbs2-1  datadbs3-1  datadbs4-1  datadbs5-1  llogdbs  plogdbs  rootdbs  sbdbs1  tempdbs1  tempdbs2  tempdbs3  bindbs1
[informix@vm84145 dbs]$ ll
total 19968000
-rw-rw-r-- 1 informix informix 1048576000 Mar  7 15:21 bindbs1
-rw-rw-r-- 1 informix informix 2097152000 Apr 17 01:11 datadbs1-1
-rw-rw-r-- 1 informix informix 2097152000 Apr 11 16:30 datadbs2-1
-rw-rw-r-- 1 informix informix 2097152000 Apr 11 16:30 datadbs3-1
-rw-rw-r-- 1 informix informix 2097152000 Apr 11 16:30 datadbs4-1
-rw-rw-r-- 1 informix informix 2097152000 Apr 11 16:30 datadbs5-1
-rw-rw-r-- 1 informix informix 2097152000 Apr 19 09:31 llogdbs
-rw-rw-r-- 1 informix informix 2097152000 Apr 19 09:31 plogdbs
-rw-rw-r-- 1 informix informix 2097152000 Apr 19 09:31 rootdbs
-rw-rw-r-- 1 informix informix 1048576000 Apr 11 16:30 sbdbs1
-rw-rw-r-- 1 informix informix  524288000 Apr 19 08:11 tempdbs1
-rw-rw-r-- 1 informix informix  524288000 Apr 19 09:11 tempdbs2
-rw-rw-r-- 1 informix informix  524288000 Apr 19 09:11 tempdbs3

给数据库文件授权

[informix@vm84145 dbs]$ chmod 660 /home/informix/dbs/*
[informix@vm84145 dbs]$ ll
total 19968000
-rw-rw---- 1 informix informix 1048576000 Mar  7 15:21 bindbs1
-rw-rw---- 1 informix informix 2097152000 Apr 17 01:11 datadbs1-1
-rw-rw---- 1 informix informix 2097152000 Apr 11 16:30 datadbs2-1
-rw-rw---- 1 informix informix 2097152000 Apr 11 16:30 datadbs3-1
-rw-rw---- 1 informix informix 2097152000 Apr 11 16:30 datadbs4-1
-rw-rw---- 1 informix informix 2097152000 Apr 11 16:30 datadbs5-1
-rw-rw---- 1 informix informix 2097152000 Apr 19 09:31 llogdbs
-rw-rw---- 1 informix informix 2097152000 Apr 19 09:31 plogdbs
-rw-rw---- 1 informix informix 2097152000 Apr 19 09:31 rootdbs
-rw-rw---- 1 informix informix 1048576000 Apr 11 16:30 sbdbs1
-rw-rw---- 1 informix informix  524288000 Apr 19 08:11 tempdbs1
-rw-rw---- 1 informix informix  524288000 Apr 19 09:11 tempdbs2
-rw-rw---- 1 informix informix  524288000 Apr 19 09:11 tempdbs3

配置环境变量

在informix用户的/home/informix目录下,创建一个profile.sinodb文件,内容如下:

export INFORMIXSERVER=sinodb
export INFORMIXDIR=/home/informix/sinodb  
export ONCONFIG=onconfig.sinodb
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/sqlhosts.sinodb  
export PATH=$INFORMIXDIR/bin:${INFORMIXDIR}/extend/krakatoa/jre/bin:/usr/bin:${PATH}:.
export DB_LOCALE=zh_cn.utf8
export CLIENT_LOCALE=zh_cn.utf8
export LD_LIBRARY_PATH=${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/cli
export TERM=vt100
export TERMCAP=$INFORMIXDIR/etc/termcap
export INFORMIXTERM=termcap                          
export DBTEMP=$INFORMIXDIR/tmp

其中INFORMIXSQLHOSTS指定的sqlhosts文件的路径和名称,INFORMIXSERVER指定了数据库实例的名称,ONCONFIG指定了配置参数文件名称。
运行source命令,使环境变量生效。

[informix@vm84145 ~]$ source profile.sinodb 
[informix@vm84145 ~]$ env |grep INFORMIX
INFORMIXDIR=/home/informix/sinodb
INFORMIXTERM=termcap
INFORMIXSERVER=sinodb
INFORMIXSQLHOSTS=/home/informix/sinodb/etc/sqlhosts.sinodb
[informix@vm84145 ~]$ 

通过env命令查看,配置的环境变量已经生效。

配置sqlhosts

参考环境变量中设置的$INFORMIXSERVER与$INFORMIXSQLHOSTS,生成sqlhosts的配置文件。

[informix@vm84145 ~]$ cp $INFORMIXDIR/etc/sqlhosts.std  $INFORMIXSQLHOSTS
[informix@vm84145 ~]$ ls $INFORMIXSQLHOSTS
/home/informix/sinodb/etc/sqlhosts.sinodb
[informix@vm84145 ~]$echo "$INFORMIXSERVER onsoctcp 192.168.84.145 1526">>$INFORMIXSQLHOSTS
[informix@vm84145 ~]$ cat $INFORMIXSQLHOSTS
#**************************************************************************
#
#  Licensed Material - Property Of IBM
#
#  "Restricted Materials of IBM"
#
#  IBM Informix Dynamic Server
#  Copyright IBM Corporation 1996, 2011
#
#  Title:       sqlhosts.demo
#  Description: Default sqlhosts file for running demos.
#
#**************************************************************************
# The connectivity information for each database server includes four fields
# of required information and one optional field. You can also configure
# database server groups.
#
# The format for the five fields of connectivity information for a database
# server is one line in the UNIX  sqlhosts file, as follows:
#
# <dbservername> <nettype> <hostname> <servicename> <options>
#
# dbservername is the name of a database server on the network.
#
# nettype is an 8-character string specifying the protocol in this format:
#
# ddiiippp
#
# where
#   dd  =  Database product [|ol|on|dr]
#   iii =  Interface type [ipc|soc|tli|sql]
#   ppp =  Protocol [imc|nmp|shm|spx|str|tcp|ssl|mux]
#
# hostname is the name of the computer where the database server resides.
#
# servicename is a service name entry from the services file.
#
# options in the fifth field:
#
#   b=<connection buffer size>
#   c=<connection redirection>
#   g=<group name>
#   i=<group identifier>
#   e=<end of group>
#   m=<multiplexed connection>
#   k=<keep alive setting>
#   r=<client security setting>
#   s=<server security setting>
#   csm=<communication support module>
#   cfd=<communication files directory>
#
# To create an entry for a group, put a group name in the dbservername field,
# the word group in the nettype field, a hyphen in both the hostname and the
# servicename fileds, and i=<group identifier> in the options field.
#
# For additional information on the parameters, see the IBM Informix
# Administrator's Guide.
#**************************************************************************
# IANA (www.iana.org) assigned port number/service names for Informix:
# sqlexec 9088/tcp
# sqlexec-ssl 9089/tcp

#demo_on        onipcshm        on_hostname     on_servername
sinodb onsoctcp 192.168.84.145 1526

sqlhosts文件配置信息的第一部分,指定了数据库实例名称,第二部分指定了通讯协议,第三部分指定了服务器监听的IP地址,第四部分指定了服务器监听的端口号。

配置onconfig

onconfig文件的配置,是手动创建实例中比较关键的步骤。我们可以复制一个标准onconfig模板内容,经过适当的修改,做为我们的onconfig。

根据环境变量配置的$ONCONFIG值,我们在$INFORMIXDIR/etc目录下,创建名称为$ONCONFIG值的文件,即配置参数文件为/home/informix/onconfig.sinodb

通过标准配置文件,复制数据库实例的配置文件。

[informix@vm84145 etc]$ pwd
/home/informix/sinodb/etc
[informix@vm84145 etc]$ ls onconfig.*
onconfig.std
[informix@vm84145 etc]$ cp onconfig.std $ONCONFIG
[informix@vm84145 etc]$ ls onconfig.*
onconfig.sinodb  onconfig.std
[informix@vm84145 etc]$ vi  $INFORMIXDIR/etc/$ONCONFIG

数据库实例关键参数信息标准文件默认值

ROOTPATH /home/informix/dbs/rootdbs 
	ROOTSIZE 2048000  #测试环境分配2GB空间,根据实际情况修改
	DBSERVERNAME sinodb #与环境变量保持一致
	TAPEDEV /dev/null
	LTAPEDEV /dev/null

初始化实例

在初始化实例前,需要保证rootdbs对应的文件已经存在,并有正确的访问权限(一般为660)。在前面我们已经创建了根数据库空间rootdbs,并授权。现在我们可以通过oninit -ivy命令初始化数据库实例。

[informix@vm84145 ~]$ oninit -ivy
 6031
Reading configuration file '/home/informix/sinodb/etc/onconfig.sinodb'...succeeded
Creating /INFORMIXTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 11030 kbytes...succeeded
Creating infos file "/home/informix/sinodb/etc/.infos.sinodb"...succeeded
Linking conf file "/home/informix/sinodb/etc/.conf.sinodb"...succeeded
Initializing rhead structure...rhlock_t 16384 (512K)... rlock_t (2656K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Initializing encryption-at-rest if necessary...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 8 flushers...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Creating database partition...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating VP cache drain thread...succeeded
Creating limits manager thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
[informix@vm84145 ~]$ 

可以通过onstat查看数据库实例当前状态。

[informix@vm84145 ~]$ onstat -

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:01:40 -- 171264 Kbytes

[informix@vm84145 ~]$ 

当前的数据库实例显示为On-Line,至此,一个简单的数据库实例已经创建成功。

添加表空间

只有root数据库空间的实例,无法应用于生产环境的部署。我们可以根据生产环境实际要求,创建适合自己需要的多个数据库空间。SinoDB 提供了onspaces命令,用于数据库空间的创建。

onspaces -c -d llogdbs -p /home/informix/dbs/llogdbs -o 0 -s 2048000 


[informix@vm84145 ~]$ onspaces -c -d llogdbs -p /home/informix/dbs/llogdbs -o 0 -s 2048000 
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 ~]$ 

说明:在使用onspaces创建数据库空间前,需要先创建一个空文件,并设置好对应的权限(660)。

创建逻辑日志数据库空间

创建数据库空间语法

onspaces -c -d llogdbs -p /home/informix/dbs/llogdbs -o 0 -s 2048000 

创建演示

[informix@vm84145 ~]$ onspaces -c -d llogdbs -p /home/informix/dbs/llogdbs -o 0 -s 2048000 
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 ~]$ 

创建物理日志数据库空间

创建物理日志数据库空间语法

onspaces -c -d plogdbs -p /home/informix/dbs/plogdbs -o 0 -s 2048000

创建演示

[informix@vm84145 ~]$ onspaces -c -d plogdbs -p /home/informix/dbs/plogdbs -o 0 -s 2048000
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 ~]$ 
创建临时数据库表空间
onspaces -c -d tempdbs1 -t -p /home/informix/dbs/tempdbs1 -o 0 -k 8 -s 512000 
onspaces -c -d tempdbs2 -t -p /home/informix/dbs/tempdbs2 -o 0 -k 8 -s 512000
onspaces -c -d tempdbs3 -t -p /home/informix/dbs/tempdbs3 -o 0 -k 8 -s 512000 

创建演示

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 ~]$ onspaces -c -d tempdbs1 -t -p /home/informix/dbs/tempdbs1 -o 0 -k 8 -s 512000 
Verifying physical disk space, please wait ...
Space successfully added.
[informix@vm84145 ~]$ onspaces -c -d tempdbs2 -t -p /home/informix/dbs/tempdbs2 -o 0 -k 8 -s 512000 
Verifying physical disk space, please wait ...
Space successfully added.
[informix@vm84145 ~]$ onspaces -c -d tempdbs3 -t -p /home/informix/dbs/tempdbs3 -o 0 -k 8 -s 512000
Verifying physical disk space, please wait ...
Space successfully added.
[informix@vm84145 ~]$ 
创建二进制大对象数据库空间

创建二进制大对象数据库空间语法(注意使用-g参数指定页大小)

onspaces -c -b bindbs1 -g 4 -p /home/informix/dbs/bindbs1 -o 0 -s 1024000 

创建演示

[informix@vm84145 dbs]$ onspaces -c -b bindbs1 -g 4 -p /home/informix/dbs/bindbs1 -o 0 -s 1024000
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ 
创建智能大对象数据库表空间
onspaces -c -S sbdbs1 -p /home/informix/dbs/sbdbs1 -o 0 -s 1024000

创建演示

[informix@vm84145 dbs]$ onspaces -c -S sbdbs1 -p /home/informix/dbs/sbdbs1 -o 0 -s 1024000
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ 
创建业务数据库空间

创建业务数据的数据库空间语法

onspaces -c -d datadbs1 -p /home/informix/dbs/datadbs1-1 -o 0 -s 2048000 -k 2
onspaces -c -d datadbs2 -p /home/informix/dbs/datadbs2-1 -o 0 -s 2048000 -k 2
onspaces -c -d datadbs3 -p /home/informix/dbs/datadbs3-1 -o 0 -s 2048000 -k 2
onspaces -c -d datadbs4 -p /home/informix/dbs/datadbs4-1 -o 0 -s 2048000 -k 2
onspaces -c -d datadbs5 -p /home/informix/dbs/datadbs5-1 -o 0 -s 2048000 -k 2

创建演示

[informix@vm84145 dbs]$ onspaces -c -d datadbs1 -p /home/informix/dbs/datadbs1-1 -o 0 -s 2048000 -k 2
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ onspaces -c -d datadbs2 -p /home/informix/dbs/datadbs2-1 -o 0 -s 2048000 -k 2
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ onspaces -c -d datadbs3 -p /home/informix/dbs/datadbs3-1 -o 0 -s 2048000 -k 2
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ onspaces -c -d datadbs4 -p /home/informix/dbs/datadbs4-1 -o 0 -s 2048000 -k 2
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ onspaces -c -d datadbs5 -p /home/informix/dbs/datadbs5-1 -o 0 -s 2048000 -k 2

查看已经添加的数据库空间信息

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ onstat -d

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:54:16 -- 253724 Kbytes

Dbspaces
address          number   flags      fchunk   nchunks  pgsize   flags    owner    name
45270028         1        0x20001    1        1        2048     N  BA    informix rootdbs
4db49180         2        0x20001    2        1        2048     N  BA    informix llogdbs
4db41740         3        0x20001    3        1        2048     N  BA    informix plogdbs
46726dc8         4        0x2001     4        1        8192     N TBA    informix tempdbs1
4da70578         5        0x2001     5        1        8192     N TBA    informix tempdbs2
4dcb3db0         6        0x2001     6        1        8192     N TBA    informix tempdbs3
4dd8e568         7        0x20011    7        1        8192     N BBA    informix bindbs1
4d8a8b90         8        0x28001    8        1        2048     N SBA    informix sbdbs1
4d8a8dd0         9        0x20001    9        1        2048     N  BA    informix datadbs1
4ddcb5b8         10       0x20001    10       1        2048     N  BA    informix datadbs2
4ddb7d90         11       0x20001    11       1        2048     N  BA    informix datadbs3
4dab2578         12       0x20001    12       1        2048     N  BA    informix datadbs4
469a5d80         13       0x20001    13       1        2048     N  BA    informix datadbs5
 13 active, 2047 maximum

Note: For BLOB chunks, the number of free pages shown is out of date.
      Run 'onstat -d update' for current stats.

Chunks
address          chunk/dbs     offset     size       free       bpages     flags pathname
45270268         1      1      0          1024000    959057                PO-B-- /home/informix/dbs/rootdbs
4db493c0         2      2      0          1024000    1023947               PO-B-- /home/informix/dbs/llogdbs
4dd22028         3      3      0          1024000    1023947               PO-B-- /home/informix/dbs/plogdbs
4d984028         4      4      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs1
4dd8c028         5      5      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs2
4d8e8028         6      6      0          64000      63947                 PO-B-- /home/informix/dbs/tempdbs3
4d8a8028         7      7      0          512000    ~128000     128000     POBB-- /home/informix/dbs/bindbs1
4d8fb028         8      8      0          512000     477465     477465     POSB-- /home/informix/dbs/sbdbs1
                                 Metadata 34482      25659      34482   
4db74028         9      9      0          1024000    1023947               PO-B-- /home/informix/dbs/datadbs1-1
4dc47028         10     10     0          1024000    1023947               PO-B-- /home/informix/dbs/datadbs2-1
4da2b028         11     11     0          1024000    1023947               PO-B-- /home/informix/dbs/datadbs3-1
4ddd0028         12     12     0          1024000    1023947               PO-B-- /home/informix/dbs/datadbs4-1
4de11028         13     13     0          1024000    1023947               PO-B-- /home/informix/dbs/datadbs5-1
 13 active, 32766 maximum

NOTE: The values in the "size" and "free" columns for DBspace chunks are
      displayed in terms of "pgsize" of the DBspace to which they belong.


Expanded chunk capacity mode: always

[informix@vm84145 dbs]$ 
Verifying physical disk space, please wait ...
Space successfully added.

** WARNING **  A level 0 archive of Root DBSpace will need to be done.
[informix@vm84145 dbs]$ 

迁移物理日志

数据库在第一次初始化时,将逻辑日志和物理日志全部保存在根数据库空间中。我们需要将逻辑日志和物理日志迁移到对应的数据库空间中。

[informix@vm84145 ~]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 00:56:09 -- 253724 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  0        1024     661        19         34.79
      phybegin         physize    phypos     phyused    %used   
      1:263            25000      661        0          0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-1  0        512      161234     13420      3534       12.0       3.8     
        Subsystem    numrecs    Log Space used
        OLDRSAM      160908     22705712      
        SBLOB        5          252           
        HA           23         1012          
        DDL          298        103704        

address          number   flags    uniqid   begin                size     used    %used
4519af68         1        U-B----  1        1:25263              5000     5000   100.00
45270f40         2        U-B----  2        1:30263              5000     5000   100.00
45270fa8         3        U---C-L  3        1:35263              5000     3420    68.40
453a0b18         4        A------  0        1:40263              5000        0     0.00
453a0b80         5        A------  0        1:45263              5000        0     0.00
453a0be8         6        A------  0        1:50263              5000        0     0.00
 6 active, 6 total
 
 

[informix@vm84145 ~]$ 

我们可以使用onparams命令,将逻辑日志和物理日志进行迁移,该命令的语法如下:

[informix@vm84145 ~]$ onparams --

Usage:  onparams  { -a -d <DBspace> [-s <size>] [-i] }                      |
                  { -b -g <pagesize> [-n <number of buffers>] 
                   [-r <number of LRUs>] [-x <maxdirty>] [-m <mindirty>] }  |
                  { -d -l <log file number> [-y] }                          |
                  { -p -s <size> [-d <DBspace>] [-y] } 

    -a  - Add a logical log file
    -b  - Add a buffer pool 
    -i  - Insert after current log
    -d  - Drop a logical log file
    -p  - Change physical log size and location
    -y  - Automatically responds "yes" to all prompts

[informix@vm84145 ~]$ 

使用下面的语法,进行物理日志的迁移。

onparams -p -d plogdbs -s 2047890 -y 

物理日志迁移演示

[informix@vm84145 ~]$ onparams -p -d plogdbs -s 2047890 -y 
Log operation started. To monitor progress, use the onstat -l command.
** WARNING ** Because the physical log has been modified, a level 0 archive 
must be taken of the following spaces before an incremental archive will be 
permitted for them: rootdbs plogdbs 
(see Dynamic Server Administrator's manual)
[informix@vm84145 ~]$

查看物理日志状态信息

[informix@vm84145 ~]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- On-Line -- Up 2 days 19:46:43 -- 2374324 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-2  0        1024     26730      525        50.91
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    168787     0          0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-1  0        512      161234     13420      3534       12.0       3.8     
        Subsystem    numrecs    Log Space used
        OLDRSAM      160908     22705712      
        SBLOB        5          252           
        HA           23         1012          
        DDL          298        103704        

address          number   flags    uniqid   begin                size     used    %used
4519af68         1        U-B----  1        1:25263              5000     5000   100.00
45270f40         2        U-B----  2        1:30263              5000     5000   100.00
45270fa8         3        U---C-L  3        1:35263              5000     3420    68.40
453a0b18         4        A------  0        1:40263              5000        0     0.00
453a0b80         5        A------  0        1:45263              5000        0     0.00
453a0be8         6        A------  0        1:50263              5000        0     0.00
 6 active, 6 total

[informix@vm84145 ~]$ 

至此,物理日志迁移成功

迁移逻辑日志

在前面的操作中,我们创建了逻辑日志的数据库空间,我们需要在逻辑日志的数据库空间中创建对应的多个逻辑日志文件,来保存逻辑日志。使用下面的命令创建一个新的逻辑日志文件。

onparams -a -d llogdbs -s 204780

下面的演示,创建9个新的逻辑日志文件。在创建第10个逻辑日志文件时,因数据库空间不足而失败。

[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
[informix@vm84145 ~]$ onparams -a -d llogdbs -s 204780
Log operation started. To monitor progress, use the onstat -l command.
Cannot add a logical log.
ISAM error:  DBSpace is full.
[informix@vm84145 ~]$ 

查看已经创建的逻辑日志文件。

[informix@vm84145 ~]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 01:06:41 -- 253724 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  0        1024     741        30         24.70
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    72         0          0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      161315     13455      3569       12.0       3.8     
        Subsystem    numrecs    Log Space used
        OLDRSAM      160977     22710928      
        SBLOB        5          252           
        HA           35         1540          
        DDL          298        103704        

address          number   flags    uniqid   begin                size     used    %used
4519af68         1        U-B----  1        1:25263              5000     5000   100.00
45270f40         2        U-B----  2        1:30263              5000     5000   100.00
45270fa8         3        U---C-L  3        1:35263              5000     3455    69.10
453a0b18         4        A------  0        1:40263              5000        0     0.00
453a0b80         5        A------  0        1:45263              5000        0     0.00
453a0be8         6        A------  0        1:50263              5000        0     0.00
4da66578         7        A------  0        2:53               102390        0     0.00
4da66648         8        A------  0        2:102443           102390        0     0.00
4da665e0         9        A------  0        2:204833           102390        0     0.00
4da666b0         10       A------  0        2:307223           102390        0     0.00
4da66720         11       A------  0        2:409613           102390        0     0.00
4da66798         12       A------  0        2:512003           102390        0     0.00
4da66818         13       A------  0        2:614393           102390        0     0.00
4da668a0         14       A------  0        2:716783           102390        0     0.00
4da66930         15       A------  0        2:819173           102390        0     0.00
4da669c8         16       A------  0        2:921563           102390        0     0.00
 16 active, 16 total

[informix@vm84145 ~]$ 

切换并删除系统默认的逻辑日志

[informix@vm84145 ~]$ onmode -l
[informix@vm84145 ~]$ onmode -l
[informix@vm84145 ~]$ onmode -l
[informix@vm84145 ~]$ onmode -l
[informix@vm84145 ~]$ onmode -c
[informix@vm84145 ~]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 01:08:12 -- 253724 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  0        1024     741        30         24.70
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    72         0          0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      161315     13459      3573       12.0       3.8     
        Subsystem    numrecs    Log Space used
        OLDRSAM      160977     22710928      
        SBLOB        5          252           
        HA           35         1540          
        DDL          298        103704        
        
address          number   flags    uniqid   begin                size     used    %used
4519af68         1        U-B----  1        1:25263              5000     5000   100.00
45270f40         2        U-B----  2        1:30263              5000     5000   100.00
45270fa8         3        U-B----  3        1:35263              5000     3456    69.12
453a0b18         4        U-B----  4        1:40263              5000        1     0.02
453a0b80         5        U-B----  5        1:45263              5000        1     0.02
453a0be8         6        U-B----  6        1:50263              5000        1     0.02
4da66578         7        U---C-L  7        2:53               102390        2     0.00
4da66648         8        A------  0        2:102443           102390        0     0.00
4da665e0         9        A------  0        2:204833           102390        0     0.00
4da666b0         10       A------  0        2:307223           102390        0     0.00
4da66720         11       A------  0        2:409613           102390        0     0.00
4da66798         12       A------  0        2:512003           102390        0     0.00
4da66818         13       A------  0        2:614393           102390        0     0.00
4da668a0         14       A------  0        2:716783           102390        0     0.00
4da66930         15       A------  0        2:819173           102390        0     0.00
4da669c8         16       A------  0        2:921563           102390        0     0.00
 16 active, 16 total

[informix@vm84145 ~]$ 

删除根目录中的逻辑日志文件命令

onparams -d -l 1 -y
onparams -d -l 2 -y
onparams -d -l 3 -y
onparams -d -l 4 -y
onparams -d -l 5 -y
onparams -d -l 6 -y

演示

[informix@vm84145 ~]$ onparams -d -l 1 -y
Logical log 1 successfully dropped.
[informix@vm84145 ~]$ onparams -d -l 2 -y
Logical log 2 successfully dropped.
[informix@vm84145 ~]$ onparams -d -l 3 -y
onparams -d -l 6 -yLogical log 3 successfully dropped.
[informix@vm84145 ~]$ onparams -d -l 4 -y
Logical log 4 successfully dropped.
[informix@vm84145 ~]$ onparams -d -l 5 -y
Logical log 5 successfully dropped.
[informix@vm84145 ~]$ onparams -d -l 6 -y
Logical log 6 successfully dropped.
[informix@vm84145 ~]$ onstat -l

Sinoregal SinoDB Dynamic Server Version 12.10.FC8 -- Quiescent -- Up 01:11:02 -- 253724 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  0        1024     783        36         21.75
      phybegin         physize    phypos     phyused    %used   
      3:53             1023945    114        0          0.00    

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      161360     13479      3593       12.0       3.8     
        Subsystem    numrecs    Log Space used
        OLDRSAM      161015     22713772      
        SBLOB        5          252           
        HA           42         1848          
        DDL          298        103704        

address          number   flags    uniqid   begin                size     used    %used
4da66578         7        U---C-L  7        2:53               102390       20     0.02
4da66648         8        A------  0        2:102443           102390        0     0.00
4da665e0         9        A------  0        2:204833           102390        0     0.00
4da666b0         10       A------  0        2:307223           102390        0     0.00
4da66720         11       A------  0        2:409613           102390        0     0.00
4da66798         12       A------  0        2:512003           102390        0     0.00
4da66818         13       A------  0        2:614393           102390        0     0.00
4da668a0         14       A------  0        2:716783           102390        0     0.00
4da66930         15       A------  0        2:819173           102390        0     0.00
4da669c8         16       A------  0        2:921563           102390        0     0.00
 10 active, 10 total

[informix@vm84145 ~]$ 

至此,逻辑日志迁移成功。

更新onconfig文件

由于添加了临时数据库空间,迁移了物理日志和逻辑日志,需要更新配置文件中对应的参数值。
查看逻辑日志文件数量,该参数已经更新。

[informix@vm84145 ~]$ onstat -c | grep LOGFILES
# LOGFILES     - The number of logical log files
LOGFILES        10              
[informix@vm84145 ~]$ onstat -g cfg | grep LOGFILES
LOGFILES                  10
[informix@vm84145 ~]$ 

查看逻辑日志大小,发现还是以前的配置值,需要更新逻辑日志文件大小。

[informix@vm84145 ~]$ onstat -c | grep LOGSIZE
# LOGSIZE      - The size of each logical log, in KB
LOGSIZE 10000
[informix@vm84145 ~]$ onstat -wf LOGSIZE=204780
Unable to open input file 'LOGSIZE=204780'
[informix@vm84145 ~]$ onstat -c | grep LOGSIZE
# LOGSIZE      - The size of each logical log, in KB
LOGSIZE 10000
[informix@vm84145 ~]$ onmode -wf LOGSIZE=204780
Value of LOGSIZE has been changed to 204780 kilobytes.
[informix@vm84145 ~]$ onstat -g cfg | grep LOGSIZE
LOGSIZE                   204780
[informix@vm84145 ~]$ 

由于创建了三个临时数据库空间,需要配置数据库实例可用的临时数据库空间

[informix@vm84145 ~]$ onstat -c | grep DBSPACETEMP
# DBSPACETEMP  - The list of dbspaces used to store temporary
DBSPACETEMP 
[informix@vm84145 ~]$ onmode -wf DBSPACETEMP=tempdbs1,tempdbs2,tempdbs3
Value of DBSPACETEMP has been changed to tempdbs1,tempdbs2,tempdbs3.
[informix@vm84145 ~]$ onstat -c | grep DBSPACETEMP
# DBSPACETEMP  - The list of dbspaces used to store temporary
DBSPACETEMP     tempdbs1,tempdbs2,tempdbs3 
[informix@vm84145 ~]$ onstat -g cfg | grep DBSPACETEMP
DBSPACETEMP               tempdbs1,tempdbs2,tempdbs3

onconfig参数优化

SBSPACENAME sbdbs1    
SYSSBSPACENAME sbdbs1 
NETTYPE soctcp,2,150,NET     
MULTIPROCESSOR 1    
VPCLASS cpu,num=2,noage 
CLEANERS 32            
DIRECT_IO 1
LOCKS 100000          
DEF_TABLE_LOCKMODE ROW 
SHMVIRTSIZE 2048000
SHMADD 81920
EXTSHMADD 8192
BUFFERPOOL      size=16K,buffers=100000,lrus=32,lru_min_dirty=5,lru_max_dirty=10

[informix@vm84145 ~]$ vim /home/informix/sinodb/etc/onconfig.sinodb 

修改参数后,重启数据库

[informix@vm84145 ~]$ onmode -ky
[informix@vm84145 ~]$ oninit -vy
Reading configuration file '/home/informix/sinodb/etc/onconfig.sinodb'...succeeded
Creating /INFORMIXTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 22166 kbytes...succeeded
Creating infos file "/home/informix/sinodb/etc/.infos.sinodb"...succeeded
Linking conf file "/home/informix/sinodb/etc/.conf.sinodb"...succeeded
Initializing rhead structure...rhlock_t 32768 (1024K)... rlock_t (13281K)... Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Initializing encryption-at-rest if necessary...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 32 flushers...succeeded
Initializing SDS Server network connections...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Validating chunks...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Init ReadAhead Daemon...succeeded
Init DB Util Daemon...succeeded
Initializing DBSPACETEMP list...succeeded
Init Auto Tuning Daemon...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Updating Global Row Counter...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Creating VP cache drain thread...succeeded
Creating limits manager thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5

验证

创建数据库

create database testdb in datadbs1 with log;

[informix@vm84145 ~]$ echo "create database testdb in datadbs1 with log;" | dbaccess

Database created.

Database closed.

[informix@vm84145 ~]$ 

创建表

create table tuser(cuserid int, cusername varchar(20));

echo "create table tuser(cuserid int, cusername varchar(20));" | dbaccess testdb
[informix@vm84145 ~]$ echo "create table tuser(cuserid int, cusername varchar(20));" | dbaccess testdb

Database selected.

Table created.

Database closed.

插入数据

echo "insert into tuser values(1, 'sinodb');" | dbaccess testdb

[informix@vm84145 ~]$ echo "insert into tuser values(1, 'sinodb');" | dbaccess testdb

Database selected.

1 row(s) inserted.

Database closed.

[informix@vm84145 ~]$ 

查询数据

select * from tuser;
echo "select * from tuser;" | dbaccess testdb

[informix@vm84145 ~]$ echo "select * from tuser;" | dbaccess testdb

Database selected.

    cuserid cusername            

          1 sinodb              

1 row(s) retrieved.

Database closed.

[informix@vm84145 ~]$