1
0

Merge branch 'main' into multi-tenant

This commit is contained in:
2024-07-09 15:16:56 +08:00
41 changed files with 4375 additions and 2056 deletions

View File

@@ -1,15 +1,16 @@
# !/bin/bash
RedisRootDir=/usr/local
OMCRootDir=/usr/local/omc
RedisOldRootDir=/usr/local/db
RedisConfDir=${RedisRootDir}/etc/adb
DependsRootDir=/usr/local/omc/depends
RedisConfDir=${RedisRootDir}/etc/kvdb
DependsRootDir=${OMCRootDir}/depends
SystemdRootDir=/lib/systemd/system
OMCEtcDir=/usr/local/omc/etc
FERootDir=/usr/local/omc/htdocs/front
OMCEtcDir=${OMCRootDir}/etc
FERootDir=${OMCRootDir}/htdocs/front
X86Lib64Dir=/lib/x86_64-linux-gnu
OmcBinDir=/usr/local/omc/bin
OMCStaticDir=/usr/local/omc/static
OmcBinDir=${OMCRootDir}/bin
OMCStaticDir=${OMCRootDir}/static
UsrLocalBinDir=/usr/local/bin
OmcDaemon=omcd
NginxEtcDir=/etc/nginx
@@ -24,7 +25,7 @@ echo " sudo systemctl start/stop/restart/status restagent.service"
echo " sudo systemctl start/stop/restart/status crontask.service"
echo " sudo systemctl start/stop/restart/status sshsvc.service"
echo " sudo systemctl start/stop/restart/status captrace.service"
echo " sudo systemctl start/stop/restart/status adb.service"
echo " sudo systemctl start/stop/restart/status kvdb.service"
echo " or run: "
echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status"
echo ""
@@ -42,10 +43,10 @@ if [ ! -e libwsutil.so ]; then ln -s libwsutil.so.13.1.0 libwsutil.so; fi
cd ${UsrLocalBinDir}
if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi
chmod +rx /usr/local/omc/bin/*
chmod +rx /usr/local/omc/*
chmod +rx /usr/local/bin/*
chmod -R 755 /usr/local/omc/htdocs/front
chmod +rx ${OMCRootDir}/bin/*
chmod +rx ${OMCRootDir}/*
chmod +rx ${UsrLocalBinDir}/*
chmod -R 755 ${OMCRootDir}/htdocs/front
for CFile in ${CFileList}; do
if [ ! -e "${OMCEtcDir}/${CFile}" ]; then
@@ -57,42 +58,54 @@ for CFile in ${CFileList}; do
done
# Install redis db if not exist /usr/local/db
if [ ! -e "${RedisRootDir}/bin/adb-server" ]; then
if [ ! -e "${RedisRootDir}/bin/kvdb-server" ]; then
# if [ ! -e "${RedisRootDir}" ]; then
# mkdir -p ${RedisRootDir}
# fi
# stop old adb service
if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service
systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/adb/* /
chmod +rx ${RedisRootDir}/bin/*
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}
# stop adb service
if [ -e "${UsrLocalBinDir}/adb-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service
systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/kvdb/* /
chmod +rx ${RedisRootDir}/bin/kvdb*
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf"
FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾
echo "$LINE" >> "$FILE"
fi
# copy the orangin dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ]; then
cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisConfDir}
# copy the old adb dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old
fi
# cp -f ${DependsRootDir}/systemd/adb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf
# copy the adb dump.rdb
if [ -e "${RedisRootDir}/etc/adb/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisRootDir}/etc/adb/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/etc/adb ${RedisRootDir}/etc/adb.old
fi
# cp -f ${DependsRootDir}/systemd/kvdb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf"
FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾
@@ -131,16 +144,16 @@ systemctl enable restagent.service
systemctl enable crontask.service
systemctl enable sshsvc.service
systemctl enable captrace.service
systemctl enable adb.service
systemctl enable kvdb.service
systemctl daemon-reload
systemctl stop nginx.service
systemctl stop restagent.service
systemctl stop crontask.service
systemctl stop sshsvc.service
systemctl stop captrace.service
systemctl stop adb.service
systemctl stop kvdb.service
systemctl start nginx.service
systemctl start adb.service
systemctl start kvdb.service
systemctl start crontask.service
systemctl start sshsvc.service
systemctl start captrace.service

View File

@@ -13,14 +13,15 @@ systemctl stop restagent.service
systemctl stop crontask.service
systemctl stop sshsvc.service
systemctl stop captrace.service
systemctl stop adb.service
#systemctl stop kvdb.service
#rm -rf /usr/local/omc
rm -rf /etc/nginx/conf.d/omc.conf
rm -f /usr/local/bin/omcd
systemctl disable restagent.service
systemctl disable crontask.service
systemctl disable sshsvc.service
systemctl disable captrace.service
systemctl disable adb.service
#systemctl disable kvdb.service
systemctl daemon-reload

View File

@@ -1,6 +1,6 @@
[Service]
Type=forking
ExecStart=/usr/local/bin/adb-server /usr/local/etc/adb/adb.conf
ExecStart=/usr/local/bin/kvdb-server /usr/local/etc/kvdb/kvdb.conf
ExecStopPost=
PIDFile=
Restart=always

View File

@@ -304,7 +304,7 @@ daemonize yes
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/run/adb-server.pid
pidfile /var/run/kvdb-server.pid
# Specify the server verbosity level.
# This can be one of:
@@ -312,13 +312,14 @@ pidfile /var/run/adb-server.pid
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice
#loglevel notice
loglevel warning
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
#logfile /usr/local/etc/adb/log/adb-server.log
logfile ""
#logfile /usr/local/etc/kvdb/log/kvdb-server.log
logfile /usr/local/etc/kvdb/log/kvdb-server.log
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
@@ -471,7 +472,7 @@ rdb-del-sync-files no
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /usr/local/etc/adb
dir /usr/local/etc/kvdb
################################# REPLICATION #################################
@@ -2081,7 +2082,3 @@ replica-weighting-factor 2
# disk space or any other I/O error Redis will instead use memory.
#
# blob-support false
# set slave of UDM primary redis
slaveof 172.16.5.140 6379
masterauth helloearth

View File

@@ -84,7 +84,7 @@
# mode.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1 -::1
bind 127.0.0.1 172.16.5.140
bind 127.0.0.1
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
@@ -304,7 +304,7 @@ daemonize yes
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/run/adb-server.pid
pidfile /var/run/kvdb-server.pid
# Specify the server verbosity level.
# This can be one of:
@@ -312,13 +312,14 @@ pidfile /var/run/adb-server.pid
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice
#loglevel notice
loglevel warning
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
#logfile /usr/local/etc/adb/log/adb-server.log
logfile ""
#logfile /usr/local/etc/kvdb/log/kvdb-server.log
logfile /usr/local/etc/kvdb/log/kvdb-server.log
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
@@ -471,7 +472,7 @@ rdb-del-sync-files no
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /usr/local/etc/adb
dir /usr/local/etc/kvdb
################################# REPLICATION #################################
@@ -502,6 +503,7 @@ dir /usr/local/etc/adb
# refuse the replica request.
#
# masterauth <master-password>
masterauth helloearth
#
# However this is not enough if you are using Redis ACLs (for Redis version
# 6 or greater), and the default user is not capable of running the PSYNC
@@ -2057,8 +2059,7 @@ server-threads 2
# bringing up replicas can result in data loss (the first master will win).
# active-replica yes
active-replica yes
replicaof 172.16.5.141 6379
masterauth helloearth
replicaof 10.0.0.2 6379
# Redis will attempt to balance clients across threads evenly; However, replica clients
# are usually much more expensive than a normal client, and so Redis will try to assign
@@ -2084,7 +2085,3 @@ replica-weighting-factor 2
# disk space or any other I/O error Redis will instead use memory.
#
# blob-support false
# set slave of UDM primary redis
slaveof 172.16.5.140 6379
masterauth helloearth

View File

@@ -1,15 +1,16 @@
# !/bin/bash
RedisRootDir=/usr/local
OMCRootDir=/usr/local/omc
RedisOldRootDir=/usr/local/db
RedisConfDir=${RedisRootDir}/etc/adb
DependsRootDir=/usr/local/omc/depends
RedisConfDir=${RedisRootDir}/etc/kvdb
DependsRootDir=${OMCRootDir}/depends
SystemdRootDir=/lib/systemd/system
OMCEtcDir=/usr/local/omc/etc
FERootDir=/usr/local/omc/htdocs/front
OMCEtcDir=${OMCRootDir}/etc
FERootDir=${OMCRootDir}/htdocs/front
X86Lib64Dir=/lib/x86_64-linux-gnu
OmcBinDir=/usr/local/omc/bin
OMCStaticDir=/usr/local/omc/static
OmcBinDir=${OMCRootDir}/bin
OMCStaticDir=${OMCRootDir}/static
UsrLocalBinDir=/usr/local/bin
OmcDaemon=omcd
NginxEtcDir=/etc/nginx
@@ -24,7 +25,7 @@ echo " sudo systemctl start/stop/restart/status restagent.service"
echo " sudo systemctl start/stop/restart/status crontask.service"
echo " sudo systemctl start/stop/restart/status sshsvc.service"
echo " sudo systemctl start/stop/restart/status captrace.service"
echo " sudo systemctl start/stop/restart/status adb.service"
echo " sudo systemctl start/stop/restart/status kvdb.service"
echo " or run: "
echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status"
echo ""
@@ -42,10 +43,10 @@ if [ ! -e libwsutil.so ]; then ln -s libwsutil.so.13.1.0 libwsutil.so; fi
cd ${UsrLocalBinDir}
if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi
chmod +rx /usr/local/omc/bin/*
chmod +rx /usr/local/omc/*
chmod +rx /usr/local/bin/*
chmod -R 755 /usr/local/omc/htdocs/front
chmod +rx ${OMCRootDir}/bin/*
chmod +rx ${OMCRootDir}/*
chmod +rx ${UsrLocalBinDir}/*
chmod -R 755 ${OMCRootDir}/htdocs/front
for CFile in ${CFileList}; do
if [ ! -e "${OMCEtcDir}/${CFile}" ]; then
@@ -57,42 +58,54 @@ for CFile in ${CFileList}; do
done
# Install redis db if not exist /usr/local/db
if [ ! -e "${RedisRootDir}/bin/adb-server" ]; then
if [ ! -e "${RedisRootDir}/bin/kvdb-server" ]; then
# if [ ! -e "${RedisRootDir}" ]; then
# mkdir -p ${RedisRootDir}
# fi
# stop old adb service
if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service
systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/adb/* /
chmod +rx ${RedisRootDir}/bin/*
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir};
# stop adb service
if [ -e "${UsrLocalBinDir}/adb-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service
systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/kvdb/* /
chmod +rx ${RedisRootDir}/bin/kvdb*
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir};
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf"
FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾
echo "$LINE" >> "$FILE"
fi
# copy the orangin dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ]; then
# copy the old adb dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ] && [ ! -e "${RedisConfDir}/dump.rdb" ]; then
cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisConfDir};
mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old
fi
# cp -f ${DependsRootDir}/systemd/adb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf
# copy the adb dump.rdb
if [ -e "${RedisRootDir}/etc/adb/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisRootDir}/etc/adb/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/etc/adb ${RedisRootDir}/etc/adb.old
fi
# cp -f ${DependsRootDir}/systemd/kvdb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf"
FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾
@@ -131,16 +144,16 @@ systemctl enable restagent.service
systemctl enable crontask.service
systemctl enable sshsvc.service
systemctl enable captrace.service
systemctl enable adb.service
systemctl enable kvdb.service
systemctl daemon-reload
systemctl stop nginx.service
systemctl stop restagent.service
systemctl stop crontask.service
systemctl stop sshsvc.service
systemctl stop captrace.service
systemctl stop adb.service
systemctl stop kvdb.service
systemctl start nginx.service
systemctl start adb.service
systemctl start kvdb.service
systemctl start crontask.service
systemctl start sshsvc.service
systemctl start captrace.service

View File

@@ -13,14 +13,15 @@ systemctl stop restagent.service
systemctl stop crontask.service
systemctl stop sshsvc.service
systemctl stop captrace.service
systemctl stop adb.service
#systemctl stop kvdb.service
#rm -rf /usr/local/omc
rm -rf /etc/nginx/conf.d/omc.conf
rm -f /usr/local/bin/omcd
systemctl disable restagent.service
systemctl disable crontask.service
systemctl disable sshsvc.service
systemctl disable captrace.service
systemctl disable adb.service
#systemctl disable kvdb.service
systemctl daemon-reload

View File

@@ -1,6 +1,6 @@
[Service]
Type=forking
ExecStart=/usr/local/bin/adb-server /usr/local/etc/adb/adb.conf
ExecStart=/usr/local/bin/kvdb-server /usr/local/etc/kvdb/kvdb.conf
ExecStopPost=
PIDFile=
Restart=always

File diff suppressed because it is too large Load Diff