commit
591cd1f297
|
@ -24,7 +24,7 @@
|
|||
# dataDir /var/lib/taos
|
||||
|
||||
# the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only
|
||||
# arbitrator arbitrator_hostname:6030
|
||||
# arbitrator arbitrator_hostname:6042
|
||||
|
||||
# number of threads per CPU core
|
||||
# numOfThreadsPerCore 1.0
|
||||
|
|
|
@ -80,9 +80,9 @@ fi
|
|||
versioninfo="${top_dir}/src/util/src/version.c"
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo"
|
||||
fi
|
||||
#if command -v sudo > /dev/null; then
|
||||
# csudo="sudo"
|
||||
#fi
|
||||
|
||||
function is_valid_version() {
|
||||
[ -z $1 ] && return 1 || :
|
||||
|
@ -267,6 +267,7 @@ if [ "$osType" != "Darwin" ]; then
|
|||
|
||||
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||
${csudo} ./makearbi.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||
else
|
||||
cd ${script_dir}/tools
|
||||
./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
|
||||
|
|
|
@ -76,7 +76,7 @@ fi
|
|||
# get the operating system type for using the corresponding init file
|
||||
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
||||
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
if [[ -d /etc/os-release ]]; then
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||:
|
||||
else
|
||||
osinfo=""
|
||||
|
@ -381,34 +381,29 @@ function install_service_on_sysvinit() {
|
|||
|
||||
function clean_service_on_systemd() {
|
||||
taosd_service_config="${service_config_dir}/taosd.service"
|
||||
|
||||
if systemctl is-active --quiet taosd; then
|
||||
echo "TDengine is running, stopping it..."
|
||||
${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null
|
||||
|
||||
${csudo} rm -f ${taosd_service_config}
|
||||
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
if systemctl is-active --quiet tarbitratord; then
|
||||
echo "tarbitrator is running, stopping it..."
|
||||
${csudo} systemctl stop tarbitratord &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null
|
||||
${csudo} rm -f ${tarbitratord_service_config}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
nginx_service_config="${service_config_dir}/nginxd.service"
|
||||
|
||||
if systemctl is-active --quiet nginxd; then
|
||||
echo "Nginx for TDengine is running, stopping it..."
|
||||
${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null
|
||||
|
||||
${csudo} rm -f ${nginx_service_config}
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
if systemctl is-active --quiet tarbitratord; then
|
||||
echo "tarbitrator is running, stopping it..."
|
||||
${csudo} systemctl stop tarbitratord &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null
|
||||
|
||||
${csudo} rm -f ${tarbitratord_service_config}
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -418,7 +413,6 @@ function install_service_on_systemd() {
|
|||
clean_service_on_systemd
|
||||
|
||||
taosd_service_config="${service_config_dir}/taosd.service"
|
||||
|
||||
${csudo} bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
||||
${csudo} bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}"
|
||||
${csudo} bash -c "echo 'After=network-online.target' >> ${taosd_service_config}"
|
||||
|
@ -439,32 +433,30 @@ function install_service_on_systemd() {
|
|||
${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}"
|
||||
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
||||
${csudo} systemctl enable taosd
|
||||
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}"
|
||||
#${csudo} systemctl enable tarbitratord
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
|
||||
${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}"
|
||||
#${csudo} systemctl enable tarbitratord
|
||||
|
||||
nginx_service_config="${service_config_dir}/nginxd.service"
|
||||
${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}"
|
||||
${csudo} bash -c "echo 'Description=Nginx For TDengine Service' >> ${nginx_service_config}"
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This file is used to install database on linux systems. The operating system
|
||||
# is required to use systemd to manage services at boot
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
# -----------------------Variables definition---------------------
|
||||
script_dir=$(dirname $(readlink -f "$0"))
|
||||
|
||||
bin_link_dir="/usr/bin"
|
||||
#inc_link_dir="/usr/include"
|
||||
|
||||
#install main path
|
||||
install_main_dir="/usr/local/tarbitrator"
|
||||
|
||||
# old bin dir
|
||||
bin_dir="/usr/local/tarbitrator/bin"
|
||||
|
||||
service_config_dir="/etc/systemd/system"
|
||||
|
||||
# Color setting
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[1;32m'
|
||||
GREEN_DARK='\033[0;32m'
|
||||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo"
|
||||
fi
|
||||
|
||||
update_flag=0
|
||||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
||||
|
||||
# get the operating system type for using the corresponding init file
|
||||
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
||||
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||:
|
||||
else
|
||||
osinfo=""
|
||||
fi
|
||||
#echo "osinfo: ${osinfo}"
|
||||
os_type=0
|
||||
if echo $osinfo | grep -qwi "ubuntu" ; then
|
||||
# echo "This is ubuntu system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "debian" ; then
|
||||
# echo "This is debian system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "Kylin" ; then
|
||||
# echo "This is Kylin system"
|
||||
os_type=1
|
||||
elif echo $osinfo | grep -qwi "centos" ; then
|
||||
# echo "This is centos system"
|
||||
os_type=2
|
||||
elif echo $osinfo | grep -qwi "fedora" ; then
|
||||
# echo "This is fedora system"
|
||||
os_type=2
|
||||
else
|
||||
echo " osinfo: ${osinfo}"
|
||||
echo " This is an officially unverified linux system,"
|
||||
echo " if there are any problems with the installation and operation, "
|
||||
echo " please feel free to contact taosdata.com for support."
|
||||
os_type=1
|
||||
fi
|
||||
|
||||
function kill_tarbitrator() {
|
||||
pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_main_path() {
|
||||
#create install main dir and all sub dir
|
||||
${csudo} rm -rf ${install_main_dir} || :
|
||||
${csudo} mkdir -p ${install_main_dir}
|
||||
${csudo} mkdir -p ${install_main_dir}/bin
|
||||
#${csudo} mkdir -p ${install_main_dir}/include
|
||||
${csudo} mkdir -p ${install_main_dir}/init.d
|
||||
}
|
||||
|
||||
function install_bin() {
|
||||
# Remove links
|
||||
${csudo} rm -f ${bin_link_dir}/rmtarbitrator || :
|
||||
${csudo} rm -f ${bin_link_dir}/tarbitrator || :
|
||||
${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/*
|
||||
|
||||
#Make link
|
||||
[ -x ${install_main_dir}/bin/remove_arbi.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_arbi.sh ${bin_link_dir}/rmtarbitrator || :
|
||||
[ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo} ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || :
|
||||
}
|
||||
|
||||
function install_header() {
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
|
||||
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
|
||||
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof tarbitrator &> /dev/null; then
|
||||
${csudo} service tarbitratord stop || :
|
||||
fi
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} chkconfig --del tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod}==2)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} insserv -r tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod}==3)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} update-rc.d -f tarbitratord remove || :
|
||||
fi
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/tarbitratord || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_service_on_sysvinit() {
|
||||
clean_service_on_sysvinit
|
||||
sleep 1
|
||||
|
||||
# Install taosd service
|
||||
|
||||
if ((${os_type}==1)); then
|
||||
${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord
|
||||
${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord
|
||||
elif ((${os_type}==2)); then
|
||||
${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord
|
||||
${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord
|
||||
fi
|
||||
|
||||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
${csudo} chkconfig --add tarbitratord || :
|
||||
${csudo} chkconfig --level 2345 tarbitratord on || :
|
||||
elif ((${initd_mod}==2)); then
|
||||
${csudo} insserv tarbitratord || :
|
||||
${csudo} insserv -d tarbitratord || :
|
||||
elif ((${initd_mod}==3)); then
|
||||
${csudo} update-rc.d tarbitratord defaults || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
if systemctl is-active --quiet tarbitratord; then
|
||||
echo "tarbitrator is running, stopping it..."
|
||||
${csudo} systemctl stop tarbitratord &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null
|
||||
|
||||
${csudo} rm -f ${tarbitratord_service_config}
|
||||
}
|
||||
|
||||
# taos:2345:respawn:/etc/init.d/tarbitratord start
|
||||
|
||||
function install_service_on_systemd() {
|
||||
clean_service_on_systemd
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
|
||||
|
||||
${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'After=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Wants=network-online.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Service]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Type=simple' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'ExecStart=/usr/bin/tarbitrator' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNOFILE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitNPROC=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'LimitCORE=infinity' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'TimeoutStartSec=0' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StandardOutput=null' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'Restart=always' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitBurst=3' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'StartLimitInterval=60s' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}"
|
||||
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}"
|
||||
${csudo} systemctl enable tarbitratord
|
||||
}
|
||||
|
||||
function install_service() {
|
||||
if ((${service_mod}==0)); then
|
||||
install_service_on_systemd
|
||||
elif ((${service_mod}==1)); then
|
||||
install_service_on_sysvinit
|
||||
else
|
||||
# must manual stop taosd
|
||||
kill_tarbitrator
|
||||
fi
|
||||
}
|
||||
|
||||
function update_TDengine() {
|
||||
# Start to update
|
||||
echo -e "${GREEN}Start to update TDengine's arbitrator ...${NC}"
|
||||
# Stop the service if running
|
||||
if pidof tarbitrator &> /dev/null; then
|
||||
if ((${service_mod}==0)); then
|
||||
${csudo} systemctl stop tarbitratord || :
|
||||
elif ((${service_mod}==1)); then
|
||||
${csudo} service tarbitratord stop || :
|
||||
else
|
||||
kill_tarbitrator
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
install_main_path
|
||||
#install_header
|
||||
install_bin
|
||||
install_service
|
||||
|
||||
echo
|
||||
#echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
|
||||
if ((${service_mod}==0)); then
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}"
|
||||
elif ((${service_mod}==1)); then
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ./tarbitrator${NC}"
|
||||
fi
|
||||
echo
|
||||
echo -e "\033[44;32;1mTDengine's arbitrator is updated successfully!${NC}"
|
||||
}
|
||||
|
||||
function install_TDengine() {
|
||||
# Start to install
|
||||
echo -e "${GREEN}Start to install TDengine's arbitrator ...${NC}"
|
||||
|
||||
install_main_path
|
||||
#install_header
|
||||
install_bin
|
||||
install_service
|
||||
echo
|
||||
#echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
|
||||
if ((${service_mod}==0)); then
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} systemctl start tarbitratord${NC}"
|
||||
elif ((${service_mod}==1)); then
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: ${csudo} service tarbitratord start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start arbitrator ${NC}: tarbitrator${NC}"
|
||||
fi
|
||||
|
||||
echo -e "\033[44;32;1mTDengine's arbitrator is installed successfully!${NC}"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
## ==============================Main program starts from here============================
|
||||
# Install server and client
|
||||
if [ -x ${bin_dir}/tarbitrator ]; then
|
||||
update_flag=1
|
||||
update_TDengine
|
||||
else
|
||||
install_TDengine
|
||||
fi
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Generate arbitrator's tar.gz setup package for all os system
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
curr_dir=$(pwd)
|
||||
compile_dir=$1
|
||||
version=$2
|
||||
build_time=$3
|
||||
cpuType=$4
|
||||
osType=$5
|
||||
verMode=$6
|
||||
verType=$7
|
||||
pagMode=$8
|
||||
|
||||
script_dir="$(dirname $(readlink -f $0))"
|
||||
top_dir="$(readlink -f ${script_dir}/../..)"
|
||||
|
||||
# create compressed install file.
|
||||
build_dir="${compile_dir}/build"
|
||||
code_dir="${top_dir}/src"
|
||||
release_dir="${top_dir}/release"
|
||||
|
||||
#package_name='linux'
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
install_dir="${release_dir}/TDengine-enterprise-arbitrator"
|
||||
else
|
||||
install_dir="${release_dir}/TDengine-arbitrator"
|
||||
fi
|
||||
|
||||
# Directories and files.
|
||||
bin_files="${build_dir}/bin/tarbitrator ${script_dir}/remove_arbi.sh"
|
||||
install_files="${script_dir}/install_arbi.sh"
|
||||
|
||||
#header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
|
||||
init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord
|
||||
init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord
|
||||
|
||||
# make directories.
|
||||
mkdir -p ${install_dir} && cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install_arbi.sh || :
|
||||
#mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc || :
|
||||
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* || :
|
||||
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || :
|
||||
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || :
|
||||
|
||||
cd ${release_dir}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
pkg_name=${install_dir}-${version}-${osType}-${cpuType}
|
||||
elif [ "$verMode" == "edge" ]; then
|
||||
pkg_name=${install_dir}-${version}-${osType}-${cpuType}
|
||||
else
|
||||
echo "unknow verMode, nor cluster or edge"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$verType" == "beta" ]; then
|
||||
pkg_name=${pkg_name}-${verType}
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
pkg_name=${pkg_name}
|
||||
else
|
||||
echo "unknow verType, nor stabel or beta"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
|
||||
exitcode=$?
|
||||
if [ "$exitcode" != "0" ]; then
|
||||
echo "tar ${pkg_name}.tar.gz error !!!"
|
||||
exit $exitcode
|
||||
fi
|
||||
|
||||
cd ${curr_dir}
|
|
@ -69,10 +69,12 @@ function kill_tarbitrator() {
|
|||
}
|
||||
function clean_bin() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosd || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo} rm -f ${bin_link_dir}/rmtaos || :
|
||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosd || :
|
||||
${csudo} rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo} rm -f ${bin_link_dir}/rmtaos || :
|
||||
${csudo} rm -f ${bin_link_dir}/tarbitrator || :
|
||||
${csudo} rm -f ${bin_link_dir}/set_core || :
|
||||
}
|
||||
|
||||
function clean_lib() {
|
||||
|
@ -207,7 +209,7 @@ ${csudo} rm -rf ${data_link_dir} || :
|
|||
|
||||
${csudo} rm -rf ${install_main_dir}
|
||||
${csudo} rm -rf ${install_nginxd_dir}
|
||||
if [[ -d /etc/os-release ]]; then
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
else
|
||||
osinfo=""
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to stop the service and uninstall TDengine's arbitrator
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
verMode=edge
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
#install main path
|
||||
install_main_dir="/usr/local/tarbitrator"
|
||||
bin_link_dir="/usr/bin"
|
||||
#inc_link_dir="/usr/include"
|
||||
|
||||
service_config_dir="/etc/systemd/system"
|
||||
tarbitrator_service_name="tarbitratord"
|
||||
csudo=""
|
||||
if command -v sudo > /dev/null; then
|
||||
csudo="sudo"
|
||||
fi
|
||||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
service_config_dir="/etc/init.d"
|
||||
if $(which chkconfig &> /dev/null); then
|
||||
initd_mod=1
|
||||
elif $(which insserv &> /dev/null); then
|
||||
initd_mod=2
|
||||
elif $(which update-rc.d &> /dev/null); then
|
||||
initd_mod=3
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
else
|
||||
service_mod=2
|
||||
fi
|
||||
|
||||
function kill_tarbitrator() {
|
||||
pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
function clean_bin() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${bin_link_dir}/tarbitrator || :
|
||||
}
|
||||
|
||||
function clean_header() {
|
||||
# Remove link
|
||||
${csudo} rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
|
||||
}
|
||||
|
||||
function clean_log() {
|
||||
# Remove link
|
||||
${csudo} rm -rf /arbitrator.log || :
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service"
|
||||
|
||||
if systemctl is-active --quiet ${tarbitrator_service_name}; then
|
||||
echo "TDengine tarbitrator is running, stopping it..."
|
||||
${csudo} systemctl stop ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null
|
||||
fi
|
||||
${csudo} systemctl disable ${tarbitrator_service_name} &> /dev/null || echo &> /dev/null
|
||||
|
||||
${csudo} rm -f ${tarbitratord_service_config}
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if pidof tarbitrator &> /dev/null; then
|
||||
echo "TDengine's tarbitrator is running, stopping it..."
|
||||
${csudo} service tarbitratord stop || :
|
||||
fi
|
||||
|
||||
if ((${initd_mod}==1)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} chkconfig --del tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod}==2)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} insserv -r tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod}==3)); then
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo} update-rc.d -f tarbitratord remove || :
|
||||
fi
|
||||
fi
|
||||
|
||||
${csudo} rm -f ${service_config_dir}/tarbitratord || :
|
||||
|
||||
if $(which init &> /dev/null); then
|
||||
${csudo} init q || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_service() {
|
||||
if ((${service_mod}==0)); then
|
||||
clean_service_on_systemd
|
||||
elif ((${service_mod}==1)); then
|
||||
clean_service_on_sysvinit
|
||||
else
|
||||
# must manual stop
|
||||
kill_tarbitrator
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop service and disable booting start.
|
||||
clean_service
|
||||
# Remove binary file and links
|
||||
clean_bin
|
||||
# Remove header file.
|
||||
##clean_header
|
||||
# Remove log file
|
||||
clean_log
|
||||
|
||||
${csudo} rm -rf ${install_main_dir}
|
||||
|
||||
echo -e "${GREEN}TDengine's arbitrator is removed successfully!${NC}"
|
|
@ -54,7 +54,7 @@ int8_t tsDaylight = 0;
|
|||
char tsTimezone[TSDB_TIMEZONE_LEN] = {0};
|
||||
char tsLocale[TSDB_LOCALE_LEN] = {0};
|
||||
char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string
|
||||
int32_t tsEnableCoreFile = 1;
|
||||
int32_t tsEnableCoreFile = 0;
|
||||
int32_t tsMaxBinaryDisplayWidth = 30;
|
||||
|
||||
/*
|
||||
|
|
|
@ -395,6 +395,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
|||
#define TSDB_PORT_DNODEDNODE 5
|
||||
#define TSDB_PORT_SYNC 10
|
||||
#define TSDB_PORT_HTTP 11
|
||||
#define TSDB_PORT_ARBITRATOR 12
|
||||
|
||||
#define TAOS_QTYPE_RPC 0
|
||||
#define TAOS_QTYPE_FWD 1
|
||||
|
|
|
@ -1059,10 +1059,12 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
||||
mError("db:%s, can't drop monitor database", pDrop->db);
|
||||
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t code = mnodeSetDbDropping(pMsg->pDb);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
#include "mnodeVgroup.h"
|
||||
#include "mnodeWrite.h"
|
||||
|
||||
#define CONN_KEEP_TIME (tsShellActivityTimer * 3000)
|
||||
#define CONN_CHECK_TIME (tsShellActivityTimer * 2000)
|
||||
#define CONN_KEEP_TIME (tsShellActivityTimer * 3)
|
||||
#define CONN_CHECK_TIME (tsShellActivityTimer * 2)
|
||||
#define QUERY_ID_SIZE 20
|
||||
#define QUERY_STREAM_SAVE_SIZE 20
|
||||
|
||||
|
|
|
@ -1714,7 +1714,8 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
|||
(sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||
pTable->superTable = pMsg->pSTable;
|
||||
} else {
|
||||
pTable->uid = (((uint64_t) pTable->createdTime) << 16) + (sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||
pTable->uid = (((uint64_t)pTable->vgId) << 40) + ((((uint64_t)pTable->sid) & ((1ul << 24) - 1ul)) << 16) +
|
||||
(sdbGetVersion() & ((1ul << 16) - 1ul));
|
||||
pTable->sversion = 0;
|
||||
pTable->numOfColumns = htons(pCreate->numOfColumns);
|
||||
pTable->sqlLen = htons(pCreate->sqlLen);
|
||||
|
|
|
@ -40,12 +40,16 @@ typedef struct {
|
|||
void *pConn;
|
||||
} SNodeConn;
|
||||
|
||||
uint16_t tsArbitratorPort = 0;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char arbLogPath[TSDB_FILENAME_LEN + 16] = {0};
|
||||
|
||||
tsArbitratorPort = tsServerPort + TSDB_PORT_ARBITRATOR;
|
||||
|
||||
for (int i=1; i<argc; ++i) {
|
||||
if (strcmp(argv[i], "-p")==0 && i < argc-1) {
|
||||
tsServerPort = atoi(argv[++i]);
|
||||
tsArbitratorPort = atoi(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-d")==0 && i < argc-1) {
|
||||
debugFlag = atoi(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-g")==0 && i < argc-1) {
|
||||
|
@ -53,13 +57,15 @@ int main(int argc, char *argv[]) {
|
|||
tstrncpy(arbLogPath, argv[i], sizeof(arbLogPath));
|
||||
} else {
|
||||
printf("\nusage: %s [options] \n", argv[0]);
|
||||
printf(" [-p port]: server port number, default is:%d\n", tsServerPort);
|
||||
printf(" [-d debugFlag]: debug flag, default:%d\n", debugFlag);
|
||||
printf(" [-g logFilePath]: log file pathe, default:%s\n", arbLogPath);
|
||||
printf(" [-p port]: arbitrator server port number, default is:%d\n", tsServerPort + TSDB_PORT_ARBITRATOR);
|
||||
printf(" [-d debugFlag]: debug flag, option 131 | 135 | 143, default:0\n");
|
||||
printf(" [-g logFilePath]: log file pathe, default:/arbitrator.log\n");
|
||||
printf(" [-h help]: print out this help\n\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
sDebugFlag = debugFlag;
|
||||
|
||||
if (tsem_init(&tsArbSem, 0, 0) != 0) {
|
||||
printf("failed to create exit semphore\n");
|
||||
|
@ -79,12 +85,11 @@ int main(int argc, char *argv[]) {
|
|||
taosInitLog(arbLogPath, 1000000, 10);
|
||||
|
||||
taosGetFqdn(tsNodeFqdn);
|
||||
tsSyncPort = tsServerPort + TSDB_PORT_SYNC;
|
||||
|
||||
SPoolInfo info;
|
||||
info.numOfThreads = 1;
|
||||
info.serverIp = 0;
|
||||
info.port = tsSyncPort;
|
||||
info.port = tsArbitratorPort;
|
||||
info.bufferSize = 640000;
|
||||
info.processBrokenLink = arbProcessBrokenLink;
|
||||
info.processIncomingMsg = arbProcessPeerMsg;
|
||||
|
@ -96,7 +101,7 @@ int main(int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsServerPort);
|
||||
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort);
|
||||
|
||||
for (int res = tsem_wait(&tsArbSem); res != 0; res = tsem_wait(&tsArbSem)) {
|
||||
if (res != EINTR) break;
|
||||
|
|
|
@ -11,9 +11,9 @@ sleep 3000
|
|||
sql connect
|
||||
|
||||
print ========== step2
|
||||
sql drop database log -x step21
|
||||
return -1
|
||||
step21:
|
||||
#sql drop database log -x step21
|
||||
# return -1
|
||||
#step21:
|
||||
sql drop table log.dn -x step22
|
||||
return -1
|
||||
step22:
|
||||
|
|
|
@ -10,8 +10,8 @@ IF (TD_LINUX)
|
|||
#add_executable(insertPerTable insertPerTable.c)
|
||||
#target_link_libraries(insertPerTable taos_static pthread)
|
||||
|
||||
add_executable(insertPerRow insertPerRow.c)
|
||||
target_link_libraries(insertPerRow taos_static pthread)
|
||||
#add_executable(insertPerRow insertPerRow.c)
|
||||
#target_link_libraries(insertPerRow taos_static pthread)
|
||||
|
||||
#add_executable(importOneRow importOneRow.c)
|
||||
#target_link_libraries(importOneRow taos_static pthread)
|
||||
|
@ -22,6 +22,9 @@ IF (TD_LINUX)
|
|||
#add_executable(hashPerformance hashPerformance.c)
|
||||
#target_link_libraries(hashPerformance taos_static tutil common pthread)
|
||||
|
||||
add_executable(createTablePerformance createTablePerformance.c)
|
||||
target_link_libraries(createTablePerformance taos_static tutil common pthread)
|
||||
#add_executable(createTablePerformance createTablePerformance.c)
|
||||
#target_link_libraries(createTablePerformance taos_static tutil common pthread)
|
||||
|
||||
add_executable(createNormalTable createNormalTable.c)
|
||||
target_link_libraries(createNormalTable taos_static tutil common pthread)
|
||||
ENDIF()
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
#include "taos.h"
|
||||
#include "tulog.h"
|
||||
#include "tutil.h"
|
||||
#include "tglobal.h"
|
||||
#include "hash.h"
|
||||
|
||||
#define MAX_RANDOM_POINTS 20000
|
||||
#define GREEN "\033[1;32m"
|
||||
#define NC "\033[0m"
|
||||
|
||||
char dbName[32] = "db";
|
||||
char stableName[64] = "st";
|
||||
int32_t numOfThreads = 30;
|
||||
int32_t numOfTables = 100000;
|
||||
int32_t replica = 1;
|
||||
int32_t numOfColumns = 2;
|
||||
|
||||
typedef struct {
|
||||
int32_t tableBeginIndex;
|
||||
int32_t tableEndIndex;
|
||||
int32_t threadIndex;
|
||||
char dbName[32];
|
||||
char stableName[64];
|
||||
float createTableSpeed;
|
||||
pthread_t thread;
|
||||
} SThreadInfo;
|
||||
|
||||
void shellParseArgument(int argc, char *argv[]);
|
||||
void *threadFunc(void *param);
|
||||
void createDbAndSTable();
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
shellParseArgument(argc, argv);
|
||||
taos_init();
|
||||
createDbAndSTable();
|
||||
|
||||
pPrint("%d threads are spawned to create table", numOfThreads);
|
||||
|
||||
pthread_attr_t thattr;
|
||||
pthread_attr_init(&thattr);
|
||||
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
|
||||
SThreadInfo *pInfo = (SThreadInfo *)calloc(numOfThreads, sizeof(SThreadInfo));
|
||||
|
||||
int32_t numOfTablesPerThread = numOfTables / numOfThreads;
|
||||
numOfTables = numOfTablesPerThread * numOfThreads;
|
||||
for (int i = 0; i < numOfThreads; ++i) {
|
||||
pInfo[i].tableBeginIndex = i * numOfTablesPerThread;
|
||||
pInfo[i].tableEndIndex = (i + 1) * numOfTablesPerThread;
|
||||
pInfo[i].threadIndex = i;
|
||||
strcpy(pInfo[i].dbName, dbName);
|
||||
strcpy(pInfo[i].stableName, stableName);
|
||||
pthread_create(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i));
|
||||
}
|
||||
|
||||
taosMsleep(300);
|
||||
for (int i = 0; i < numOfThreads; i++) {
|
||||
pthread_join(pInfo[i].thread, NULL);
|
||||
}
|
||||
|
||||
float createTableSpeed = 0;
|
||||
for (int i = 0; i < numOfThreads; ++i) {
|
||||
createTableSpeed += pInfo[i].createTableSpeed;
|
||||
}
|
||||
|
||||
pPrint("%s total speed:%.1f tables/second, threads:%d %s", GREEN, createTableSpeed, numOfThreads, NC);
|
||||
|
||||
pthread_attr_destroy(&thattr);
|
||||
free(pInfo);
|
||||
}
|
||||
|
||||
void createDbAndSTable() {
|
||||
pPrint("start to create db and stable");
|
||||
char qstr[64000];
|
||||
|
||||
TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
|
||||
if (con == NULL) {
|
||||
pError("failed to connect to DB, reason:%s", taos_errstr(con));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(qstr, "create database if not exists %s replica %d", dbName, replica);
|
||||
TAOS_RES *pSql = taos_query(con, qstr);
|
||||
int32_t code = taos_errno(pSql);
|
||||
if (code != 0) {
|
||||
pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(con), taos_errstr(con));
|
||||
exit(0);
|
||||
}
|
||||
taos_free_result(pSql);
|
||||
|
||||
sprintf(qstr, "use %s", dbName);
|
||||
pSql = taos_query(con, qstr);
|
||||
code = taos_errno(pSql);
|
||||
if (code != 0) {
|
||||
pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con));
|
||||
exit(0);
|
||||
}
|
||||
taos_free_result(pSql);
|
||||
|
||||
taos_close(con);
|
||||
}
|
||||
|
||||
void *threadFunc(void *param) {
|
||||
SThreadInfo *pInfo = (SThreadInfo *)param;
|
||||
char qstr[65000];
|
||||
int code;
|
||||
|
||||
TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
|
||||
if (con == NULL) {
|
||||
pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(qstr, "use %s", pInfo->dbName);
|
||||
TAOS_RES *pSql = taos_query(con, qstr);
|
||||
taos_free_result(pSql);
|
||||
|
||||
int64_t startMs = taosGetTimestampMs();
|
||||
|
||||
for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) {
|
||||
sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t);
|
||||
TAOS_RES *pSql = taos_query(con, qstr);
|
||||
code = taos_errno(pSql);
|
||||
if (code != 0) {
|
||||
pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code));
|
||||
}
|
||||
taos_free_result(pSql);
|
||||
}
|
||||
|
||||
float createTableSpeed = 0;
|
||||
for (int i = 0; i < numOfThreads; ++i) {
|
||||
createTableSpeed += pInfo[i].createTableSpeed;
|
||||
}
|
||||
|
||||
int64_t endMs = taosGetTimestampMs();
|
||||
int32_t totalTables = pInfo->tableEndIndex - pInfo->tableBeginIndex;
|
||||
float seconds = (endMs - startMs) / 1000.0;
|
||||
float speed = totalTables / seconds;
|
||||
pInfo->createTableSpeed = speed;
|
||||
|
||||
pPrint("thread:%d, time:%.2f sec, speed:%.1f tables/second, ", pInfo->threadIndex, seconds, speed);
|
||||
taos_close(con);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void printHelp() {
|
||||
char indent[10] = " ";
|
||||
printf("Used to test the performance while create table\n");
|
||||
|
||||
printf("%s%s\n", indent, "-c");
|
||||
printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir);
|
||||
printf("%s%s\n", indent, "-d");
|
||||
printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName);
|
||||
printf("%s%s\n", indent, "-s");
|
||||
printf("%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stableName);
|
||||
printf("%s%s\n", indent, "-t");
|
||||
printf("%s%s%s%d\n", indent, indent, "numOfThreads, default is ", numOfThreads);
|
||||
printf("%s%s\n", indent, "-n");
|
||||
printf("%s%s%s%d\n", indent, indent, "numOfTables, default is ", numOfTables);
|
||||
printf("%s%s\n", indent, "-r");
|
||||
printf("%s%s%s%d\n", indent, indent, "replica, default is ", replica);
|
||||
printf("%s%s\n", indent, "-columns");
|
||||
printf("%s%s%s%d\n", indent, indent, "numOfColumns, default is ", numOfColumns);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void shellParseArgument(int argc, char *argv[]) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
printHelp();
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "-d") == 0) {
|
||||
strcpy(dbName, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-c") == 0) {
|
||||
strcpy(configDir, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-s") == 0) {
|
||||
strcpy(stableName, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-t") == 0) {
|
||||
numOfThreads = atoi(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-n") == 0) {
|
||||
numOfTables = atoi(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-r") == 0) {
|
||||
replica = atoi(argv[++i]);
|
||||
} else if (strcmp(argv[i], "-columns") == 0) {
|
||||
numOfColumns = atoi(argv[++i]);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
pPrint("%s dbName:%s %s", GREEN, dbName, NC);
|
||||
pPrint("%s stableName:%s %s", GREEN, stableName, NC);
|
||||
pPrint("%s configDir:%s %s", GREEN, configDir, NC);
|
||||
pPrint("%s numOfTables:%d %s", GREEN, numOfTables, NC);
|
||||
pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC);
|
||||
pPrint("%s numOfColumns:%d %s", GREEN, numOfColumns, NC);
|
||||
pPrint("%s replica:%d %s", GREEN, replica, NC);
|
||||
|
||||
pPrint("%s start create table performace test %s", GREEN, NC);
|
||||
}
|
Loading…
Reference in New Issue