乐趣区

关于redis:Redis的安装与配置

  1. 下载软件包

    wget http://download.redis.io/releases/redis-5.0.5.tar.gz
  2. 编译装置

    tar -xzvf redis-5.0.5.tar.gz
    yum install gcc -y
    'make MALLOC=libc' OR 'yum install -y jemalloc'    //--https://blog.csdn.net/qq_37859539/article/details/83715803
    cd redis-5.0.5
    make PREFIX=/data1/srv/redis install
    cp redis.conf  /data1/srv/redis/bin/
  3. 批改配置文件

     [root@bluse /]# cat /etc/redis.conf
     bind 192.168.1.242
     protected-mode yes
     port 6379
     tcp-backlog 511
     timeout 0
     tcp-keepalive 300
     daemonize yes
     supervised no
     pidfile /var/run/redis_6379.pid
     loglevel notice
     logfile ""
     databases 16
     always-show-logo yes
     save 900 1
     save 300 10
     save 60 10000
     stop-writes-on-bgsave-error yes
     rdbcompression yes
     rdbchecksum yes
     dbfilename dump.rdb
     dir /data1/srv/redis/bin
     replica-serve-stale-data yes
     replica-read-only yes
     repl-diskless-sync no
     repl-diskless-sync-delay 5
     repl-disable-tcp-nodelay no
     replica-priority 100
     lazyfree-lazy-eviction no
     lazyfree-lazy-expire no
     lazyfree-lazy-server-del no
     replica-lazy-flush no
     appendonly no
     appendfilename "appendonly.aof"
     appendfsync everysec
     no-appendfsync-on-rewrite no
     auto-aof-rewrite-percentage 100
     auto-aof-rewrite-min-size 64mb
     aof-load-truncated yes
     aof-use-rdb-preamble yes
     lua-time-limit 5000
     slowlog-log-slower-than 10000
     slowlog-max-len 128
     latency-monitor-threshold 0
     notify-keyspace-events ""
     hash-max-ziplist-entries 512
     hash-max-ziplist-value 64
     list-max-ziplist-size -2
     list-compress-depth 0
     set-max-intset-entries 512
     zset-max-ziplist-entries 128
     zset-max-ziplist-value 64
     hll-sparse-max-bytes 3000
     stream-node-max-bytes 4096
     stream-node-max-entries 100
     activerehashing yes
     client-output-buffer-limit normal 0 0 0
     client-output-buffer-limit replica 256mb 64mb 60
     client-output-buffer-limit pubsub 32mb 8mb 60
     hz 10
     dynamic-hz yes
     aof-rewrite-incremental-fsync yes
     rdb-save-incremental-fsync yes
     requirepass password
  4. 配置启动服务

    [root@bluse /]# cat /usr/lib/systemd/system/redis.service
    [Unit]
    Description=Redis
    After=network.target
    
    [Service]
    Type=forking
    PIDFile=/var/run/redis_6379.pid
    ExecStart=/data1/srv/redis/bin/redis-server /data1/srv/redis/bin/redis.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    • [Install]

      • WantedBy=multi-user.target
    • [Unit] 示意这是根底信息

      • Description 是形容
      • After 是在那个服务前面启动,个别是网络服务启动后启动
    • [Service] 示意这里是服务信息 ExecStart 是启动服务的命令

      • ExecStop 是进行服务的指令
    • [Install] 示意这是是装置相干信息 WantedBy 是以哪种形式启动:

      • multi-user.target 表明当零碎以多用户形式(默认的运行级别)启动时,这个服务须要被主动运行。
systemctl daemon-reload
systemctl enable redis && systemctl start redis
退出移动版