Do not report ERROR when sample rate equals 100

This commit is contained in:
ZenoWang
2024-02-06 14:49:31 +00:00
committed by ob-robot
parent 1f1d5c08ae
commit c8ef409bf3
3710 changed files with 486984 additions and 3083329 deletions

View File

@ -1,264 +0,0 @@
#!/bin/bash
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"
source _env
export HOST_IP_MODE=1
STAMP="$(date +%s)"
STEP=1
PHASE_START_TIME=0
function timediff() {
start_time=$1
end_time=$2
start_s=${start_time%.*}
start_nanos=${start_time#*.}
end_s=${end_time%.*}
end_nanos=${end_time#*.}
if [ "$end_nanos" -lt "$start_nanos" ];then
end_s=$(( 10#$end_s - 1 ))
end_nanos=$(( 10#$end_nanos + 10**9 ))
fi
time=$(( 10#$end_s - 10#$start_s )).`printf "%03d\n" $(( (10#$end_nanos - 10#$start_nanos)/10**6 ))`
echo $time
}
function print_start_phase() {
echo "/////////////////////// STEP ${STEP}: $@ ///////////////////////"
STEP=$[ ${STEP} + 1 ]
PHASE_START_TIME=$(date +%s.%N)
}
function print_end_phase() {
cur_time=$(date +%s.%N)
echo "/////////////////////// phase end: $(timediff ${PHASE_START_TIME} ${cur_time}) s ///////////////////////"
}
function is_true() {
value=$1
# convert value to upper case string(can work in bash 4.x)
value=${value^^}
if [ "x${value}" == "xNO" ] || [ "x${value}" == "xFALSE" ] || [ "x${value}" == "x0" ]; then
return 1
fi
return 0
}
function get_mode() {
if test -z ${MODE}
then
MODE="MINI"
fi
MODE=${MODE^^}
}
function exit_while_error() {
if test -z ${EXIT_WHILE_ERROR}
then
return 0
fi
return `is_true ${EXIT_WHILE_ERROR}`
}
function fastboot() {
if test -z ${FASTBOOT}
then
return 0
fi
return `is_true ${FASTBOOT}`
}
function remove_disk_check_logic_in_obd() {
# make sure obd copy the plugin code
obd cluster list
start_check_files=('/root/.obd/plugins/oceanbase/3.1.0/start_check.py' '/root/.obd/plugins/oceanbase/4.0.0.0/start_check.py')
for start_check_file in ${start_check_files[@]}
do
sed -i "s/critical('(%s) %s not enough disk space\. (Avail/alert('(%s) %s not enough disk space\. (Avail/g" $start_check_file
sed -i "s/critical(EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG/alert(EC_OBSERVER_NOT_ENOUGH_DISK_4_CLOG/g" $start_check_file
done
}
function run_custom_scripts {
INIT_SCRIPTS_ROOT="${1}";
# Check whether parameter has been passed on
if [ -z "${INIT_SCRIPTS_ROOT}" ]; then
echo "No INIT_SCRIPTS_ROOT passed on, no scripts will be run.";
return;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "${INIT_SCRIPTS_ROOT}" ] && [ -n "$(ls -A "${INIT_SCRIPTS_ROOT}")" ]; then
echo -e "Executing user defined scripts..."
run_custom_scripts_recursive ${INIT_SCRIPTS_ROOT}
echo -e "DONE: Executing user defined scripts.\n"
fi;
}
function run_custom_scripts_recursive {
local f
for f in "${1}"/*; do
echo -e "running ${f} ...";
obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < ${f}
echo "DONE: running ${f}";
done
}
function deploy_failed {
echo "deploy failed!"
if exit_while_error
then
exit 1
else
echo "Please check the log file ${OB_HOME_PATH}/log/observer.log"
fi
}
# We should decide whether the observer's data exists and
# whether the obd has the information of the cluster
if [ -f "$HOME/.obd/cluster/${OB_CLUSTER_NAME}/config.yaml" ]; then
echo "find obd deploy information, skip configuring..."
echo "start ob cluster ..."
obd cluster start $OB_CLUSTER_NAME
else # nothing here, bootstrap
print_start_phase "Config Generation"
TMPFILE="boot.${STAMP}.yaml"
get_mode
if [ "x${MODE}" == "xNORMAL" ]; then
echo "oceanbase-ce docker in normal mode"
cp -f boot-tmp.yaml $TMPFILE
elif [ "x${MODE}" == "xMINI" ]; then
echo "oceanbase-ce docker in mini mode"
cp -f boot-mini-tmp.yaml $TMPFILE
elif [ "x${MODE}" == "xSLIM" ]; then
echo "oceanbase-ce docker in slim mode"
cp -f boot-mini-tmp.yaml $TMPFILE
else
cp -f boot-mini-tmp.yaml $TMPFILE
fi
if [ "x${MODE}" != "xSLIM" ]; then
cat obagent.yaml >> $TMPFILE
fi
if [ "x${MODE}" == "xSLIM" ]; then
cat ob-configserver.yaml >> $TMPFILE
fi
sed -i "s|@OB_SERVER_IP@|${OB_SERVER_IP}|g" $TMPFILE
sed -i "s|@OB_HOME_PATH@|${OB_HOME_PATH}|g" $TMPFILE
sed -i "s|@OB_MYSQL_PORT@|${OB_MYSQL_PORT}|g" $TMPFILE
sed -i "s|@OB_RPC_PORT@|${OB_RPC_PORT}|g" $TMPFILE
sed -i "s|@OB_CLUSTER_NAME@|${OB_CLUSTER_NAME}|g" $TMPFILE
sed -i "s|@OB_MEMORY_LIMIT@|${OB_MEMORY_LIMIT}|g" $TMPFILE
sed -i "s|@OB_SYSTEM_MEMORY@|${OB_SYSTEM_MEMORY}|g" $TMPFILE
sed -i "s|@OB_DATAFILE_SIZE@|${OB_DATAFILE_SIZE}|g" $TMPFILE
sed -i "s|@OB_LOG_DISK_SIZE@|${OB_LOG_DISK_SIZE}|g" $TMPFILE
sed -i "s|@OB_ROOT_PASSWORD@|${OB_ROOT_PASSWORD}|g" $TMPFILE
[ "${OB_DATA_DIR}" ] && echo " data_dir: ${OB_DATA_DIR}" >> $TMPFILE
[ "${OB_REDO_DIR}" ] && echo " redo_dir: ${OB_REDO_DIR}" >> $TMPFILE
print_end_phase
print_start_phase "Ob-deploy mirror clone"
mkdir -p $OB_HOME_PATH
obd mirror clone /root/pkg/*.rpm \
&& obd mirror list local
print_end_phase
print_start_phase "Ob-deploy deploy"
remove_disk_check_logic_in_obd
if fastboot; then
obd devmode enable && obd cluster deploy "${OB_CLUSTER_NAME}" -c $TMPFILE;
if [ $? -ne 0 ]; then
deploy_failed
fi
print_end_phase
print_start_phase "Ob-deploy restore store dir"
rm -rf ${OB_HOME_PATH}/store && tar -Sxzvf /root/boot/store.tar.gz -C ${OB_HOME_PATH}
BLOCK_CNT=`cat /root/boot/block_cnt`
for i in $(seq 0 $[ $BLOCK_CNT - 1 ])
do
fallocate -o 0 -l 67108864 ${OB_HOME_PATH}/store/clog/log_pool/$i
echo "restore block id $i"
done
print_end_phase
print_start_phase "Ob-deploy import etc"
cp -r /root/boot/etc/* ${OB_HOME_PATH}/etc
print_end_phase
print_start_phase "Ob-deploy start"
obd cluster start ${OB_CLUSTER_NAME}
print_end_phase
if [ "x${MODE}" == "xSLIM" ]; then
run_custom_scripts /root/boot/init.d
fi
else
print_start_phase "Ob-deploy autodeploy"
obd devmode enable && obd cluster autodeploy "${OB_CLUSTER_NAME}" -c $TMPFILE;
print_end_phase
print_start_phase "Ob-deploy Create Tenant"
create_tenant_cmd="obd cluster tenant create ${OB_CLUSTER_NAME} -n ${OB_TENANT_NAME}"
if ! [ -z "${OB_TENANT_MINI_CPU}" ]; then
create_tenant_cmd="${create_tenant_cmd} --min-cpu=${OB_TENANT_MINI_CPU}"
fi;
if ! [ -z "${OB_TENANT_MEMORY_SIZE}" ]; then
create_tenant_cmd="${create_tenant_cmd} --memory-size=${OB_TENANT_MEMORY_SIZE}"
fi;
if ! [ -z "${OB_TENANT_LOG_DISK_SIZE}" ]; then
create_tenant_cmd="${create_tenant_cmd} --log-disk-size=${OB_TENANT_LOG_DISK_SIZE}"
fi;
eval ${create_tenant_cmd}
if [ $? -ne 0 ]; then
deploy_failed
fi
if [ "x${MODE}" != "xSLIM" ]; then
obclient -h127.1 -uroot@${OB_TENANT_NAME} -A -P${OB_MYSQL_PORT} < init_tenant_user.sql
else
run_custom_scripts /root/boot/init.d
fi
print_end_phase
fi
if [ $? -ne 0 ]; then
deploy_failed
fi
mv -f $TMPFILE ${OB_HOME_PATH}/boot.yaml && echo "deploy success!"
fi
if [ $? -eq 0 ]; then
echo "boot success!"
# close the enable_rich_error_msg
PASSWORD_ARG=""
if [ "${OB_ROOT_PASSWORD}" != "" ]; then
PASSWORD_ARG="-p${OB_ROOT_PASSWORD}"
fi
obclient -h127.1 -uroot@sys -A -P${OB_MYSQL_PORT} ${PASSWORD_ARG} -e "alter system set enable_rich_error_msg = false;"
else
echo "boot failed!"
if exit_while_error
then
exit 1
else
echo "Please check the log file ${OB_HOME_PATH}/log/observer.log"
fi
fi
exec tail -f /dev/null

View File

@ -1,15 +0,0 @@
MODE=${MODE:-MINI}
FASTBOOT=${FASTBOOT:-false}
EXIT_WHILE_ERROR=${EXIT_WHILE_ERROR:-true}
OB_HOME_PATH="/root/ob"
OB_SERVER_IP="127.0.0.1"
OB_MYSQL_PORT="2881"
OB_RPC_PORT="2882"
OB_CLUSTER_NAME=${OB_CLUSTER_NAME:-obcluster}
OB_TENANT_NAME=${OB_TENANT_NAME:-test}
OB_MEMORY_LIMIT=${OB_MEMORY_LIMIT:-6G}
OB_DATAFILE_SIZE=${OB_DATAFILE_SIZE:-5G}
OB_LOG_DISK_SIZE=${OB_LOG_DISK_SIZE:-5G}
OB_ROOT_PASSWORD=${OB_ROOT_PASSWORD:-}
OB_SYSTEM_MEMORY=${OB_SYSTEM_MEMORY:-1G}
OB_TENANT_LOWER_CASE_TABLE_NAMES=${OB_TENANT_LOWER_CASE_TABLE_NAMES:-1}

View File

@ -1,27 +0,0 @@
oceanbase-ce:
depends:
- ob-configserver
servers:
# Please don't use hostname, only IP can be supported
- @OB_SERVER_IP@
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: @OB_HOME_PATH@
mysql_port: @OB_MYSQL_PORT@
rpc_port: @OB_RPC_PORT@
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: @OB_MEMORY_LIMIT@ # The maximum running memory for an observer
system_memory: @OB_SYSTEM_MEMORY@ # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
datafile_size: @OB_DATAFILE_SIZE@ # Size of the data file.
log_disk_size: @OB_LOG_DISK_SIZE@ # The size of disk space used by the clog files.
cpu_count: 16
production_mode: false
syslog_level: INFO # System log level. The default value is INFO.
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
appname: @OB_CLUSTER_NAME@
root_password: @OB_ROOT_PASSWORD@
enable_rich_error_msg: true

View File

@ -1,15 +0,0 @@
oceanbase-ce:
depends:
- ob-configserver
servers:
- @OB_SERVER_IP@
global:
home_path: @OB_HOME_PATH@
mysql_port: @OB_MYSQL_PORT@
rpc_port: @OB_RPC_PORT@
datafile_size: 20G
log_disk_size: 20G
production_mode: false
appname: @OB_CLUSTER_NAME@
root_password: @OB_ROOT_PASSWORD@
enable_rich_error_msg: true

View File

@ -1,2 +0,0 @@
CREATE USER 'test'@'%';
GRANT ALL ON test.* TO 'test'@'%';

View File

@ -1,7 +0,0 @@
ob-configserver:
servers:
- @OB_SERVER_IP@
global:
listen_port: 8080
server_ip: 0.0.0.0
home_path: /home/admin/obconfigserver

View File

@ -1,24 +0,0 @@
#!/bin/bash
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"
source _env
case "$1" in
sys)
LOGIN_USER="root@sys"
DB="oceanbase"
;;
root)
DB="oceanbase"
LOGIN_USER="root@${OB_TENANT_NAME}"
;;
*)
DB="test"
LOGIN_USER="test@${OB_TENANT_NAME}"
;;
esac
echo "login as ${LOGIN_USER}"
CMD="obclient -h127.1 -u${LOGIN_USER} -A -D${DB} -P${OB_MYSQL_PORT} ${PASSCMD}"
echo "Command is: ${CMD}"
${CMD}

View File

@ -1,63 +0,0 @@
obagent:
# The list of servers to be monitored. This list is consistent with the servers in oceanbase-ce.
servers:
- @OB_SERVER_IP@
# Set dependent components for the component.
# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
depends:
- oceanbase-ce
global:
# The working directory for obagent. obagent is started under this directory. This is a required field.
home_path: /root/obagent
# The port that pulls and manages the metrics. The default port number is 8088.
monagent_http_port: 8088
# Debug port for pprof. The default port number is 8089.
mgragent_http_port: 8089
# Log level. The default value is INFO.
log_level: INFO
# Log path. The default value is log/monagent.log.
log_path: log/monagent.log
# Encryption method. OBD supports aes and plain. The default value is plain.
crypto_method: plain
# Path to store the crypto key. The default value is conf/.config_secret.key.
# crypto_path: conf/.config_secret.key
# Size for a single log file. Log size is measured in Megabytes. The default value is 30M.
log_size: 30
# Expiration time for logs. The default value is 7 days.
log_expire_day: 7
# The maximum number for log files. The default value is 10.
log_file_count: 10
# Whether to use local time for log files. The default value is true.
# log_use_localtime: true
# Whether to enable log compression. The default value is true.
# log_compress: true
# Username for HTTP authentication. The default value is admin.
http_basic_auth_user: admin
# Password for HTTP authentication. The default value is root.
http_basic_auth_password: root
# Username for debug service. The default value is admin.
pprof_basic_auth_user: admin
# Password for debug service. The default value is root.
pprof_basic_auth_password: root
# Monitor username for OceanBase Database. The user must have read access to OceanBase Database as a system tenant. The default value is root.
# monitor_user: root
# Monitor password for OceanBase Database. The default value is empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the root_password in oceanbase-ce.
# monitor_password:
# The SQL port for observer. The default value is 2881. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the mysql_port in oceanbase-ce.
# sql_port: 2881
# The RPC port for observer. The default value is 2882. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the rpc_port in oceanbase-ce.
# rpc_port: 2882
# Cluster name for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the appname in oceanbase-ce.
cluster_name: @OB_CLUSTER_NAME@
# Cluster ID for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the cluster_id in oceanbase-ce.
# cluster_id: 1
# Zone name for your observer. The default value is zone1. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the zone name in oceanbase-ce.
# zone_name: zone1
# Monitor status for OceanBase Database. Active is to enable. Inactive is to disable. The default value is active. When you deploy an cluster automatically, OBD decides whether to enable this parameter based on depends.
ob_monitor_status: active
# Monitor status for your host. Active is to enable. Inactive is to disable. The default value is active.
host_monitor_status: active
# Whether to disable the basic authentication for HTTP service. True is to disable. False is to enable. The default value is false.
disable_http_basic_auth: true
# Whether to disable the basic authentication for the debug interface. True is to disable. False is to enable. The default value is false.
disable_pprof_basic_auth: true