Ubuntu18.04锛屽畨瑁匯edis鍜岀畝鍗曚娇鐢≧edis

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu18.04锛屽畨瑁匯edis鍜岀畝鍗曚娇鐢≧edis相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e5%ae%a2%e6%88%b7%e7%ab%af' title='瀹㈡埛绔?>瀹㈡埛绔?/a>   鍚姩   listen   鐩戝惉   rtu   ips   鍛戒护   integer   

鍓嶈█

Redis鏄父鐢ㄥ熀浜庡唴瀛樼殑Key-Value鏁版嵁搴擄紝姣擬emcache鏇村厛杩涳紝鏀寔澶氱鏁版嵁缁撴瀯锛岄珮鏁堬紝蹇€熴€傜敤Redis鍙互寰堣交鏉捐В鍐抽珮骞跺彂鐨勬暟鎹闂棶棰橈紱浣滀负瀹炴椂鐩戞帶淇″彿澶勭悊涔熼潪甯镐笉閿欍€?/p>

鐜

Ubuntu 18.04

瀹夎Redis鏈嶅姟鍣ㄧ

~ sudo apt-get install redis-server

瀹夎瀹屾垚鍚庯紝Redis鏈嶅姟鍣ㄤ細鑷姩鍚姩锛屾垜浠鏌edis鏈嶅姟鍣ㄧ▼搴?/p>

~ ps -agx|grep redis

1 10382 10382 10382 ? -1 Ssl 124 0:07 /usr/bin/redis-server 127.0.0.1:6379
2677 10618 10617 2677 pts/0 10617 S+ 1000 0:00 grep --color=auto redis

~ netstat -nlt|grep 6379

tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
tcp6 0 0 ::1:6379 :::* LISTEN

閫氳繃鍚姩鍛戒护妫€鏌edis鏈嶅姟鍣ㄧ姸鎬?/h2>
~$ sudo /etc/init.d/redis-server status

鈼?redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-08-10 19:50:13 CST; 36min ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 10382 (redis-server)
Tasks: 4 (limit: 2294)
CGroup: /system.slice/redis-server.service
鈹斺攢10382 /usr/bin/redis-server 127.0.0.1:6379

8鏈?10 19:50:12 zhangkun-virtual-machine systemd[1]: Starting Advanced key-v鈥?.
8鏈?10 19:50:13 zhangkun-virtual-machine systemd[1]: redis-server.service: C鈥y
8鏈?10 19:50:13 zhangkun-virtual-machine systemd[1]: Started Advanced key-va鈥.
Hint: Some lines were ellipsized, use -l to show in full.

閫氳繃鍛戒护琛屽鎴风璁块棶Redis

瀹夎Redis鏈嶅姟鍣紝浼氳嚜鍔ㄥ湴涓€璧峰畨瑁匯edis鍛戒护琛屽鎴风绋嬪簭銆?/p>

鍦ㄦ湰鏈鸿緭鍏edis-cli鍛戒护灏卞彲浠ュ惎鍔紝瀹㈡埛绔▼搴忚闂甊edis鏈嶅姟鍣ㄣ€?/p>

~ redis-cli

127.0.0.1:6379> help
redis-cli 4.0.9
To get help about Redis commands type:
"help @<group>" to get a list of commands in <group>
"help <command>" for help on <command>
"help <tab>" to get a list of possible help topics
"quit" to exit

To set redis-cli preferences:
":set hints" enable online hints
":set nohints" disable online hints
Set your preferences in ~/.redisclirc


127.0.0.1:6379> set key1 "hello"
OK
127.0.0.1:6379> get key1
"hello"

redis 127.0.0.1:6379> set key1 "hello"
OK

# 鎵撳嵃璁板綍
redis 127.0.0.1:6379> get key1
"hello"

澧炲姞涓€鏉℃暟瀛楄褰?/strong>

 
set key2 1
OK

