zoukankan      html  css  js  c++  java
  • centos7 安装 redis4.0.8

    1.安装lrzsz

    yum install lrzsz -y

    2.利用rz命令将window中从redis官网下载好的“redis-4.0.8.tar.gz” 拷贝到centos中

    redis官网 :https://redis.io/

    3.解压

    mkdir tmp
    cd tmp
    tar
    -zvxf redis-4.0.8.tar.gz

    4.将tmp中的解压文件复制到/usr/local/redis,并且重命名

    [root@localhost tmp]# ll
    总用量 1696
    drwxrwxr-x. 6 root root    4096 2月   3 00:39 redis-4.0.8
    -rw-r--r--. 1 root root 1729973 2月   8 20:51 redis-4.0.8.tar.gz
    [root@localhost ~]# mkdir usr
    [root@localhost ~]# cd usr
    [root@localhost usr]# mkdir local
    [root@localhost usr]# cd /tmp
    [root@localhost tmp]# mv redis-4.0.8 /usr/local/redis

    4.安装gcc

    yum install gcc gcc-c+ tcl tcl-devel -y

    5.使用make编译源码

    [root@localhost redis]# make -j 4

    执行完后发现报错:

    zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录

    解决方案:

    make clean
    make MALLOC=libc

    6.把编译完成的可执行文件添加到系统目录中,然后我们就可以正常访问了。

    make install

    参考资料:centOS6.3 安装redis make报错 zmalloc.h:50:31: 错误:jemalloc/jemalloc.h:没有那个文件或目录

    7.配置文件

    [root@localhost redis]# ll
    总用量 296
    -rw-rw-r--.  1 root root 150927 2月   3 00:39 00-RELEASENOTES
    -rw-rw-r--.  1 root root     53 2月   3 00:39 BUGS
    -rw-rw-r--.  1 root root   1815 2月   3 00:39 CONTRIBUTING
    -rw-rw-r--.  1 root root   1487 2月   3 00:39 COPYING
    drwxrwxr-x.  6 root root    192 2月  10 00:00 deps
    -rw-rw-r--.  1 root root     11 2月   3 00:39 INSTALL
    -rw-rw-r--.  1 root root    151 2月   3 00:39 Makefile
    -rw-rw-r--.  1 root root   4223 2月   3 00:39 MANIFESTO
    -rw-rw-r--.  1 root root  20543 2月   3 00:39 README.md
    -rw-rw-r--.  1 root root  58353 2月   3 00:39 redis.conf
    -rwxrwxr-x.  1 root root    271 2月   3 00:39 runtest
    -rwxrwxr-x.  1 root root    280 2月   3 00:39 runtest-cluster
    -rwxrwxr-x.  1 root root    281 2月   3 00:39 runtest-sentinel
    -rw-rw-r--.  1 root root   7606 2月   3 00:39 sentinel.conf
    drwxrwxr-x.  3 root root   8192 2月  10 00:04 src
    drwxrwxr-x. 10 root root    167 2月   3 00:39 tests
    drwxrwxr-x.  8 root root   4096 2月   3 00:39 utils

    其中的redis.conf后期需要重点从头到尾的研究一遍。

    这里我们更改如下几个参数

     1) bind

    这个参数的意思是允许哪个ip访问我的redis服务器

    默认是127.0.0.1,也就是本机才能够访问

    若系统是分布式的,则需要修改

    把这个参数改成

    bind 0.0.0.0

    也就是任意一台服务器都能够访问。

    2)daemonize

    允许后台执行

    默认是no

    这里设置成yes

    参考资料:Redis daemonize介绍

    8.启动redis

    启动时指定配置文件

    redis-server ./redis.conf

    查看redis进程

    ps -ef|grep redis

    9.访问redis

     redis-cli

    10.设置密码

    requirepass 123456

    然后保存退出

    重启redis,执行如下

    redis-cli
    
    shutdown save
    
    exit

    重启redis后,get或者set等操作的时候必须授权密码

     11.做成系统服务

    cd cd utils/
    ll
    ./install_server.sh
    
    
    /usr/local/redis/redis.conf
    /usr/local/redis/redis.log
    /usr/local/redis/data

    检查服务是否已经存在了

    chkconfig --list|grep redis

    systemctl status redis_6379

    systemctl stop redis_6379
    systemctl start redis_6379
    ps -ef|grep redis

    vim /etc/init.d/redis_6379
  • 相关阅读:
    洛谷P1514引水入城
    洛谷P2827蚯蚓
    外部排序总结
    桶排序
    基数排序
    计数排序
    搜索文件-读目录的使用
    堆排序
    甲乙用同一串数字玩游戏
    Cracking the Coding Interview 8.7
  • 原文地址:https://www.cnblogs.com/knyel/p/8437227.html
Copyright © 2011-2022 走看看