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/config2.关闭防火墙
[root@localhost ~]# systemctl stop iptables [root@localhost ~]# systemctl disable iptables [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# systemctl disable firewalld3.时钟校对
[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/root4.调整文件打开数
[root@localhost ~]# cat <<EOF > /etc/security/limits.d/20-nproc.conf root soft nofile 102400 root hard nofile 102400 EOF1.需要先安装gcc新版才能编译 centos7 默认的 gcc 版本小于 5.3 无法编译 2.安装scl源
[root@localhost ~]#yum -y install centos-release-scl scl-utils-build3.列出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-binutils5.临时生效,退出 shell 或重启会恢复原 gcc 版本
[root@localhost ~]# scl enable devtoolset-9 bash6.永久生效
[root@localhost ~]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile1.解压安装
[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 testMake 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-server3.修改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_HOME5.启动服务
[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,否则不能编译。