# 璁╂暟瀛楄嚜澧?redis 127.0.0.1:6379> INCR key2
(integer) 2
redis 127.0.0.1:6379> INCR key2
(integer) 3

# 鎵撳嵃璁板綍
redis 127.0.0.1:6379> get key2
"3"
 

澧炲姞涓€涓垪琛ㄨ褰昸ey3

 
redis 127.0.0.1:6379> LPUSH key3 a
(integer) 1

# 浠庡乏杈规彃鍏ュ垪琛?redis 127.0.0.1:6379> LPUSH key3 b
(integer) 2

# 浠庡彸杈规彃鍏ュ垪琛?redis 127.0.0.1:6379> RPUSH key3 c
(integer) 3

# 鎵撳嵃鍒楄〃璁板綍锛屾寜浠庡乏鍒板彸鐨勯『搴?redis 127.0.0.1:6379> LRANGE key3 0 3
1) "b"
2) "a"
3) "c"
鎶€鏈垎浜浘鐗? src=

澧炲姞涓€涓搱甯岃琛ㄥ綍key4

鎶€鏈垎浜浘鐗? src=
redis 127.0.0.1:6379> HSET key4 name "John Smith"
(integer) 1

# 鍦ㄥ搱甯岃〃涓彃鍏ワ紝email鐨凨ey鍜孷alue鐨勫€?redis 127.0.0.1:6379> HSET key4 email "[email protected]"
(integer) 1

# 鎵撳嵃鍝堝笇琛ㄤ腑锛宯ame涓簁ey鐨勫€?redis 127.0.0.1:6379> HGET key4 name
"John Smith"

# 鎵撳嵃鏁翠釜鍝堝笇琛?redis 127.0.0.1:6379> HGETALL key4
1) "name"
2) "John Smith"
3) "email"
4) "[email protected]"
鎶€鏈垎浜浘鐗? src=

澧炲姞涓€鏉″搱甯岃〃璁板綍key5

鎶€鏈垎浜浘鐗? src=
# 澧炲姞涓€鏉″搱甯岃〃璁板綍key5锛屼竴娆℃彃鍏ュ涓狵ey鍜寁alue鐨勫€?redis 127.0.0.1:6379> HMSET key5 username antirez password P1pp0 age 3
OK

# 鎵撳嵃鍝堝笇琛ㄤ腑锛寀sername鍜宎ge涓簁ey鐨勫€?redis 127.0.0.1:6379> HMGET key5 username age
1) "antirez"
2) "3"

# 鎵撳嵃瀹屾暣鐨勫搱甯岃〃璁板綍
redis 127.0.0.1:6379> HGETALL key5
1) "username"
2) "antirez"
3) "password"
4) "P1pp0"
5) "age"
6) "3"
鎶€鏈垎浜浘鐗? src=

鍒犻櫎璁板綍

鎶€鏈垎浜浘鐗? src=
# 鏌ョ湅鎵€鏈夌殑key鍒楄〃
redis 127.0.0.1:6379> keys *
1) "key2"
2) "key3"
3) "key4"
4) "key5"
5) "key1"

# 鍒犻櫎key1,key5
redis 127.0.0.1:6379> del key1
(integer) 1
redis 127.0.0.1:6379> del key5
(integer) 1

# 鏌ョ湅鎵€鏈夌殑key鍒楄〃
redis 127.0.0.1:6379> keys *
1) "key2"
2) "key3"
3) "key4"
鎶€鏈垎浜浘鐗? src=

浣跨敤Redis鐨勮闂处鍙?/h2>

榛樿鎯呭喌涓嬶紝璁块棶Redis鏈嶅姟鍣ㄦ槸涓嶉渶瑕佸瘑鐮佺殑锛屼负浜嗗鍔犲畨鍏ㄦ€ф垜浠渶瑕佽缃甊edis鏈嶅姟鍣ㄧ殑璁块棶瀵嗙爜銆傝缃闂瘑鐮佷负redisredis銆?/p>

