1
2 3 |
cd /usr/local/redis sudo make test |
1
|
sudo make install |
1
|
redis-server |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 修改為守護模式 daemonize yes # 設置進程鎖文件 pidfile /usr/local/redis/redis.pid # 端口 port 6379 # 客戶端超時時間 timeout 300 # 日志級別 loglevel debug # 日志文件位置 logfile /usr/local/redis/log-redis.log # 設置數(shù)據(jù)庫的數(shù)量,默認數(shù)據(jù)庫為16,可以使用SELECT 命令在連接上指定數(shù)據(jù)庫id databases 16 ## 指定在多長時間內(nèi),有多少次更新操作,就將數(shù)據(jù)同步到數(shù)據(jù)文件,可以多個條件配合 #save #Redis 默認配置文件中提供了三個條件: save 900 1 save 300 10 save 60 10000 # 指定存儲至本地數(shù)據(jù)庫時是否壓縮數(shù)據(jù),默認為yes,Redis采用LZF壓縮,如果為了節(jié)省CPU時間, # 可以關閉該#選項,但會導致數(shù)據(jù)庫文件變的巨大 rdbcompression yes # 指定本地數(shù)據(jù)庫文件名 dbfilename dump.rdb # 指定本地數(shù)據(jù)庫路徑 dir /usr/local/redis/db/ # 指定是否在每次更新操作后進行日志記錄,Redis在默認情況下是異步的把數(shù)據(jù)寫入磁盤,如果不開啟,可能 專業(yè):服務器數(shù)據(jù)恢復服務 服務器運維服務 計算機網(wǎng)絡設備 網(wǎng)絡覆蓋 # 會在斷電時導致一段時間內(nèi)的數(shù)據(jù)丟失。因為 redis本身同步數(shù)據(jù)文件是按上面save條件來同步的,所以有 # 的數(shù)據(jù)會在一段時間內(nèi)只存在于內(nèi)存中 appendonly no # 指定更新日志條件,共有3個可選值: #no :表示等操作系統(tǒng)進行數(shù)據(jù)緩存同步到磁盤(快) #always :表示每次更新操作后手動調(diào)用fsync()將數(shù)據(jù)寫到磁盤(慢,安全) #everysec :表示每秒同步一次(折衷,默認值) appendfsync everysec |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
_._ _.-``__ '' -._ _.-`` `. `_. '' -._ Redis 3.2.5 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ '' -._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._| '` _.-' | Port: 6379 | `-._ `._ / _.-' | PID: 14447 `-._ `-._ `-./ _.- ' _.-' |`-._`-._ `-.__.- ' _.-' _.-'| | `-._`-._ _.- '_.-' | http://redis.io `-._ `-._`-.__.- '_.-' _.-' |`-._`-._ `-.__.- ' _.-' _.-'| | `-._`-._ _.- '_.-' | `-._ `-._`-.__.- '_.-' _.-' `-._ `-.__.- ' _.-' `-._ _.-' `-.__.-' 14447:M 24 Apr 17:57:33.215 # Server started, Redis version 3.2.5 14447:M 24 Apr 17:57:33.215 * The server is now ready to accept connections on port 6379 14447:M 24 Apr 17:57:33.215 - 0 clients connected (0 slaves), 956832 bytes in use 14447:M 24 Apr 17:57:38.257 - 0 clients connected (0 slaves), 956832 bytes in use |
1
2 3 |
ps axu| grep redis ## 查找redis-server的PID kill -9 PID |
1
2 3 4 5 6 7 8 9 10 11 |
## 啟動redis-server,后臺線程 AT8775:redis shoren$ redis-server /usr/local/redis/etc/redis.conf ## 啟動成功 AT8775:redis shoren$ ps axu| grep redis shoren 14948 0.0 0.0 2434840 760 s000 S+ 10:18 上午 0:00.00 grep redis shoren 14946 0.0 0.0 2452968 1492 ?? Ss 10:18 上午 0:00.01 redis-server *:6379 ## 關閉服務器 AT8775:redis shoren$ redis-cli shutdown ## 關閉成功 AT8775:redis shoren$ ps axu| grep redis shoren 14952 0.0 0.0 2435864 772 s000 S+ 10:19 上午 0:00.01 grep redis 專業(yè):IT外包、企業(yè)外包、網(wǎng)站外包、中小企業(yè)云服務平臺等北京IT外包服務 |
1
2 3 4 5 6 7 8 9 |
AT8775:redis shoren$ redis-cli -h 127.0.0.1 -p 6379 ## 簡單使用set、get命令 127.0.0.1:6379> set key value12 OK 127.0.0.1:6379> get key "value12" ## 退出 127.0.0.1:6379> quit
|
相關文章