在ARM64系统上部署Redis
redis源码包下载并编译安装
redis已经自己写好了make file ,故不需要configure操作了
cd ~
wget http://download.redis.io/releases/redis-4.0.0.tar.gz
tar -xvf redis-4.0.0.tar.gz
cd redis-4.0.0
sudo mkdir /usr/local/redis
sudo make
sudo make PREFIX=/usr/local/redis install
sudo mkdir /usr/local/redis/etc
sudo cp ~/redis-4.0.0/redis.conf /usr/local/redis/etc
更改配置
更改redis配置
sudo vim /usr/local/redis/etc/redis.conf
#将redis改为以守护进程的方式运行
daemonize yes
取消注释requirepass
requirepass password
注释bind
#bind 127.0.0.1
添加环境变量
sudo echo 'export PATH="$PATH:/usr/local/redis/bin"'>> /etc/profile
sudo source /etc/profile
设置systemctl方式启动
添加配置启动脚本
sudo vim /etc/rc.d/init.d/redis
#!/bin/bash
#chkconfig: 2345 80 90
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
给脚本增加运行权限
sudo chmod +x /etc/init.d/redis
查看服务列表
sudo chkconfig --list
添加服务
sudo chkconfig --add redis
配置启动级别
sudo chkconfig --level 2345 redis on
启动服务并查看
sudo systemctl start redis
sudo systemctl status redis