1.shell脚本和使用说明
1.1 脚本的使用
将脚本和数据库安装包放在同一个文件夹下,前提如下:
- 服务器内没有gbasedbt用户
- 数据库安装的前提条件需要满足(数据库安装部分有一些软件和插件的要求)
- /home下有足够的空间
将数据库脚本和安装包放在一个文件夹下即可执行
1.2脚本说明
由于在安装过程中用户做了切换,所以共有两个脚本,分别是install_app和install_data
- install_app是对数据库软件的安装
- 操作系统用户的创建
- 压缩包的解压
- 安装配置的一些默认输入
- 和脚本的后续处理
- install_data
- 主要是数据库的初始化部分,初始化资源较小,后续可调整
2.shell脚本使用的演示
- 需要手动输入的部分都会有注释说明
--查看当前文件夹
[root@iZ2ze5s78e4tanwe5q2znxZ test]# pwd
/home/test
--下列是存放的文件,第一个是安装包,执行install_app脚本即可
[root@iZ2ze5s78e4tanwe5q2znxZ test]# ls -l
total 519380
-rwxr-xr-x 1 root root 346388480 May 16 09:27 GBase8sV8.8_TL_3.5.1_x86_64.tar
-rwxr-xr-x 1 root root 2246 May 26 22:19 install_app.sh
-rwxr-xr-x 1 root root 5923 May 26 22:15 install_data.sh
--开始执行脚本
[root@iZ2ze5s78e4tanwe5q2znxZ test]# ./install_app.sh
------------------------------------------
------------------------------------------
-----------------创建用户-----------------
Changing password for user gbasedbt.
New password: BAD PASSWORD: The password contains less than 3 character classes
Retype new password: passwd: all authentication tokens updated successfully.
用户已创建成功
--------------处理安装包-----------------
当前文件夹路径为:/home/test
--由于此脚本针对某个版本,故默认为那个版本,所以需要输入自己的安装包名称
输入安装包名称,默认为GBase8s-JYV8.6_TL_3.5.0_3X2_4_73ea52_Kylin10_Loongson3A5000.tar: GBase8sV8.8_TL_3.5.1_x86_64.tar
/home/test/GBase8sV8.8_TL_3.5.1_x86_64.tar
/home/test/GBase8sV8.8_TL_3.5.1_x86_64.tar
--确定一下安装包,如果是则回车即可,不是输入n
安装包存在,请确认是否是此安装包,默认是(y/n):
安装包确定
ids_install
onsecurity
doc/
doc/ids_machine_notes_12.10.txt
doc/ids_unix_relnotes_12.10.html
ids.properties
.gbase.properties
Preparing to install...
WARNING: /tmp does not have enough disk space!
Attempting to use /root for install base and tmp dir.
Extracting the JRE from the installer archive...
- 下面一部分无手动输入部分,但是为了方便,也将内容放置在下面
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...
===============================================================================
GBase Software Bundle (created with InstallAnywhere)
-------------------------------------------------------------------------------
Preparing CONSOLE Mode Installation...
===============================================================================
Getting Started
---------------
This application will guide you through the installation of GBase Software
Bundle.
Copyright General Data Corporation 2014, 2024. All rights reserved.
1. Release Notes
The Release Notes can be found in
/home/gbasedbt/install/doc/ids_unix_relnotes_12.10.html.
2. Launch Information Center
Access the GBase Information Center at http://www.gbase.cn.
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 Agreement
-----------------
Installation and Use of GBase Software Bundle Requires Acceptance of the
Following License Agreement:
Thank you for choosing GBase product!
Please read carefully the following licencing agreement before installing any
product: TIANJIN GENERAL DATA TECHNOLOGY CO. LTD. LICENSE AGREEMENT
READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSETERMS
(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWAREMEDIA PACKAGE.
BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF THIS
AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE YOUR
ACCEPTANCE OF THESE TERMS. IF YOU DO NOT AGREE TO ALL THESE TERMS, PROMPTLY
RETURN THE UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND.
1. LICENSE TO USE. GeneralData grants you a non-exclusive and non-transferable
license for the internal use only of the accompanying software and
documentation and any error corrections provided by GeneralData(collectively
"Software"), by the number of users and the class of computer hardware for
which the corresponding fee has been paid.
2. RESTRICTIONS. Software is confidential and copyrighted. Title to Software
PRESS <ENTER> TO CONTINUE:
and all associated intellectual property rights is retained by GeneralData
and/or its licensors. Except as specifically authorized in any Supplemental
License Terms, you may not make copies of Software, other than a single copy
of Software for archival purposes. Unless enforcement is prohibited by
applicable law, you may not modify, decompile, or reverse engineer Software.
You acknowledge that Software is not designed, licensed or intended for use in
the design, construction, operation or maintenance of any nuclear facility.
GeneralData disclaims any express or implied warranty of fitness for such
uses. No right, title or interest in or to any trademark, service mark, logo or
trade name of GeneralData or its licensors is granted under this Agreement.
3. DISCLAIMER OF WARRANTY. Unless specified in this agreement, all express of
implied conditions, representations and warranties, including any implied
warranty of merchantability, fitness for aparticular purpose or
non-infringement are disclaimed, except to theextent that these disclaimers
are held to be legally invalid.
4. LIMITATION OF LIABILITY. To the extent not prohibited by law, in no event
will GeneralData or its licensors be liable for any lost revenue, profit or
data, or for special, indirect, consequential, incidental orpunitive damages,
however caused regardless of the theory of liability, arising out of or
related to the use of or inability to use software, even if GeneralData has
PRESS <ENTER> TO CONTINUE:
been advised of the possibility of such damages. In no event will
GeneralData's libility to you, whether incontract, tort(including negligence),
or otherwise, exceed the amount paid by you for Software under this Agreement.
The foregoing limitations will apply even if the above stated warranty fails
of itsessential purpose.
5. TERMINATION. This Agreement is effective until terminated. You may terminate
this Agreement at any time by destroying all copies of Software. This
Agreement will terminate immediately without noticefrom GeneralData if you
fail to comply with any provision of this Agreement. Upon Termination, you
must destroy all copies of Software.
6. EXPORT REGULATIONS. All Software and technical data delivered under this
Agreement are subject to US export control laws and may be subject to export
or import regulations in other countries. You agree to comply strictly with
all such laws and regulations and acknowledge that you have the responsibility
to obtain such licenses to export, re-export, or import as may be required
after delivery to you.
7. CHINESE GOVERNMENT RESTRICTED. If Software is being acquired by or on behalf
PRESS <ENTER> TO CONTINUE:
of the Chinese Government, then the Government's rights in Software and
accompanying documentation will be only as set forth in this Agreement.
8. GOVERNING LAW. Any action related to this Agreement will be governed by
Chinese law: "COPYRIGHT LAW OF THE PEOPLE'S REPUBLIC OF CHINA", "PATENT LAW OF
THE PEOPLE'S REPUBLIC OF CHINA", "TRADEMARK LAW OF THE PEOPLE'S REPUBLIC OF
CHINA", "COMPUTER SOFTWARE PROTECTION REGULATIONS OF THE PEOPLE'S REPUBLIC OF
CHINA". No choice of law rules of any jurisdiction will apply."
9. SEVERABILITY. If any provision of this Agreement is held to be
unenforceable, this Agreement will remain in effect with the provision
omitted, unless omission would frustrate the intent of the parties, in which
case this Agreement will immediately terminate.
10. INTEGRATION. This Agreement is the entire agreement between you and
GeneralData relating to its subject matter. It supersedes all prior or
contemporaneous oral or written communications, proposals, representations and
warranties and prevails over any conflicting or additional terms of any quote,
order, acknowledgment, or other communication between the parties relating to
its subject matter during the term of this Agreement. No modification of this
Agreement will be binding, unless in writing and signed by an authorize
depresentative of each party. When the translation document has the different
PRESS <ENTER> TO CONTINUE:
meaning or has the conflicting views with Chinese original text conflict,
should take the laws and regulations promulgation unit as well as the
GeneralData issue Chinese original text as the standard.
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): DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N):
===============================================================================
Installation Location
---------------------
Choose location for software installation.
Default Install Folder: /opt/GBASE/gbase
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
:
INSTALL FOLDER IS: /home/gbasedbt/gbase
IS THIS CORRECT? (Y/N):
===============================================================================
Installation or Distribution
----------------------------
Select the installation type.
Typical: Install the database server with all features and a database server
that
is configured with default values. Includes:
** Client Software Development Kit (CSDK)
** Java Database Connectivity (JDBC)
Minimum disk space required: 700-800MB
Custom: Install the database server with specific features and software that
you need.
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)
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::
===============================================================================
Server Instance Creation
------------------------
Create a server instance?
->1- Yes - create an instance
2- No - do not create an instance
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::
===============================================================================
Installation Summary
--------------------
Please review the following before continuing:
Product Name:
GBase Software Bundle
Install Folder:
/home/gbasedbt/gbase
Product Features:
GBase 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,
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,
Global Language Support (GLS),
Chinese
Disk Space Information (for Installation Target):
Required: 579,287,501 Bytes
Available: 28,169,125,888 Bytes
PRESS <ENTER> TO CONTINUE:
===============================================================================
Ready To Install
----------------
InstallAnywhere is now ready to install GBase Software Bundle onto your system
at the following location:
/home/gbasedbt/gbase
PRESS <ENTER> TO INSTALL:
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Installation Complete
---------------------
Congratulations! GBase Software Bundle installation is complete.
Product install status:
GBase: Successful
GBase Connect: Successful
GBase 8s V8.8
- 上述软件的安装已经完成,下面进入到了数据库初始化阶段
For more information about using GBase products, see the GBase Information
Center at http://www.gbase.cn.
PRESS <ENTER> TO EXIT THE INSTALLER:
--此部分需要输入root密码,为了方便,使用了明文的方式
请输入root密码:Fxl.1q@W3e$R
--下面三个部分为输入的安装路径,实例名称,IP地址和端口号,由于是针对情景使用,所以部分写死了,后续会进行优化
Password: 输入数据库软件安装地址(默认/home/gbasedbt/gbase):
输入实例名称(默认node1):
输入IP地址(默认127.0.0.1):
输入端口号(默认9088):
Your evaluation license will expire on 2025-05-26 00:00:00
Reading configuration file '/home/gbasedbt/gbase/etc/onconfig.node1'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 4310 kbytes...succeeded
Creating infos file "/home/gbasedbt/gbase/etc/.infos.node1"...succeeded
Linking conf file "/home/gbasedbt/gbase/etc/.conf.node1"...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
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 periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
- 后续部分没有了手动输入的部分,仅是为了步骤完整而放置的内容,第一行由于是整数比较,好像出现了一个格式报错,后续更正
/home/gbasedbt/install/install_data.sh: line 81: [: 6.2: integer expression expected
CPU is OK
Your evaluation license will expire on 2025-05-26 00:00:00
Database selected.
1 row(s) retrieved.
Database closed.
数据库的数量:6
Your evaluation license will expire on 2025-05-26 00:00:00
onclean: Cleaning up processes and resources for 'node1'...
- Looking for the master daemon process: 127260
- Looking for the shmem key: 52574803
- Looking for semaphore ID: 32779
- Looking for the shmem key: 52574801
- Looking for the shmem key: 52574802
- Looking for the shmem key: 52574804
- Looking for the shmem key: 52574805
- Looking for the shmem key: 52574806
- Looking for the shmem key: 52574807
- Looking for the shmem key: 52574808
Password: Your evaluation license will expire on 2025-05-26 00:00:00
Reading configuration file '/home/gbasedbt/gbase/etc/onconfig.node1'...succeeded
Creating /GBASEDBTTMP/.infxdirs...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 4310 kbytes...succeeded
Creating infos file "/home/gbasedbt/gbase/etc/.infos.node1"...succeeded
Linking conf file "/home/gbasedbt/gbase/etc/.conf.node1"...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
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 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 periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
Your evaluation license will expire on 2025-05-26 00:00:00
Verifying physical disk space, please wait ...
Space successfully added.
** WARNING ** A level 0 archive of Root DBSpace will need to be done.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Log operation started. To monitor progress, use the onstat -l command.
Logical log successfully added.
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 1 successfully dropped.
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 2 successfully dropped.
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 3 successfully dropped.
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 4 successfully dropped.
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 5 successfully dropped.
Your evaluation license will expire on 2025-05-26 00:00:00
Logical log 6 successfully dropped.
3.脚本内容
3.1 install_app
#!/bin/bash
echo '------------------------------------------'
echo '------------------------------------------'
echo '-----------------创建用户-----------------'
useradd -U -m gbasedbt
passwd gbasedbt <<EOF
gbasedbt
gbasedbt
EOF
USER_INFO=`cat /etc/passwd|grep gbasedbt|grep '/bin/sh'`
if [ -z '$USER_INFO' ]; then
echo '用户正常'
else
sed -i 's/\(.*bin\)\/sh/\1\/bash/g' /etc/passwd
fi
echo "用户已创建成功"
echo "--------------处理安装包-----------------"
CURRENT_FOLDER=`pwd`
echo "当前文件夹路径为:$CURRENT_FOLDER"
read -p $"输入安装包名称,默认为GBase8s-JYV8.6_TL_3.5.0_3X2_4_73ea52_Kylin10_Loongson3A5000.tar: " INSTALL_PACKAGE
if [ -z "$INSTALL_PACKAGE" ]; then
INSTALL_PACKAGE="GBase8s-JYV8.6_TL_3.5.0_3X2_4_73ea52_Kylin10_Loongson3A5000.tar"
else
INSTALL_PACKAGE=$INSTALL_PACKAGE
fi
INSTALL_PACKAGE_PATH=$CURRENT_FOLDER/$INSTALL_PACKAGE
echo $INSTALL_PACKAGE_PATH
if [ -f "$INSTALL_PACKAGE_PATH" ]; then
echo $INSTALL_PACKAGE_PATH
read -p "安装包存在,请确认是否是此安装包,默认是(y/n): " INSTALL_PACKAGE_ANSWER
if [ -z "$INSTALL_PACKAGE_ANSWER" ] || [ "$INSTALL_PACKAGE_ANSWER" = "y" ];then
echo "安装包确定"
INSTALL_PACKAGE_TAR_PATH=/home/gbasedbt/install
if [ -d "$INSTALL_PACKAGE_TAR_PATH" ]; then
INSTALL_PACKAGE_TAR_PATH=$INSTALL_PACKAGE_TAR_PATH$(date +'%Y%m%d_%H%M%S')
echo $INSTALL_PACKAGE_TAR_PATH
mkdir $INSTALL_PACKAGE_TAR_PATH
echo '正在解压'
tar -xvf $INSTALL_PACKAGE_PATH -C $INSTALL_PACKAGE_TAR_PATH
chown -R gbasedbt:gbasedbt /home/gbasedbt/*
chmod +x /home/gbasedbt/*
else
mkdir $INSTALL_PACKAGE_TAR_PATH
tar -xvf $INSTALL_PACKAGE_PATH -C $INSTALL_PACKAGE_TAR_PATH
chown -R gbasedbt:gbasedbt /home/gbasedbt/*
chmod +x /home/gbasedbt/*
fi
else
echo "安装包错误"
exit 1
fi
else
echo '没有'
fi
/home/gbasedbt/install/ids_install <<EOF
Y
/home/gbasedbt/gbase
Y
2
EOF
sync;
echo 3> /proc/sys/vm/drop_caches
ipcrm -a
cp $CURRENT_FOLDER/install_data.sh /home/gbasedbt/install/install_data.sh
chown -R gbasedbt:gbasedbt /home/gbasedbt/install/install_data.sh
chmod +x /home/gbasedbt/install/install_data.sh
su - gbasedbt -c "sh /home/gbasedbt/install/install_data.sh"
3.2 install_data
#!/bin/bash
read -p $"请输入root密码:" ROOT_PW
echo $ROOT_PW|su -c "sync;echo 3 >/proc/sys/vm/drop_caches ; ipcrm -a; exit"
read -p $'输入数据库软件安装地址(默认/home/gbasedbt/gbase):' install_path
read -p $'输入实例名称(默认node1):' DBNAME
read -p $'输入IP地址(默认127.0.0.1):' DBIP
read -p $'输入端口号(默认9088):' DBPORT
if [ -z "$install_path" ]
then
install_path='/home/gbasedbt/gbase'
else
install_path=$install_path
fi
if [ -z "$DBNAME" ]
then
DBNAME='node1'
else
DBNAME=$DBNAME
fi
if [ -z "$DBPORT" ]
then
DBPORT='9088'
else
DBPORT=$DBPORT
fi
if [ -z "$DBIP" ]
then
DBIP='127.0.0.1'
else
DBIP=$DBIP
fi
echo ''
cp $install_path/etc/onconfig.std $install_path/etc/onconfig.$DBNAME
cp $install_path/etc/sqlhosts.std $install_path/etc/sqlhosts.$DBNAME
DBNAME_dbs=$DBNAME'_dbs'
rm -rf $install_path/$DBNAME_dbs
mkdir -p $install_path/$DBNAME_dbs
chmod 755 $install_path/$DBNAME_dbs
touch $install_path/$DBNAME_dbs/rootdbs
chmod 660 $install_path/$DBNAME_dbs/rootdbs
sed -i "s#^ROOTPATH.*#ROOTPATH $install_path/$DBNAME_dbs/rootdbs#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^LOGSIZE.*#LOGSIZE 10000#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^ROOTSIZE.*#ROOTSIZE 200000#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#MSGPATH.*#MSGPATH $install_path/etc/$DBNAME.log#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^DBSERVERNAME.*#DBSERVERNAME $DBNAME#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^SERVERNUM.*#SERVERNUM 1#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^FULL_DISK_INIT.*#FULL_DISK_INIT 1#g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^TAPEDEV.*#TAPEDEV /dev/null #g" $install_path/etc/onconfig.$DBNAME
sed -i "s#^LTAPEDEV.*#LTAPEDEV /dev/null #g" $install_path/etc/onconfig.$DBNAME
echo "$DBNAME onsoctcp $DBIP $DBPORT" >> $install_path/etc/sqlhosts.$DBNAME
echo "export GBASEDBTSERVER=$DBNAME" > /home/gbasedbt/profile.$DBNAME
echo "export KAIOON=0" >> /home/gbasedbt/profile.$DBNAME
echo "export GBASEDBTDIR=$install_path" >> /home/gbasedbt/profile.$DBNAME
echo "export GBASEDBTSQLHOSTS=$install_path/etc/sqlhosts.$DBNAME" >> /home/gbasedbt/profile.$DBNAME
echo "export ONCONFIG=onconfig.$DBNAME" >> /home/gbasedbt/profile.$DBNAME
echo "export PATH=$install_path/bin:\$PATH" >> /home/gbasedbt/profile.$DBNAME
echo "export DB_LOCALE=zh_CN.utf8" >> /home/gbasedbt/profile.$DBNAME
echo "export CLIENT_LOCALE=zh_CN.utf8" >> /home/gbasedbt/profile.$DBNAME
echo "export GL_USEGLU=1" >> /home/gbasedbt/profile.$DBNAME
echo 'source /home/gbasedbt/profile.node1 '>> /home/gbasedbt/.bash_profile
source /home/gbasedbt/.bash_profile
. /home/gbasedbt/profile.$DBNAME
oninit -ivy
sleep 100
sed -i 's#BUFFERPOOL size=2k.*#BUFFERPOOL size=2k,buffers=10000,lrus=8,lru_min_dirty=50,lru_max_dirty=60#g' $install_path/etc/onconfig.$DBNAME
echo 'BUFFERPOOL size=16k,buffers=10000,lrus=8,lru_min_dirty=50,lru_max_dirty=60' >> $install_path/etc/onconfig.$DBNAME
CPU_FZ='40'
CPU_USE=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
if [ "$CPU_USE" -gt "$CPU_FZ" ]; then
echo "CPU过高,等待30s: $CPU_USE "
sleep 60
else
echo 'CPU is OK'
fi
SQL="echo 'select count(*) from sysmaster:sysdatabases'| dbaccess sysmaster"
RE="6"
NUM_COUNT=1
while true; do
RESULT=$(eval $SQL)
if echo "$RESULT" | grep -q "$RE"; then
echo "数据库的数量:$RE"
break
fi
echo "初始化进行中,等待5秒后重试连接..."
NUM_COUNT=$((NUM_COUNT+1))
echo $NUM_COUNT
if [ "$NUM_COUNT" -eq "3" ]; then
onclean -ky
echo $ROOT_PW|su -c "sync;echo 3 >/proc/sys/vm/drop_caches ; ipcrm -a; exit"
oninit -vy
sleep 10
SQL_SYSMASTER=$(echo "select name from sysmaster:sysdatabases where name ='sysmaster'"| dbaccess sysmaster )
RE_SYSMASTER="sysmaster"
RESU_SYSMASTER=$SQL_SYSMASTER
if echo "$RESU_SYSMASTER" | grep -q "$RE_SYSMASTER"; then
echo "sysmastery is exists"
else
dbaccess - $install_path/etc/sysmaster.sql
fi
SQL_SYSUSER=$(echo "select name from sysmaster:sysdatabases where name ='sysuser'"| dbaccess sysmaster )
RE_SYSUSER="sysuser"
RESU_SYSUSER=$SQL_SYSUSER
if echo "$RESU_SYSUSER" | grep -q "$RE_SYSUSER"; then
echo "sysuser is exists"
else
dbaccess - $install_path/etc/sysuser.sql
fi
SQL_SYSUTILS=$(echo "select name from sysmaster:sysdatabases where name ='sysutils'"| dbaccess sysmaster )
RE_SYSUTILS="sysutils"
RESU_SYSUTILS=$SQL_SYSUTILS
if echo "$RESU_SYSUTILS" | grep -q "$RE_SYSUTILS"; then
echo "sysutils is exists"
else
dbaccess - $install_path/etc/sysutils.sql
fi
SQL_SYSUTILS=$(echo "select name from sysmaster:sysdatabases "| dbaccess sysmaster )
RE_SYSUTILS="sysutils"
RESU_SYSUTILS=$SQL_SYSUTILS
break
fi
sleep 60
done
onclean -ky
echo $ROOT_PW|su -c "sync;echo 3 >/proc/sys/vm/drop_caches ; ipcrm -a; exit"
sleep 10
oninit -vy
. /home/gbasedbt/profile.$DBNAME
install_path=/home/gbasedbt/gbase
DBNAME_dbs=node1_dbs
sleep 10
L1=$install_path/$DBNAME_dbs/llogdbs
P1=$install_path/$DBNAME_dbs/plogdbs
D1=$install_path/$DBNAME_dbs/datadbs1
T1=$install_path/$DBNAME_dbs/tempdbs1
B1=$install_path/$DBNAME_dbs/bindbs
S1=$install_path/$DBNAME_dbs/sbdbs
touch $L1 $P1 $D1 $T1 $B1 $S1
chmod -R 660 $install_path/$DBNAME_dbs/*
onspaces -c -d llogdbs -p $L1 -o 0 -s 2048000
sleep 10
onspaces -c -P plogdbs -p $P1 -o 0 -s 2048000
sleep 10
onspaces -c -d datadbs1 -p $D1 -o 0 -s 2048000 -k 16
sleep 10
onspaces -c -d tempdbs1 -p $T1 -o 0 -s 2048000 -k 16 -t
sleep 10
onspaces -c -b bindbs -p $B1 -o 0 -s 2048000 -g 16
sleep 10
onspaces -c -S sbdbs -p $S1 -o 0 -s 2048000
for i in {1..10};do onparams -a -d llogdbs -s 180000;done
for i in {1..10};do onmode -l;done
onmode -c
onmode -c
for i in {1..6};do onparams -d -l $i -y;done