月度归档:2014年11月

如何让informix数据库再次进入到恢复模式,来完成之前失败的数据备份恢复操作?

如何让informix数据库再次进入到恢复模式,来完成之前失败的数据备份恢复操作?
本文主要介绍,在对数据库的备份进行恢复操作失败的情况下,如何再次进入恢复模式,继续之前的恢复数据库操作,而不必重头再次做起。
通常情况下,数据库如果正在做备份的恢复工程中,如果把数据库停下来,则我们需要重头执行整个数据库恢复操作,这样会比较浪费客户的时间,有没有更好的方法呢?
如果数据库的物理恢复完成的情况下,我们中断了数据库的逻辑日志恢复阶段,则我们可以有以下机会跳过再次进行物理恢复数据的过程,而直接进入到未完成的逻辑日志恢复阶段。
步骤:
1. 首先检查online.log, bar_act.log确认数据库的物理恢复已经完成,如果数据物理恢复阶段没有完成的情况下,需要重头执行恢复命令。
2. onmode -ky把数据库停下来。
3. onbar -r , 或者 onbar -r -l 来继续恢复逻辑日志,并把数据库转换到静止模式。
用户可以使用以上步骤,而不必关心ONCONFIG中的RESTARTABLE_RESTORE参数配置。
RESTARTABLE_RESTORE该参数只使用于onbar -RESTART命令的执行,缺省值为ON.
更多信息可以参考 IBM Informix Backup & Restore Guide等资料。

如何清理hung住的分布式事务

如何清理hung住的分布式事务

[清理两阶段提交不能完成的事务]

环境:

IDS 分布式数据库,遵循两阶段提交协议

问题描述:

重启IDS后仍然不能清理一些XA事务 继续阅读

Recovery of RAID and LVM2 Volumes

Raid and Logical Volume Managers are great, until you lose data.

The combination of Linux software RAID (Redundant Array of Inexpensive Disks) and LVM2 (Logical Volume Manager, version 2) offered in modern Linux operating systems offers both robustness and flexibility, but at the cost of complexity should you ever need to recover data from a drive formatted with software RAID and LVM2 partitions. I found this out the hard way when I recently tried to mount a system disk created with RAID and LVM2 on a different computer. The first attempts to read the filesystems on the disk failed in a frustrating manner.

I had attempted to put two hard disks into a small-form-factor computer that was really only designed to hold only one hard disk, running the disks as a mirrored RAID 1 volume. (I refer to that system as raidbox for the remainder of this article.) This attempt did not work, alas. After running for a few hours, it would power-off with an automatic thermal shutdown failure. I already had taken the system apart and started re-installing with only one disk when I realized there were some files on the old RAID volume that I wanted to retrieve.

Recovering the data would have been easy if the system did not use RAID or LVM2. The steps would have been to connect the old drive to another computer, mount the filesystem and copy the files from the failed volume. I first attempted to do so, using a computer I refer to as recoverybox, but this attempt met with frustration.

继续阅读

LVM recovery tale

Over the weekend I had the worrying experience of losing my LVM settings and potentially all my data… a quick search on the web showed a confusing set of information, much of it for older versions of LVM and therefore rather suspect.

Well, I recovered all my data and it was really quite simple, so I’ve written up what I did in the hope that someone else, in a similar situation, will find it useful. It’s a scary thing, losing the whole hard disk and knowing that, in reality, its all there. 继续阅读

The specified table (mon_syssqltrace) is not in the database

在informix 11.50中,tmp/online.log日志中出现如下错误信息:

09:15:01  SCHAPI: Error -206 The specified table (mon_syssqltrace) is not in the database.
09:15:01  SCHAPI: Type: SENSOR, Name: Save SQL Trace, Location: NULL.
09:15:01  SCHAPI: Error -111 ISAM error:  no record found.
09:15:01  SCHAPI: Type: SENSOR, Name: Save SQL Trace, Location: NULL. 继续阅读

在 IDS 9.4 中更高效地创建表和索引

简介

