2020-06-16

Redis在CentOS for LInux上安装详细教程

1.首先上传安装包,这里我以 redis-5.0.8.tar.gz 为例子。

      Linux下载redis地址:wget   先在opt目录下建立一个软件包上传文件夹  mkdir  /opt/software

    把 redis-5.0.8.tar.gz 上传到 /opt/software/

2.下载Redis安装依赖编译环境

    yum -y install gcc gcc-c++ 安装gcc编译环境,用来执行make命令

3.在/opt/software/下使用命令

    tar -xzvf redis-5.0.8.tar.gz 

4.把解压的redis源码文件移动到/usr/local/src/目录下

    mv /opt/software/redis-5.0.8  /usr/local/src/

5.进入到 /usr/local/src/redis-5.0.8 目录下输入make命令进行源码的编译

   make

6.之后进入/usr/local/src/redis-5.0.8/src/下,输入如下命令,目的是给redis安装指定目录

   make install PREFIX=/usr/local/redis

7.建立一个文件夹用来处方自定义的redis.conf 文件

    mkdir /etc/redis/

8.把 /usr/local/src/redis-5.0.8/redis.conf 复制到 /etc/redis/

    cp  /usr/local/src/redis-5.0.8/redis.conf   /etc/redis/

9.修改 /etc/redis/redis.conf 配置文件

   vim  /etc/redis/redis.conf 

10.核心redis.conf 配置修改代码如下:

bind 0.0.0.0protected-mode noport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile /var/run/redis_6379.pidloglevel noticelogfile /var/log/redis/redis_master.logdatabases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir /opt/redis_datareplica-serve-stale-data yesreplica-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noreplica-priority 100maxmemory 10000000kblazyfree-lazy-eviction nolazyfree-lazy-expire nolazyfree-lazy-server-del noreplica-lazy-flush noappendonly yesappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit replica 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10 dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-save-incremental-fsync yes

可以把我的配置配置文件进行复制到你的配置文件中。

11.配置文件中有的路径需要建立相应目录

    1.mkdir  /var/log/redis/

    2.mkdir  /opt/redis_data

12.开始运行redis

      /usr/local/redis/bin/redis-server  /etc/redis/redis.conf 

13.检测后台进程是否存在

    ps -ef |grep redis

14.使用客户端可以进行测试了

     /usr/local/redis/bin/redis-cli   回车

15.关闭redis

      redis-cli shutdown

16.强制关闭redis

      kill -9  PID(你的进程ID,通过这个命令进行查询ps -ef |grep redis )

     或者 pkill redis

 


Redis在CentOS for LInux上安装详细教程

No comments:

Post a Comment