提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
Informix数据库根据参数自动创建实例shell脚本
前言
一、建立环境变量并使能
#make env_variable file and enable it
if [ ! -d "/opt/user_profile" ]
then
echo "Error: The library user_profile not exists!
else
echo "The library user_profile already exists!"
fi
if [ ! -e "/opt/user_profile/profile_example" ]
then
touch /opt/user_profile/profile_example
check
cat >/opt/user_profile/profile_example<<FLAGEOF
export INFORMIXDIR=/opt/xigeme_DB_Software_Bundle
export INFORMIXSERVER=example
export INFORMIXSQLHOSTS=\$INFORMIXDIR\etc\sqlhosts.example
export ONCONFIG=onconfig.example
export PATH=\$INFORMIXDIR/bin:.:\$PATH
FLAGEOF
source /opt/user_profile/profile_example
else
echo "The file profile_example is already exists!"
source /opt/user_profile/profile_example
fi
二、按需求修改onconfig配置文件
#modify onconfig.example
cp $INFORMIXDIR/etc/onconfig.std $INFORMIXDIR/etc/onconfig.example
sed -i 's/^DBSERVERNAME.*/DBSERVERNAME example/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^ROOTPATH.*/ROOTPATH $INFORMIXDIR\/dbs_1\/rootdbs/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^ROOTSIZE.*/ROOTSIZE 5000000/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^ROOTNAME.*/ROOTNAME rootdbs/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^FULL_DISK_INIT.*/FULL_DISK_INIT 1/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^MULTIPROCESSOR.*/MULTIPROCESSOR 1/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^NETTYPE.*/NETTYPE soctcp,10,50,CPU/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^PHYSFILES.*/PHYSFILE 1000000/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^LOGFILES.*/LOGFILES 3/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^LOGSIZE.*/LOGSIZE 1000000/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^SBSPACENAME.*/SBSPACENAME sbspace/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^TAPEDEV.*/TAPEDEV \/dev\/null/' $INFORMIXDIR/etc/onconfig.example
sed -i 's/^LTAPEDEV.*/LTAPEDEV \/dev\/null/' $INFORMIXDIR/etc/onconfig.example
三、创建rootdbspace,blobdbspace,tmpdbspace
#function of make dbsapce
function make_dbspacefile(){
if [ ! -e "$INFORMIXDIR/dbs_1/$1" ]
then
touch $INFORMIXDIR/dbs_1/$1
else
echo "The file $1 already exists!"
fi
}
#make dbspace
make_dbspacefile rootdbs
make_dbspacefile sbspace
make_dbspacefile datadbs1
#change the files' permisssion of dbs_1:
cd $INFORMIXDIR
chmod -R 660 $INFORMIXDIR/dbs_1/*
四、修改sqlhosts连接文件
#modify sqlhosts.example
cp $INFORMIXDIR/etc/sqlhosts.std $INFORMIXDIR/etc/sqlhosts.example
sed -i 's/^demo_on.*/example onsoctcp localhost 9088/' $INFORMIXSQLHOSTS
五、脚本使用前配置
1.在root用户下,在/opt/目录下创建user_profile文件夹,将此文件夹权限改为777。
2.在informix用户下source 自动化创建脚本文件。
总结
本文仅仅简单介绍了informix的实例创建自动化搭建的shell脚本,对于物理日志和逻辑日志的迁移还并没有涉及,在之后有时间会增加这部分的内容。