鐢╲i鎵撳紑Redis鏈嶅姟鍣ㄧ殑閰嶇疆鏂囦欢redis.conf

~ sudo vi /etc/redis/redis.conf

#鍙栨秷娉ㄩ噴requirepass
requirepass redisredis

璁㏑edis鏈嶅姟鍣ㄨ杩滅▼璁块棶

榛樿鎯呭喌涓嬶紝Redis鏈嶅姟鍣ㄤ笉鍏佽杩滅▼璁块棶锛屽彧鍏佽鏈満璁块棶锛屾墍浠ユ垜浠渶瑕佽缃墦寮€杩滅▼璁块棶鐨勫姛鑳姐€?/p>

鐢╲i鎵撳紑Redis鏈嶅姟鍣ㄧ殑閰嶇疆鏂囦欢redis.conf

~ sudo vi /etc/redis/redis.conf

#娉ㄩ噴bind
#bind 127.0.0.1

淇敼鍚庯紝閲嶅惎Redis鏈嶅姟鍣ㄣ€?/p>

~ sudo /etc/init.d/redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.

鏈娇鐢ㄥ瘑鐮佺櫥闄哛edis鏈嶅姟鍣?/p>

~ redis-cli

redis 127.0.0.1:6379> keys *
(error) ERR operation not permitted

鍙戠幇鍙互鐧婚檰锛屼絾鏃犳硶鎵ц鍛戒护浜嗐€?/p>

鐧婚檰Redis鏈嶅姟鍣紝杈撳叆瀵嗙爜

~  redis-cli -a redisredis

redis 127.0.0.1:6379> keys *
1) "key2"
2) "key3"
3) "key4"

鐧婚檰鍚庯紝涓€鍒囨甯搞€?/p>

鎴戜滑妫€鏌edis鐨勭綉缁滅洃鍚鍙?/p>

妫€鏌edis鏈嶅姟鍣ㄥ崰鐢ㄧ鍙?/p>

~ netstat -nlt|grep 6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN

鎴戜滑鐪嬪埌缃戠粶鐩戝惉浠庝箣鍓嶇殑 127.0.0.1:3306 鍙樻垚 0 0.0.0.0:3306锛岃〃绀篟edis宸茬粡鍏佽杩滅▼鐧婚檰璁块棶銆?/p>

鎴戜滑鍦ㄨ繙绋嬬殑鍙︿竴鍙癓inux璁块棶Redis鏈嶅姟鍣?/p>

~ redis-cli -a redisredis -h 192.168.1.199

redis 192.168.1.199:6379> keys *
1) "key2"
2) "key3"
3) "key4"

杩滅▼璁块棶姝e父銆傞€氳繃涓婇潰鐨勬搷浣滐紝鎴戜滑灏辨妸Redis鏁版嵁搴撴湇鍔″櫒锛屽湪Linux Ubuntu涓殑绯荤粺瀹夎瀹屾垚銆?/p>


























以上是关于Ubuntu18.04锛屽畨瑁匯edis鍜岀畝鍗曚娇鐢≧edis的主要内容,如果未能解决你的问题,请参考以下文章

kail涓嬪畨瑁匯saCtfTool

鎵嶇枏瀛︽祬锛屽啓鐐规枃绔狅綖java鍗曚緥妯″紡

娣卞害瑙f瀽jQuery涓嶢jax鐨勫師鐞嗭紝灏忕櫧閮藉彲浠ョ湅寰楁噦锛岀畝鍗曟槗鎳傦紒锛?/h1>

linux涓嬪畨瑁卹edis

Linux涓婻edis鐨勫畨瑁呭拰閮ㄧ讲

CentOS涓嬬绾垮畨瑁単cc鐜锛屽浘鏂囪缁嗭紝鏂规硶鍏ㄩ潰