參考鏈接:https://blog.csdn.net/n_fly/article/details/52692480
1、window10環境下面安裝的redis,之前安裝好弄了一下,過了好幾天,再次使用redis-server.exe命令啟動,發現報了如下所示的錯誤:
1 D:\biehl\redis>redis-server.exe 2 [16916] 28 Nov 19:43:49.684 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server.exe /path/to/redis.conf 3 [16916] 28 Nov 19:43:49.689 # Creating Server TCP listening socket *:6379: bind: No such file or directory 4 5 D:\biehl\redis>redis-cli.exe 6 127.0.0.1:6379> shutdown 7 (error) NOAUTH Authentication required. 8 127.0.0.1:6379> AUTH 123456 9 OK 10 127.0.0.1:6379> shutdown 11 not connected> exit 12 13 D:\biehl\redis>redis-server.exe 14 [12420] 28 Nov 19:46:00.458 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server.exe /path/to/redis.conf 15 _._ 16 _.-``__ ''-._ 17 _.-`` `. `_. ''-._ Redis 3.2.100 (00000000/0) 64 bit 18 .-`` .-```. ```\/ _.,_ ''-._ 19 ( ' , .-` | `, ) Running in standalone mode 20 |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 21 | `-._ `._ / _.-' | PID: 12420 22 `-._ `-._ `-./ _.-' _.-' 23 |`-._`-._ `-.__.-' _.-'_.-'| 24 | `-._`-._ _.-'_.-' | http://redis.io 25 `-._ `-._`-.__.-'_.-' _.-' 26 |`-._`-._ `-.__.-' _.-'_.-'| 27 | `-._`-._ _.-'_.-' | 28 `-._ `-._`-.__.-'_.-' _.-' 29 `-._ `-.__.-' _.-' 30 `-._ _.-' 31 `-.__.-' 32 33 [12420] 28 Nov 19:46:00.467 # Server started, Redis version 3.2.100 34 [12420] 28 Nov 19:46:00.468 * DB loaded from disk: 0.000 seconds 35 [12420] 28 Nov 19:46:00.468 * The server is now ready to accept connections on port 6379
截圖如下所示:
所以呢,自己學習完,也可以將redis進行shutdown,這樣養成好的習慣。
redis-cli shutdown,這樣可以避免redis正在將內存中的數據同步到硬盤中,因為強行終止redis進行可能會導致數據丟失。
執行此命令后,redis會先斷開所有客戶端連接,然后根據配置執行持久化,最后完成退出。
Redis可以妥善處理Sigterm信號,所以使用kill redis進行的pid也可以正常結束redis,效果與發送shutdown命令一樣。
2、linux操作系統安裝的redis如何進行正常啟動服務器端,客戶端,關閉客戶端,關閉服務器端。操作如下所示:
1 [root@localhost bin]# ls 2 dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server 3 [root@localhost bin]# ps -aux | grep redis 4 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 5 root 2399 0.0 0.1 33936 1812 ? Ssl 19:26 0:00 ./redis-server 127.0.0.1:6379 6 root 2413 0.0 0.0 4356 752 pts/0 S+ 19:30 0:00 grep redis 7 [root@localhost bin]# kill -9 2399 8 [root@localhost bin]# ps -aux | grep redis 9 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 10 root 2415 0.0 0.0 4356 752 pts/0 S+ 19:30 0:00 grep redis 11 [root@localhost bin]# ls 12 dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server 13 [root@localhost bin]# ./redis-server redis.conf 14 [root@localhost bin]# ps -aux | grep redis 15 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 16 root 2418 0.0 0.1 33936 1732 ? Ssl 19:30 0:00 ./redis-server 127.0.0.1:6379 17 root 2422 0.0 0.0 4356 728 pts/0 S+ 19:30 0:00 grep redis 18 [root@localhost bin]# ls 19 dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server 20 [root@localhost bin]# ./redis-cli 21 127.0.0.1:6379> get name 22 (nil) 23 127.0.0.1:6379> set name biehl 24 OK 25 127.0.0.1:6379> get name 26 "biehl" 27 127.0.0.1:6379> exit 28 [root@localhost bin]# ps -aux | grep redis 29 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ 30 root 2418 0.0 0.1 33936 1808 ? Ssl 19:30 0:00 ./redis-server 127.0.0.1:6379 31 root 2426 0.0 0.0 4356 732 pts/0 S+ 19:31 0:00 grep redis 32 [root@localhost bin]#
操作如下所示: