1.首先上傳安裝包,這裡我以 redis-5.0.8.tar.gz 為例子。 Linux下載redis地址:wget http://download.redis.io/releases/redis-5.0.8.tar.gz 先在opt目錄下建立一個軟體包上傳文件夾 mkdir /opt/softwa ...
1.首先上傳安裝包,這裡我以 redis-5.0.8.tar.gz 為例子。
Linux下載redis地址:wget http://download.redis.io/releases/redis-5.0.8.tar.gz
先在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.0 protected-mode no port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile /var/log/redis/redis_master.log 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 /opt/redis_data 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 maxmemory 10000000kb lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no appendonly yes 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
可以把我的配置配置文件進行複製到你的配置文件中。
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