redis4.0 安裝


本地環境:Centos 7.6

 

https://redis.io/download

在官網找了半天只有5.0  6.0的下載地址,沒有找到4.0的下載址,

http://www.redis.cn/download.html

在redis中文網上才找到下載地址。

 

wget http://download.redis.io/releases/redis-4.0.11.tar.gz

tar xvf redis-4.0.11.tar.gz -C /usr/local/

cd /usr/local/redis-4.0.11/

make

 

 

提示這些表示安裝完成:

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/usr/local/redis-4.0.11/src'

[root@iZ8vbdjpjvhsbz4w10d7rhZ redis-4.0.11]# src/redis-server    #啟動數據庫

 

新開一個窗口,連接寫入查詢數據庫

[root@iZ8vbdjpjvhsbz4w10d7rhZ redis-4.0.11]# /usr/local/redis-4.0.11/src/redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> get a
"1"
127.0.0.1:6379>

 

將  /usr/local/redis-4.0.11/src/ 目錄添加到PATH環境變量中

vi ~/.bash_profile 

PATH=$PATH:/usr/local/redis-4.0.11/src/

source  ~/.bash_profile 

 

看下redis-server 命令行參數

[root@iZ8vbdjpjvhsbz4w10d7rhZ redis-4.0.11]# src/redis-server --help
Usage: ./redis-server [/path/to/redis.conf] [options]
       ./redis-server - (read config from stdin)
       ./redis-server -v or --version
       ./redis-server -h or --help
       ./redis-server --test-memory <megabytes>

Examples:
       ./redis-server (run the server with default conf)  #不加參數會加載默認的conf配置文件
       ./redis-server /etc/redis/6379.conf          #指定某個conf配置文件
       ./redis-server --port 7777                #指定端口號,這個參數在conf配置文件中也有
       ./redis-server --port 7777 --slaveof 127.0.0.1 8888  #指定端口號和主庫的IP地址、端口號
       ./redis-server /etc/myredis.conf --loglevel verbose   #指定配置文件,同時指定loglevel參數值為 verbose
Sentinel mode: ./redis-server /etc/sentinel.conf --sentinel   #以哨兵的模式啟動,后續會寫

可以看到,參數可以顯式的在運行redis-server時指定,如果顯式指定的參數與配置文件中的參數值不同,則以顯式指定的參數值為准。

 

編輯配置文件,修改如下幾個參數

 

vi /usr/local/redis-4.0.11/redis.conf



bind 0.0.0.0    #允許所有IP連接redis數據庫

appendonly yes    #開啟aof日志

dir /usr/local/redis-4.0.11  #指定rdb生成的文件目錄,這個參數默認值是./ 意味着rdb文件會生成在redis-server運行時的目錄下。

保存退出,再次啟動,可以看到啟動執行

[root@iZ8vbdjpjvhsbz4w10d7rhZ redis-4.0.11]# redis-server /usr/local/redis-4.0.11/redis.conf
16989:C 16 May 17:11:35.859 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
16989:C 16 May 17:11:35.859 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=16989, just started
16989:C 16 May 17:11:35.859 # Configuration loaded
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 16989
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'

16989:M 16 May 17:11:35.860 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
16989:M 16 May 17:11:35.860 # Server initialized
16989:M 16 May 17:11:35.860 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
16989:M 16 May 17:11:35.860 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
16989:M 16 May 17:11:35.860 * Ready to accept connections


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM