@@ -9,8 +9,8 @@ rm -rf /tmp/codis || true
99rm -rf codis_data_1 || true
1010rm -rf codis_data_2 || true
1111
12- # Clean up log directory in codis to free space, but preserve bin if it exists
13- # to avoid unnecessary recompilation
12+ # Clean up temporary directories in codis to free space
13+ rm -rf ../codis/bin || true
1414rm -rf ../codis/log || true
1515mkdir -p ../codis/bin
1616mkdir -p ../codis/log
@@ -39,9 +39,9 @@ mkdir codis_data_2
3939sed -i.bak -e ' s|databases : 1|databases : 2|' -e ' s|port : 9221|port : 8000|' -e ' s|log-path : ./log/|log-path : ./codis_data_1/log/|' -e ' s|db-path : ./db/|db-path : ./codis_data_1/db/|' -e ' s|dump-path : ./dump/|dump-path : ./codis_data_1/dump/|' -e ' s|pidfile : ./pika.pid|pidfile : ./codis_data_1/pika.pid|' -e ' s|db-sync-path : ./dbsync/|db-sync-path : ./codis_data_1/dbsync/|' -e ' s|#daemonize : yes|daemonize : yes|' ./pika_8000.conf
4040sed -i.bak -e ' s|databases : 1|databases : 2|' -e ' s|port : 9221|port : 8001|' -e ' s|log-path : ./log/|log-path : ./codis_data_2/log/|' -e ' s|db-path : ./db/|db-path : ./codis_data_2/db/|' -e ' s|dump-path : ./dump/|dump-path : ./codis_data_2/dump/|' -e ' s|pidfile : ./pika.pid|pidfile : ./codis_data_2/pika.pid|' -e ' s|db-sync-path : ./dbsync/|db-sync-path : ./codis_data_2/dbsync/|' -e ' s|#daemonize : yes|daemonize : yes|' ./pika_8001.conf
4141# Start pika instances with reduced memory footprint
42- # Add memory_limit parameter to reduce memory usage
43- sed -i.bak -e ' s|#max-memory : 0|max-memory : 512 |' ./pika_8000.conf
44- sed -i.bak -e ' s|#max-memory : 0|max-memory : 512 |' ./pika_8001.conf
42+ # Add memory_limit parameter to reduce memory usage (256MB per instance)
43+ sed -i.bak -e ' s|#max-memory : 0|max-memory : 256 |' ./pika_8000.conf
44+ sed -i.bak -e ' s|#max-memory : 0|max-memory : 256 |' ./pika_8001.conf
4545
4646# Start instances one by one with time to initialize
4747./pika -c ./pika_8000.conf
@@ -54,14 +54,18 @@ sleep 10
5454free -h || true
5555
5656cd ../codis
57- # Check if codis is already built to avoid unnecessary compilation
58- if [ ! -f " bin/codis-admin" ] || [ ! -f " bin/codis-proxy" ] || [ ! -f " bin/codis-dashboard" ]; then
59- echo " Building codis..."
60- make
61- else
62- echo " Codis already built, skipping compilation..."
57+ echo " Building codis..."
58+
59+ # Free up memory before building
60+ echo " Clearing caches to free up memory..."
61+ sync
62+ if [ $( id -u) -eq 0 ]; then
63+ echo 3 > /proc/sys/vm/drop_caches || true
6364fi
6465
66+ # Limit parallel jobs during make to reduce memory usage
67+ make -j2
68+
6569echo ' startup codis dashboard and codis proxy'
6670./admin/codis-dashboard-admin.sh start
6771./admin/codis-proxy-admin.sh start
0 commit comments