任何稍微了解 SQL(结构化查询语言)的人都知道如何在数据库中创建表和索引。但是就系统和数据库性能而言,如何才能更高效地创建表和索引呢?以下是在创建表和索引之前需要考虑的事项:

  • 数据库空间(Dbspace)
  • 区段大小(Extent size)
  • 锁模式
  • 约束键字

本文将仔细研究所有这些考虑事项,并通过工作环境中收集的实际例子进行说明。 继续阅读

IP Range To CIDR Convertor

IP Range To CIDR Convertor

// Convert a given Ip range to CIDR notation.

# cat rangeToCidr
/* rangeToCidr.c - Convert Ip ranges to CIDR */

/*
modification history http://snippets.dzone.com/tag/cidr
--------------------
,17sep08,karn written
*/

/* includes */

#include
#include
#include
#include #include
#include
#include
#include

/* defines */
//#define DBG
#ifdef DBG
#define DEBUG(x) fprintf(stderr,x)
#else
#define DEBUG
#endif /* DBG */

#define IP_BINARY_LENGTH 32+1 /* 32 bits ipv4 address +1 for null */
#define IP_HEX_LENGTH 10
#define MAX_CIDR_MASK 32
#define MAX_CIDR_LEN 18+1 /*255.255.255.255/32*/

/* Forward declaratopms */
void rangeToCidr(uint32_t from ,uint32_t to,
void (callback)(char *cidrNotation));
int ipToBin(uint32_t ip , char * pOut);

void printNotation(char *cidrNotation);

/* Globals */

/*******************************************************************************
*
* ipToBin - convert an ipv4 address to binary representation
* and pads zeros to the beginning of the string if
* the length is not 32
* (Important for ranges like 10.10.0.1 - 20.20.20.20 )
*
* ip - ipv4 address on host order
* pOut - Buffer to store binary.
*
* RETURNS: OK or ERROR
*/

int ipToBin(uint32_t ip , char * pOut)
{
char hex[IP_HEX_LENGTH];
int i;
int result=0;
int len;
char pTmp[2];
int tmp;
/*
* XXX: Could use bit operations instead but was easier to debug
*/
char binMap[16][5] = {
"0000","0001","0010","0011", "0100",
"0101","0110","0111","1000", "1001",
"1010","1011","1100", "1101","1110","1111",
};
pTmp[1]=0x0;
memset(hex,0x0,sizeof(hex));
len=sprintf(hex,"%x",ip);

for(i=0;i IP_BINARY_LENGTH-1)
return -1;

/* Success */
return 0;
}

/*******************************************************************************
* main :
*
* arg1 : Start Ip Address
* arg2 : End Ip address
*/

int main (int argc,char **argv)
{
long fromIp, toIp;
struct in_addr addr;
if(argc !=3 )
{
printf("Usage: %s \n",argv[0]);
return(0);
}

/* All operation on host order */
if (inet_aton(argv[1],&addr) == 0)
goto error;
fromIp = ntohl(addr.s_addr);

if (inet_aton(argv[2],&addr) ==0)
goto error;
toIp = ntohl(addr.s_addr);

rangeToCidr(fromIp,toIp,printNotation);

return 0;
error:
printf("Invalid Argument\n");
return -EINVAL;
}

/*******************************************************************************
*
* rangeToCidr - convert an ip Range to CIDR, and call 'callback' to handle
* the value.
*
* from - IP Range start address
* to - IP Range end address
* callback - Callback function to handle cidr.
* RETURNS: OK or ERROR
*/

