Centos7.4 安装Redis3.2.4(单点)
一、普通用户zhaosj安装Redis3.2.4
1、创建安装目录
[[email protected] redis]# cd /home/zhaosj/redis
2、上传并解压安装包
[[email protected] redis]# tar -zxvf redis-3.2.4.tar.gz
3、执行make命令, 对Redis解压后文件进行编译
4、切换到src目录,进行编译安装
使用sudo命令切换
[[email protected] src]$ sudo -s
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for zhaosj:
编译安装
二、启动redis的三种方式
先切换到redis src目录下
1、直接启动redis
./redis-server
如上图:redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。
按 ctrl + c可以关闭窗口。
2、以后台进程方式启动redis
第一步:修改redis.conf文件
将:daemonize no 改为:daemonize yes
启动方法:
[[email protected] src]$ ./redis-server ../redis.conf
3、设置redis开机自启动
1、在/etc目录下新建redis目录
mkdir redis
2、将# cp redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf
[[email protected] redis-3.2.4]# cp redis.conf /etc/6379.conf
3、将redis的启动脚本复制一份放到/etc/init.d目录下
4、设置redis开机自启动
先切换到/etc/init.d目录下
然后执行自启命令
# chkconfig redisd on
看结果是redisd不支持chkconfig
解决方法:
使用vim编辑redisd文件,在第一行加入如下两行注释,保存退出
# chkconfig: 2345 90 10 # description: Redis is a persistent key-value database
注释的意思是,redis服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。
再次执行开机自启命令,成功
# chkconfig redisd on