🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
目录规划 ``` ### redis下载目录 /data/soft/ ### redis安装目录 /opt/redis_cluster/redis_{PORT}/{conf,logs,pid} ### redis数据目录 /data/redis_cluster/redis_{PORT}/redis_{PORT}.rdb ### redis运维脚本 /root/scripts/redis_shell.sh ``` 安装命令 ``` ### 创建下载目录,安装目录和数据目录 mkdir -p /data/soft mkdir -p /data/redis_cluster/redis_6379 mkdir -p /opt/redis_cluster/redis_6379/{conf,pid,logs} ### 下载软件和创建软链接 cd /data/soft/ wget http://download.redis.io/releases/redis-3.2.9.tar.gz tar zxf redis-3.2.9.tar.gz -C /opt/redis_cluster/ ln -s /opt/redis_cluster/redis-3.2.9/ /opt/redis_cluster/redis ### 编译安装 cd /opt/redis_cluster/redis make && make install ``` 简单配置文件 vim /opt/redis_cluster/redis_6379/conf/redis_6379.conf ``` bind 172.16.1.90 port 6379 daemonize yes pidfile /opt/redis_cluster/redis_6379/pid/redis_6379.pid logfile /opt/redis_cluster/redis_6379/logs/redis_6379.log databases 16 dbfilename redis_6379.rdb dir /data/redis_cluster/redis_6379 ``` 集群管理脚本 ``` #!/bin/bash #Author:Alaska #Blog:null #Time:2018-03-27 07:07:31 #Name:redis_start.sh #Version:V1.0 #Description:This is a test script. USAG(){ echo "sh $0 {start|stop|restart|login|ps|tail} PORT" } if [ "$#" = 1 ] then REDIS_PORT='6379' elif [ "$#" = 2 -a -z "$(echo "$2"|sed 's#[0-9]##g')" ] then REDIS_PORT="$2" else USAG exit 0 fi REDIS_IP=$(hostname -I|awk '{print $2}') PATH_DIR=/opt/redis_cluster/redis_${REDIS_PORT}/ PATH_CONF=/opt/redis_cluster/redis_${REDIS_PORT}/conf/redis_${REDIS_PORT}.conf PATH_LOG=/opt/redis_cluster/redis_${REDIS_PORT}/logs/redis_${REDIS_PORT}.log CMD_START(){ redis-server ${PATH_CONF} } CMD_SHUTDOWN(){ redis-cli -c -h ${REDIS_IP} -p ${REDIS_PORT} shutdown } CMD_LOGIN(){ redis-cli -c -h ${REDIS_IP} -p ${REDIS_PORT} } CMD_PS(){ ps -ef|grep redis } CMD_TAIL(){ tail -f ${PATH_LOG} } case $1 in start) CMD_START CMD_PS ;; stop) CMD_SHUTDOWN CMD_PS ;; restart) CMD_START CMD_SHUTDOWN CMD_PS ;; login) CMD_LOGIN ;; ps) CMD_PS ;; tail) CMD_TAIL ;; *) USAG esac ```