一.安装前准备
1.关闭SELinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# echo "/usr/sbin/setenforce 0"
[root@localhost ~]# sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
[root@localhost ~]# sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.关闭防火墙
[root@localhost ~]# systemctl stop iptables
[root@localhost ~]# systemctl disable iptables
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
3.时钟校对
[root@localhost ~]# yum -y install ntpdate
[root@localhost ~]# echo "#Clock synchronization" >> /var/spool/cron/root
[root@localhost ~]# echo "01 00 * * * /sbin/ntpdate ntp2.aliyun.com;/sbin/hwclock -w" >> /var/spool/cron/root
4.调整文件打开数
[root@localhost ~]# cat <<EOF > /etc/security/limits.d/20-nproc.conf
root soft nofile 102400
root hard nofile 102400
EOF
二.安装依赖
[root@localhost ~]#yum install -y cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl
1.需要先安装gcc新版才能编译
centos7 默认的 gcc 版本小于 5.3 无法编译
2.安装scl源
[root@localhost ~]#yum -y install centos-release-scl scl-utils-build
3.列出scl可用源
[root@localhost ~]#yum list all --enablerepo='centos-sclo-rh'
[root@localhost ~]#yum list all --enablerepo='centos-sclo-rh' | grep "devtoolset-"
4.安装新版本的gcc、gcc-c++、gdb工具链(toolchian)
[root@localhost ~]#yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
5.临时生效,退出 shell 或重启会恢复原 gcc 版本
[root@localhost ~]# scl enable devtoolset-9 bash
6.永久生效
[root@localhost ~]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
三.下载最新版本redis
[root@localhost ~]#wget http://download.redis.io/releases/redis-6.0.8.tar.gz
1.解压安装
[root@localhost ~]# tar -xf redis-6.0.8.tar.gz
[root@localhost ~]# cd redis-6.0.8
[root@localhost redis-6.0.8]# make
[root@localhost redis-6.0.8]# make test
Make test需要几分钟的时间
最后会提示有下面的提示说明没有问题可以继续
\o/ All tests passed without errors!
\ o /所有测试均顺利通过!
Cleanup: may take some time… OK
清理:可能需要一些时间…好
[root@localhost redis-6.0.8]# make install
cd src && make install
make[1]: 进入目录“/root/redis-6.0.8/src”
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/root/redis-6.0.8/src”
2.编译文件会复制到/usr/local/bin目录下
[root@localhost redis-6.0.8]# ls /usr/local/bin/
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
3.修改redis.conf文件并复制到etc目录
[root@localhost redis-6.0.8]# vim redis.conf
bind 127.0.0.1 #根据情况是否需要远程访问去掉注释
requirepass 123456 #修改密码
daemonize yes 后台运行
protected-mode no # 关闭protected-mode模式,此时外部网络可以直接访问
pidfile /home/redis/etc/redis_6379.pid
logfile /home/redis/logs/redis.log
dir /home/redis/db/
4.创建文件目录
[root@localhost redis-6.0.8]# mkdir /home/redis
[root@localhost redis-6.0.8]# mkdir /home/redis/{logs,db,etc}
[root@localhost redis-6.0.8]# touch /home/redis/logs/redis.log
修改环境变量
[root@localhost redis-6.0.8]# vim /etc/profile
在最后添加
export REDIS_HOME=/usr/local/bin
export PATH=$PATH:$REDIS_HOME
5.启动服务
[root@localhost redis-6.0.8]# redis-server /home/redis/etc/redis.conf
[root@localhost redis-6.0.8]# ps -aux |grep redis
root 22936 0.1 0.4 162420 7852 ? Ssl 11:28 0:00 redis-server 0.0.0.0:6379
root 22942 0.0 0.0 112828 984 pts/0 S+ 11:28 0:00 grep --color=auto redis
安装redis6最大的不同,就是要安装新版的GCC,否则不能编译。