33# Clean up processes and temporary files
44pkill -9 pika || true
55pkill -9 codis || true
6+ # Wait for processes to fully terminate and release resources
7+ sleep 5
68rm -rf /tmp/codis || true
79rm -rf codis_data_1 || true
810rm -rf codis_data_2 || true
911
10- # Clean up temporary directories in codis to free space
11- rm -rf ../codis/bin || true
12+ # Clean up log directory in codis to free space, but preserve bin if it exists
13+ # to avoid unnecessary recompilation
1214rm -rf ../codis/log || true
1315mkdir -p ../codis/bin
1416mkdir -p ../codis/log
1517
18+ # Display memory usage for monitoring
19+ free -h || true
20+
1621# Display available disk space
1722df -h
1823
@@ -33,14 +38,29 @@ mkdir codis_data_2
3338# Example Change the location for storing data on primary and secondary nodes in the configuration file
3439sed -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
3540sed -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
36- # Start three nodes
41+ # 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
45+
46+ # Start instances one by one with time to initialize
3747./pika -c ./pika_8000.conf
48+ sleep 5
3849./pika -c ./pika_8001.conf
3950# ensure both master and slave are ready
4051sleep 10
4152
53+ # Display memory usage after starting pika instances
54+ free -h || true
55+
4256cd ../codis
43- make
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..."
63+ fi
4464
4565echo ' startup codis dashboard and codis proxy'
4666./admin/codis-dashboard-admin.sh start
0 commit comments