本次安装的系统版本如下:
[root@zhangqinglei ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@zhangqinglei ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-
noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarchDistributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
因不同的系统版本会存在一些差异,因此记录比对。后续针对centos其他版本测试安装说明。
本次安装的redis版本如下
redis-3.2.13.tar.gz
安装在一台服务器,并且分别提供不同的端口。以及针对redis的卸载进行说明。
目录:
安装目录:/home/soft
工具目录:/home/tools
rz上传到工具目录,redis-3.2.13.tar.gz
解压到soft目录
tar -zxvf redis-3.2.13.tar.gz -C /home/soft/
cd /home/soft/
改名
mv redis-3.2.13 redis3-6379
表示为redis3版本,开放端口为6379
进入目录开始安装
cd redis3-6379
make && make install
等待1分钟左右后执行完成无报错
进入到utils目录下,执行redis初始化脚本install_server.sh
cd utils/
./install_server.sh
执行如下步骤
填写端口号,以及其他的路径,如果默认则直接回车
从安装过程来看,创建了一个文件在
/etc/init.d/redis_6379
查看该文件内容
#!/bin/sh#Configurations injected by install_server below.... EXEC=/usr/local/bin/redis-server CLIEXEC=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_6379.pid CONF="/etc/redis/6379.conf"REDISPORT="6379"############### # SysV Init Information # chkconfig: - 58 74# description: redis_6379 is the redis daemon. ### BEGIN INIT INFO # Provides: redis_6379 # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Should-Start: $syslog $named # Should-Stop: $syslog $named # Short-Description: start and stop redis_6379 # Description: Redis daemon ### END INIT INFOcase "$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 shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown ..."sleep 1doneecho "Redis stopped"fi;; status) PID=$(cat $PIDFILE)if [ ! -x /proc/${PID} ]thenecho 'Redis is not running'elseecho "Redis is running ($PID)"fi;; restart) $0 stop $0 start ;;*)echo "Please use start, stop, restart or status as first argument";;esac
可以得知,
启动为/etc/init.d/redis_6379 start
停止为/etc/init.d/redis_6379 stop
查看状态为/etc/init.d/redis_6379 status
redis.config默认绑定的IP为127.0.0.1,密码没有设置
安装即启动了,查看状态
[root@zhangqinglei redis3-6379]# /etc/init.d/redis_6379 status
Redis is running (8236)
当前正在运行中,进程ID为8236
进入到src目录下,使用redis-cli进行连接测试
[root@zhangqinglei src]# ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> set first 1
OK
127.0.0.1:6379> get first
“1”
127.0.0.1:6379> keys *
1) “first”
使用exit退出。至此成功安装。
The above is the detailed content of How to install redis3.2 in stand-alone environment in centos7. For more information, please follow other related articles on the PHP Chinese website!