⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mchkpnt

📁 一个内存数据库的源代码这是服务器端还有客户端
💻
字号:
#!/bin/bash# The contents of this file are subject to the MonetDB Public License# Version 1.1 (the "License"); you may not use this file except in# compliance with the License. You may obtain a copy of the License at# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html## Software distributed under the License is distributed on an "AS IS"# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the# License for the specific language governing rights and limitations# under the License.## The Original Code is the MonetDB Database System.## The Initial Developer of the Original Code is CWI.# Portions created by CWI are Copyright (C) 1997-2007 CWI.# All Rights Reserved.#See the MonetDB Version 5 documentation for detailsfunction usage(){	echo "Usage: mchkpnt [options] "	echo "    --dbname=<database_name>"	echo "    --ascii=<yes/no> default no"	echo "    --tool=<mapi/jdbc> default mapi"	echo "    --chkpnt=<directory>"	echo "    --help"	exit 0}function diefunc() {	local linenr="$1" exitnr="$2"	shift 2	echo >&2	echo "A fatal error occurred at line ${linenr}!" >&2	echo -e "${*:-(no error message given)}" >&2	echo "Exit state: ${exitnr}" >&2	echo "Please check your configuration and try again" >&2	exit 1}# must set this option, else script will not expand aliasesshopt -s expand_aliasesalias die='diefunc "$LINENO" "$?"'DBFARM=$MONETDB5_PREFIX/var/MonetDB5/dbfarmDBLOGS=$MONETDB5_PREFIX/var/MonetDB5/dblogsCHKPNTDIR=$MONETDB5_PREFIX/var/MonetDB5/chkpntTAG=`date +%F-%H%M%S`# First perform some sanity checks[[ -z "$MONETDB5_PREFIX" ]] && die \"The MONETDB5_PREFIX environment variable has not been set.\n\It should point to where you have installed the build directory"# start the checkpoint process.[[ -d $DBFARM ]] || die "Database storage area '$DBFARM' is not accessible"# massage the argument list to prepare for callingDBNAME=""ASCII="no"TOOL="MapiClient -lsql"while [ $# -gt 0 ];do	case "$1" in		--help)		usage 		;;		--ascii=*)		ASCII="${1#--ascii=}"		case "$ASCII" in			[Yy][Ee][Ss]|[Yy])			ASCII="yes"			;;			[Nn][Oo]|[Nn])			ASCII="no"			;;			*)			die "--ascii: '$ASCII' not understood, use 'yes' or 'no'"			;;		esac		;;		--tool=*)			TOOL=${1%Client}			TOOL=${TOOL#--tool=}			case "$TOOL" in				[Mm]api)				TOOL="MapiClient -lsql"				;;				[Jj][Dd][Bb][Cc])				TOOL="JdbcClient"				;;				*)				die "--tool: '${1#--tool=}' not understood, use 'mapi' or 'jdbc'"			esac		;;		--dbname=*)		DBNAME="${1#--dbname=}"		;;		--chkpnt=*)		CHKPNTDIR="${1#--chkpnt=}"		;;		--tag=*)		TAG="${1#--tag=}"		;;		*)		usage		;;	esac	shiftdone[[ -z "$DBNAME" ]] && die "Database name missing"[[ -d "$DBFARM/$DBNAME" ]] || die "Database '$DBNAME' missing"if [ ! -d $CHKPNTDIR ]then	mkdir -p $CHKPNTDIRfi[[ -d $CHKPNTDIR ]] || die "Checkpoint directory '$CHKPNTDIR' not available"if [ ! -d "$CHKPNTDIR/$DBNAME" ]then	mkdir -p "$CHKPNTDIR/$DBNAME"fi[[ -d "$CHKPNTDIR/$DBNAME" ]] || die "Database checkpoint directory '$CHKPNTDIR/$DBNAME' is not accessible"CHKPFILE="$CHKPNTDIR/$DBNAME/$TAG"LOGFILE="$CHKPNTDIR/$DBNAME/$TAG-logs"[[ -f $CHKPFILE ]] && die "Checkpoint file '$CHKPFILE' already exist"[[ -f $LOGFILE ]] && die "Checkpoint log file '$LOGFILE' already exist"# Ready for preparing the checkpointcd $DBFARMecho "Checkpoint store $CHKPNTDIR"echo "Preparing checkpoint file '$DBNAME/$TAG'"if [ "$ASCII" == "yes" ];then	monetdb --start --dbname=$DBNAME || die "failed to start Mserver"	sleep 2	$TOOL --dump > ${CHKPFILE}.sql || die "Creation of dump failed"	gzip ${CHKPFILE}.sql || die "Compression of dump file failed"else	tar -cf ${CHKPFILE}.tar $DBNAME || die "Creation of checkpoint file failed"	gzip ${CHKPFILE}.tar || die "Compression of checkpoint file failed"ficd $DBLOGSecho "Preparing checkpoint log file '$DBNAME/$TAG-logs'"[[ -d "$DBNAME" ]] || die "No log directory available for '$DBNAME'"tar -cf ${LOGFILE}.tar $DBNAME || die "Creation of checkpoint log file failed"gzip ${LOGFILE}.tar || die "Compression of checkpoint log file failed"echo "Database checkpoint finished"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -