您當(dāng)前位置: 主頁(yè) > 資訊動(dòng)態(tài) > IT知識(shí)庫(kù) >
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 |
# 修改為守護(hù)模式 daemonize yes # 設(shè)置進(jìn)程鎖文件 pidfile /usr/local/redis/redis.pid # 端口 port 6379 # 客戶端超時(shí)時(shí)間 timeout 300 # 日志級(jí)別 loglevel debug # 日志文件位置 logfile /usr/local/redis/log-redis.log # 設(shè)置數(shù)據(jù)庫(kù)的數(shù)量,默認(rèn)數(shù)據(jù)庫(kù)為16,可以使用SELECT 命令在連接上指定數(shù)據(jù)庫(kù)id databases 16 ## 指定在多長(zhǎng)時(shí)間內(nèi),有多少次更新操作,就將數(shù)據(jù)同步到數(shù)據(jù)文件,可以多個(gè)條件配合 #save #Redis 默認(rèn)配置文件中提供了三個(gè)條件: save 900 1 save 300 10 save 60 10000 # 指定存儲(chǔ)至本地?cái)?shù)據(jù)庫(kù)時(shí)是否壓縮數(shù)據(jù),默認(rèn)為yes,Redis采用LZF壓縮,如果為了節(jié)省CPU時(shí)間, # 可以關(guān)閉該#選項(xiàng),但會(huì)導(dǎo)致數(shù)據(jù)庫(kù)文件變的巨大 rdbcompression yes # 指定本地?cái)?shù)據(jù)庫(kù)文件名 dbfilename dump.rdb # 指定本地?cái)?shù)據(jù)庫(kù)路徑 dir /usr/local/redis/db/ # 指定是否在每次更新操作后進(jìn)行日志記錄,Redis在默認(rèn)情況下是異步的把數(shù)據(jù)寫入磁盤,如果不開(kāi)啟,可能 專業(yè):服務(wù)器數(shù)據(jù)恢復(fù)服務(wù) 服務(wù)器運(yùn)維服務(wù) 計(jì)算機(jī)網(wǎng)絡(luò)設(shè)備 網(wǎng)絡(luò)覆蓋 # 會(huì)在斷電時(shí)導(dǎo)致一段時(shí)間內(nèi)的數(shù)據(jù)丟失。因?yàn)?redis本身同步數(shù)據(jù)文件是按上面save條件來(lái)同步的,所以有 # 的數(shù)據(jù)會(huì)在一段時(shí)間內(nèi)只存在于內(nèi)存中 appendonly no # 指定更新日志條件,共有3個(gè)可選值: #no :表示等操作系統(tǒng)進(jìn)行數(shù)據(jù)緩存同步到磁盤(快) #always :表示每次更新操作后手動(dòng)調(diào)用fsync()將數(shù)據(jù)寫到磁盤(慢,安全) #everysec :表示每秒同步一次(折衷,默認(rèn)值) 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 |
## 啟動(dòng)redis-server,后臺(tái)線程 AT8775:redis shoren$ redis-server /usr/local/redis/etc/redis.conf ## 啟動(dòng)成功 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 ## 關(guān)閉服務(wù)器 AT8775:redis shoren$ redis-cli shutdown ## 關(guān)閉成功 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è)云服務(wù)平臺(tái)等北京IT外包服務(wù) |
1
2 3 4 5 6 7 8 9 |
AT8775:redis shoren$ redis-cli -h 127.0.0.1 -p 6379 ## 簡(jiǎn)單使用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
|
相關(guān)文章