一、redis安装
1、下载安装包:https://codeload.github.com/redis/redis/tar.gz/refs/tags/7.0.12
2、上传并解压安装包
[luo@localhost redis]$ tar -zxvf redis-7.0.12.tar.gz
3、进入解压后的文件夹进行编译安装
[luo@localhost redis]cd redis-7.0.12 [luo@localhost redis]make && make install
二、redis启动
1、前台启动
redis-server
2、后台启动
1.修改配置文件
vim redis.conf bind 0.0.0.0 #监听的地址,默认是127.0.0.1,会导致只能在本地访问,修改为0.0.0.0则可以在意IP访问, daemonize yes #守护讲程,改为yes后即可后台运行 requirepass 123321 #密码,设置后访问Redis必须输入密码 logfile "redis.log" #日志文件,可以指定日志文件名
2.此时就可以后台启动了
[root@localhost redis-7.0.12]# redis-server redis.conf
3、开机自启
1.配置文件
[root@localhost redis-7.0.12]# vi /etc/systemd/system/redis.service //复制以下配置文件即可 [Unit] Description=redis-server After=network.target [Service] Type=forking ExecStart=/usr/local/bin/redis-server /export/server/redis/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target ~
2.重启配置文件并使之生效
[root@localhost redis-7.0.12]# systemctl daemon-reload [root@localhost redis-7.0.12]# systemctl start redis // 启动 [root@localhost redis-7.0.12]# systemctl restart redis //重启 [root@localhost redis-7.0.12]# ststemctl status redis //查看状态 [root@localhost redis-7.0.12]# ststemctl stop redis //停止 [root@localhost redis-7.0.12]# ststemctl status redis [root@localhost redis-7.0.12]# ststemctl enable redis [root@localhost redis-7.0.12]# systemctl start redis