centos8安装redis5.0.7
1下载软件
cd /server/tools
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
2重名了解压目录并移动至指定目录中
tar -xzf redis-5.0.7.tar.gz
mv tar -xzf redis-5.0.7 /application/redis
3安装依赖
cd ~
yum install gcc
yum install tcl
4编译安装
cd /application/redis
make MALLOC=libc
5测试安装(出现\o/ All tests passed without errors!表示成功)
make test
6编辑配置文件:
[root@laiyue-20210601 ~]#vim /application/redis/redis.conf
说明:分别是以daemon方式独立运行 / 内存的最大使用限制
# daemonize no daemonize yes # maxmemory <bytes> maxmemory 2048MB
7运行:
[root@laiyue-20210601 ~]#/application/redis/src/redis-server /application/redis/redis.conf
8检查端口是否在使用中
[root@laiyue-20210601 ~]#netstat -anp |grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 374691/redis-server
9查看redis版本:
[root@laiyue-20210601 ~]#/application/redis/src/redis-server -v
10使redis可以用systemd方式启动和管理:
[root@laiyue-20210601 ~]#vim /lib/systemd/system/redis.service
[root@laiyue-20210601 ~]#cat /lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/application/redis/src/redis-server /application/redis/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
11重载系统服务:
[root@laiyue-20210601 ~]#systemctl daemon-reload
[root@laiyue-20210601 ~]#
12管理命令:
[root@开始 ~]#systemctl start redis
[root@停止 ~]#systemctl stop redis
[root@状态 ~]#systemctl status redis
[root@设为开机自启 ~]#systemctl enable redis
13添加环境变量:
[root@laiyue-20210601 ~]#find /application/redis -name "redis-cli"
/application/redis/src/redis-cli
[root@laiyue-20210601 ~]#vim ~/.bash_profile
[root@laiyue-20210601 ~]#source ~/.bash_profile
[root@laiyue-20210601 ~]#cat vim ~/.bash_profile
cat: vim: No such file or directory
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/bin
#export PATH
export REDIS_HOME=/application/redis
export PATH=$PATH:$REDIS_HOME/src
[root@laiyue-20210601 ~]#
[root@laiyue-20210601 ~]#redis-cli
127.0.0.1:6379> exit
![]()
14在任何位置登录:
redis-cli redis-cli -h localhost redis-cli -h 127.0.0.1 redis-cli -h 127.0.0.1 -p 6378 redis-cli -p 6378