1.下载
wget https://download.redis.io/releases/redis-6.2.1.tar.gz
2.CentOS7 修改yum源为阿里源
下载阿里yum源配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
更新yum缓存:yum clean all
3.解压到 /usr/local/
[root@do8888 local]# tar -zxvf redis-6.2.1.tar.gz -C /usr/local/
4.编译需要安装的包
yum -y install gcc gcc-c++ cmake
5.编译redis需要安装的包
yum -y install tcl-devel
6.进入 /usr/locat/redis-6.2.1 安装编译包
[root@do8888 redis-6.2.1]# pwd /tmp/redis-6.2.1
安装
make PREFIX=/usr/local/redis install
7.配置文件
[root@do8888 redis-6.2.1]# egrep -v "#|^$" /usr/local/redis-6.2.1/redis.conf bind 127.0.0.1 -::1 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize no pidfile /var/run/redis_6379.pid loglevel notice logfile ""
8.从库配
bind 127.0.0.1
port 6380
slaveof 127.0.0.1 6379
127.0.0.1:6379> SLOWLOG get 获取慢查询队列
(empty list or set)
127.0.0.1:6379> SLOWLOG len 获取慢查询队列长度
(integer) 0
127.0.0.1:6379> SLOWLOG reset 清空慢查询队列
OK
动态设置慢查询
127.0.0.1:6379> CONFIG set slowlog-max-len 1
OK
127.0.0.1:6379> CONFIG set slowlog-log-slower-than 1000
OK