Skip to content

Commit

Permalink
Merge pull request #910 from ctripcorp/feature/uat_automic_deploy
Browse files Browse the repository at this point in the history
add inject data script for pt redis
  • Loading branch information
LanternLee authored Nov 20, 2024
2 parents 2b336d5 + 964bee8 commit 8a60c07
Showing 1 changed file with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,26 @@ echo $DIR
PORT=${DIR##*/}
CONFIG=$DIR/master.conf
DATA=$DIR/data
LOG=/opt/data/redis/$(($PORT / 1000))/$PORT
echo $LOG
FILE=/opt/data/redis/$(($PORT / 1000))/$PORT
echo $FILE
LOG=$FILE
SLEEP=1

mkdir -p $DATA
mkdir -p $LOG
chmod 755 $LOG
mkdir -p $FILE
chmod 755 $FILE

function toUpper(){
echo $(echo $1 | tr [a-z] [A-Z])
}

function getType(){
TYPE=NORMAL
if [ -f /opt/settings/server.properties ];then
TYPE=`cat /opt/settings/server.properties | egrep -i "^type" | awk -F= '{print $2}'`
fi
echo `toUpper $TYPE`
}

if [ -n "$PORT" ]; then
echo "port from dir:$PORT"
Expand All @@ -27,8 +40,19 @@ if [ $preCount -ge 0 ]; then
sleep 1
fi

DATA_DIR=$DIR"/data"
sed -i "s#dir.*#dir $DATA_DIR#" $DIR/*.conf
TYPE=`getType`
echo "TYPE:"$TYPE
if [ $TYPE = "LARGE" ];then
DATA_DIR="$FILE/data"
mkdir -p $DATA_DIR
chmod 755 $DATA_DIR
cp /opt/data/redis-rdb/dump.rdb $DATA_DIR
sed -i "s#dir.*#dir $DATA_DIR#" $DIR/*.conf
sed -i 's/^maxmemory.*mb$/maxmemory 10gb/' $DIR/*.conf
else
DATA_DIR=$DIR"/data"
sed -i "s#dir.*#dir $DATA_DIR#" $DIR/*.conf
fi

REDIS=redis-server
if [ -f ~/redis/redis-server ]; then
Expand Down

0 comments on commit 8a60c07

Please sign in to comment.