Redis二进制安装
一、系统信息
[root@centos8 07:40:23~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
二、安装依赖包
[root@centos8 07:41:39~]# yum -y install gcc automake autoconf libtool make gcc-c++ vim wget
三、下载软件6.2.5版本的redis
[root@centos8 07:53:17~]# wget https://download.redis.io/releases/redis-6.2.5.tar.gz
四、创建目录
[root@centos8 07:54:14~]# mkdir /data/software/redis
五、安装redis
[root@centos8 07:56:36~]# tar -zxf redis-6.2.5.tar.gz && \
cd redis-6.2.5 && \
make -j 4 PREFIX=//data/software/redis install
五、创建所需要的目录
[root@centos8 07:58:30~]# cd /data/software/redis/ && mkdir data log run etc
六、配置redis配置文件
[root@centos8 08:00:02~]# cat > /data/software/redis/etc/redis.conf <
七、配置redis环境变量
[root@centos8 08:08:30~]# cat > /etc/profile.d/redis_home.sh <
八、配置启动关闭脚本
[root@centos8 08:10:37~]# cat /etc/init.d/redis
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.### BEGIN INIT INFO
# Provides: redis_6379
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Redis data structure server
# Description: Redis data structure server. See https://redis.io
### END INIT INFOREDISPORT=6379
EXEC=/data/software/redis/bin/redis-server
CLIEXEC=/data/software/redis/bin/redis-cliPIDFILE=/data/software/redis/run/redis.pid
CONF="/data/software/redis/etc/redis.conf"case "$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, process is already running or crashed"elseecho "Starting Redis server..."$EXEC $CONFfi;;stop)if [ ! -f $PIDFILE ]thenecho "$PIDFILE does not exist, process is not running"elsePID=$(cat $PIDFILE)echo "Stopping ..."$CLIEXEC -p $REDISPORT -a $(awk '$1=="requirepass" {print $2}' ${CONF}) --no-auth-warning shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown ..."sleep 1doneecho "Redis stopped"fi;;*)echo "Please use start or stop as first argument";;
esac
九、添加用户和修改属性
[root@centos8 08:12:48~]# useradd -r -s /sbin/nologin redis[root@centos8 08:13:47~]# chown redis:redis -R /data/software/redis
十、加入到system管理服务中同时启动服务
[root@centos8 08:16:19~]# chmod +x /etc/init.d/redis && \
chkconfig --add redis && \
chkconfig --level 345 redis on && \
systemctl daemon-reload && \
systemctl start redis && \
netstat -untpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 11172/redis-server
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 966/sshd
tcp6 0 0 :::22 :::* LISTEN 966/sshd
udp 0 0 127.0.0.1:323 0.0.0.0:* 945/chronyd
udp6 0 0 ::1:323 :::* 945/chronyd
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
