zoukankan      html  css  js  c++  java
  • redis配置笔记

    #cd /opt
    #tar -zxvf redis-4.0.6.tar.gz
    #cd redis-4.0.6
    #make
    #cd src
    #make install PREFIX=/usr/local/redis
    #mkdir –p /usr/local/redis/etc放配置文件
    #mv /opt/redis-4.0.6/redis.conf /usr/local/redis/etc/
    修改配置文件:
    默认情况,Redis不是在后台运行,我们需要把redis放在后台运行
    vi /usr/local/redis/etc/redis.conf
    将daemonize的值改为yes
    bind 192.168.100.101
    save <seconds> <changes>:保存快照的频率
    将其注释掉:
    # save 900 1
    # save 300 10
    # save 60 10000

    启动:

    # /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 
    10422:C 09 Jan 16:41:21.005 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    10422:C 09 Jan 16:41:21.005 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=10422, just started
    10422:C 09 Jan 16:41:21.005 # Configuration loaded

    测试:

    [root@redis-master bin]# ./redis-cli -h 10.174.66.201 -p 6379 或
    [root@redis-master bin]# ./redis-cli 
    192.168.100.101:6379> info
    # Server
    redis_version:4.0.6
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:e17e63b9178f2308
    redis_mode:standalone
    os:Linux 3.10.0-693.el7.x86_64 x86_64
    arch_bits:64
    ……
    
    192.168.100.101:6379> set key hello
    OK
    192.168.100.101:6379> get key
    "hello"
    192.168.100.101:6379> keys *
    1) "key"
    192.168.100.101:6379> FLUSHALL
    OK
    192.168.100.101:6379>

    停止redis实例

    # ./redis-cli -h 192.168.100.101 -p 6379
    192.168.100.101:6379> SHUTDOWN

    redis主从配置,修改slave从服务器的配置文件。
    slaveof 192.168.100.101 6379 (映射到主服务器上)

    查看master服务器

    [root@redis-master bin]# ./redis-cli -h 192.168.100.101 -p 6379
    192.168.100.101:6379> info
    ……
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=192.168.100.102,port=6379,state=online,offset=42,lag=0
    master_replid:a0d0bdb21443e69c99a32bc3859be833d61d09cc
    master_replid2:0000000000000000000000000000000000000000
    ……

    查看slave服务器:

    [root@redis-slave bin]# ./redis-cli -h 10.174.66.202 -p 6379
    192.168.100.102:6379> info
    # Replication
    role:slave
    master_host:10.174.66.201
    master_port:6379
    master_link_status:up

    添加开机自启动:

    #crontab -e

    @reboot  /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 
    
  • 相关阅读:
    [转载]ASP.NET Core 之 Identity 入门(一)
    ABP框架使用(版本3.3.1)
    [转载]ABP 结合 MongoDB 集成依赖注入
    [转载]初识ABP vNext(4):vue用户登录&菜单权限
    【转载】ASP.NET Core中如何显示[PII is hidden]的隐藏信息
    [转载]超简单本地mock假数据测试,模拟后台数据返回必杀技
    Git 分支简介、Git 和 GitHub 日常操作
    重载++运算符为成员函数(日期类函数设计也可以看一下 )
    重载操作符(cin cout 都在这篇文章里出现了 注意区别)
    重载操作符(日期类)
  • 原文地址:https://www.cnblogs.com/rusking/p/8259855.html
Copyright © 2011-2022 走看看