void rangeToCidr(uint32_t from ,uint32_t to,
void (callback)(char *cidrNotation))
{
int cidrStart = 0;
int cidrEnd = MAX_CIDR_MASK - 1;
long newfrom;
long mask;
char fromIp[IP_BINARY_LENGTH];
char toIp[IP_BINARY_LENGTH];
struct in_addr addr;
char cidrNotation[MAX_CIDR_LEN];

memset (fromIp,0x0,sizeof(fromIp));
memset (toIp,0x0,sizeof(toIp));

if ( ipToBin(from,fromIp) != 0 )
return;
if ( ipToBin(to,toIp) != 0 )
return;

DEBUG ("from %lu to %lu\n", from,to);
DEBUG("from %s\n",fromIp);
DEBUG("to %s\n",toIp);

if(from < to ) { /* Compare the from and to address ranges to get the first * point of difference */ while(fromIp[cidrStart]==toIp[cidrStart]) cidrStart ++; cidrStart = 32 - cidrStart -1 ; DEBUG("cidrStart is %u\n",cidrStart); /* Starting from the found point of difference make all bits on the * right side zero */ newfrom = from >> cidrStart +1 << cidrStart +1 ; /* Starting from the end iterate reverse direction to find * cidrEnd */ while( fromIp[cidrEnd] == '0' && toIp[cidrEnd] == '1') cidrEnd --; cidrEnd = MAX_CIDR_MASK - 1 - cidrEnd; DEBUG("cidrEnd is %u\n",cidrEnd); if(cidrEnd <= cidrStart) { /* * Make all the bit-shifted bits equal to 1, for * iteration # 1. */ mask = pow (2, cidrStart ) - 1; DEBUG("it1 is %lu \n",newfrom | mask ); rangeToCidr (from , newfrom | mask, callback); DEBUG("it2 is %lu \n",newfrom | 1 << cidrStart); rangeToCidr (newfrom | 1 << cidrStart ,to ,callback); } else { addr.s_addr = htonl(newfrom); sprintf(cidrNotation,"%s/%d", inet_ntoa(addr), MAX_CIDR_MASK-cidrEnd); if (callback != NULL) callback(cidrNotation); } } else { addr.s_addr = htonl(from); sprintf(cidrNotation,"%s/%d",inet_ntoa(addr),MAX_CIDR_MASK); if(callback != NULL) callback(cidrNotation); } } /******************************************************************************* * * printNotation - This is an example callback function to handle cidr notation. * * RETURNS: */ void printNotation(char *cidrNotation) { printf("%s\n",cidrNotation); }
编译:

# gcc rangeToCidr.c -lm -o rang2cidr

Perl版本:

#!/usr/bin/perl -w
# range2cidr.pl

use Net::CIDR;
use Net::CIDR ':all';

if (@ARGV == 0) {
die "Usage Example: $0 192.168.0.0-192.168.255.255 \n";
}

print join("\n", Net::CIDR::range2cidr("$ARGV[0]")) . "\n";

合并CIDR:

#!/usr/bin/perl

use Net::CIDR::Lite;

my $cidr = Net::CIDR::Lite->new;

$cidr->add("202.38.175.0/24");
$cidr->add("202.38.174.0/24");
$cidr->add("202.38.173.0/24");
$cidr->add("202.38.172.0/24");
$cidr->add("202.38.171.0/24");
$cidr->add("202.38.170.0/24");
$cidr->add("202.38.169.0/24");
$cidr->add("202.38.168.0/24");

print "$_\n" for $cidr->list;
// 执行结果:202.38.168.0/21

Linux: Subnet (CIDR) Calculator

I‘m new to networking and need help with network settings. I’m looking for a tool for calculating available host address ranges with CIDR using Linux command prompt. How do I use subnet calculator under Linux or UNIX?
Linux comes with various IP subnet calculator that will help you with network settings. Once such program is Sipcalc which is an ip subnet calculator. You can install it as follows under Debian or Ubuntu Linux:
$ sudo apt-get update
$ sudo apt-get install sipcalc
继续阅读

Xtrabackup:MySQL DBA的必备工具

Xtrabackuppercona开发的产品,可以看做是InnoDB Hotbackup的免费替代品。

Percona XtraBackup is the world’s only open-source, free MySQL hot backup software that performs non-blocking backups for InnoDB, XtraDB, and MyISAM databases0. It makes MySQL hot backups for all versions of Percona Server, MySQL, and MariaDB. It performs streaming, compressed, and incremental MySQL backups.

What are the features of Percona XtraBackup?

Here is a short list of XtraBackup features. See the documentation for more.

  • Create hot InnoDB backups without pausing your database
  • Make incremental backups of MySQL
  • Stream compressed MySQL backups to another server
  • Move tables between MySQL servers online
  • Create new MySQL replication slaves easily
  • Backup MySQL without adding load to the server

继续阅读