代码改变世界

CentOS6.10安装redis6.0.6

2020-08-13 14:53  猎手家园  阅读(811)  评论(0编辑  收藏  举报

1、下载安装包:http://redis.io

2、安装依赖

[root@centos6 ~] yum install -y cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl

 

3、解压安装

[root@centos6 ~] tar -zxvf redis-6.0.6.tar.gz
[root@centos6 ~] cd redis-6.0.6
[root@centos6 ~] make
[root@centos6 ~] make test
[root@centos6 ~] make install

 

出现问题:error: unrecognized command line option "-std=c11"

原因是gcc版本低,默认安装的是4.4.7,而redis6需要更高的版本 >=4.9 

可到到官网 http://ftp.gnu.org/gnu/gcc/ 下载4.9.4版本,手动安装。

注意安装gcc4.9.4版本还需要mpc、mpfr、gmp等依赖(MPFR=mpfr-2.4.2;GMP=gmp-4.3.2;MPC=mpc-0.8.1)。

安装顺序:gmp > mpfr > mpc

[root@centos6 ~] tar zxvf gmp-4.2.3.tar.gz
[root@centos6 ~]# cd gmp-4.2.3
[root@centos6 gmp-4.2.3]# mkdir gmp-build 
[root@centos6 gmp-4.2.3]# cd gmp-build
[root@centos6 gmp-build]# ../configure --prefix=/usr/local/gmp-4.2.3
[root@centos6 gmp-build]# make && make install
[root@centos6 ~] tar zxvf mpfr-2.4.2.tar.gz
[root@centos6 ~]# cd mpfr-2.4.2
[root@centos6 mpfr-2.4.2]# mkdir mpfr-build 
[root@centos6 mpfr-2.4.2]# cd mpfr-build
[root@centos6 mpfr-build]# ../configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.2.3
[root@centos6 mpfr-build]# make && make install
[root@centos6 ~] tar zxvf mpc-0.8.1.tar.gz
[root@centos6 ~]# cd mpc-0.8.1
[root@centos6 mpc-0.8.1]# mkdir mpc-build 
[root@centos6 mpc-0.8.1]# cd mpc-build
[root@centos6 mpc-build]# ../configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.2.3 --with-mpfr=/usr/local/mpfr-2.4.2
[root@centos6 mpc-build]# make && make install

 

 保存到环境变量:

[root@centos6 ~] vim /etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.2.3/lib:/usr/local/mpfr-2.4.2/lib

[root@centos6 ~] source /etc/profile

 

 安装GCC

[root@centos6 ~] tar -xzf gcc-4.9.4.tar.gz
[root@centos6 ~] cd gcc-4.9.4
[root@centos6 gcc-4.9.4] mkdir gcc-build
[root@centos6 gcc-4.9.4] cd gcc-build
[root@centos6 gcc-build] ../configure --prefix=/usr/local/gcc-4.9.4 --disable-multilib --disable-checking --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.2.3 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
[root@centos6 gcc-build] make -j4 && make install

 

调整gcc相关命令:

[root@centos6 ~] mv /usr/bin/gcc /usr/bin/gcc-4.9.4
[root@centos6 ~] ln -s /usr/local/gcc-4.9.4/bin/gcc /usr/bin/gcc
[root@centos6 ~] /usr/bin/gcc -v
[root@centos6 ~] mv /usr/bin/g++ /usr/bin/g++-4.9.4
[root@centos6 ~] ln -s /usr/local/gcc-4.9.4/bin/g++ /usr/bin/g++
[root@centos6 ~] mv /usr/bin/c++ /usr/bin/c++-4.9.4
[root@centos6 ~] ln -s /usr/local/gcc/bin-4.9.4/c++ /usr/bin/c++

 

4、继续安装redis6,安装完成后修改配置文件

[root@centos6 ~]# vim redis.conf  #修改配置文件
protected-mode no # 关闭保护模式
daemonize yes     # 守护进程模式开启
bind 127.0.0.1    # 绑定IP按需修改
port 6379         # 端口按需修改

 

5、启动

[root@centos6 redis6.0.6]# ./src/redis-server redis.conf   #启动服务命令
[root@centos6 redis6.0.6]# netstat -tunpl | grep 6379     #查看6379端口是否占用