首页 / REDIS / 3.启停redis服务
3.启停redis服务
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了3.启停redis服务,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3073字,纯文字阅读大概需要5分钟。
内容图文
![3.启停redis服务](/upload/InfoBanner/zyjiaocheng/532/95b6d9320589418485b20788e77b8d49.jpg)
1.编译redis.conf参数文件安装完成后,我们就得尝试启动redis服务了。在$REDIS_HOME,编译如下文件 /home/ldh/redis/redis-2.8.3/redis.conf 修改端口将PORT 6379改成你想要的被客户访问的端口,不改也可以,只要不冲突。 设置密码: redis.conf中requirepas
1.编译redis.conf参数文件安装完成后,我们就得尝试启动redis服务了。在$REDIS_HOME,编译如下文件 /home/ldh/redis/redis-2.8.3/redis.conf
修改端口将PORT 6379改成你想要的被客户访问的端口,不改也可以,只要不冲突。 设置密码: redis.conf中requirepass前的注释去掉,后面加上密码,如 requirepass pass1234 如果服务已经启动,修改密码后需要重启服务才能使新密码生效。
2.启动服务启动服务,假如不用Nohup的话,当前会话就不能再进行其他操作咯。 nohup redis-server /home/ldh/redis/redis-2.8.3/redis.conf & 我们来看看nohup.out中,这个服务启动会反馈什么信息 [ldh@hauser redis-2.8.3]$ vi nohup.out [22624] 25 Dec 11:00:06.456 # Fatal error, can't open config file '/home/otredis/redis/2.6.16/conf/redis.conf' [22726] 25 Dec 11:06:01.442 # Fatal error, can't open config file '/home/otredis/redis/2.6.16/conf/redis.conf' [22737] 25 Dec 11:06:25.925 # Unable to set the max number of files limit to 10032 (Operation not permitted), setting the max clients configuration to 992. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6389 | `-._ `._ / _.-' | PID: 22737 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [22737] 25 Dec 11:06:25.931 # Server started, Redis version 2.8.3 [22737] 25 Dec 11:06:25.931 # 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. [22737] 25 Dec 11:06:25.931 * The server is now ready to accept connections on port 6389
此时,redis服务已经启动了。
3.登陆redis 此时我们登陆到redis数据库当中 [ldh@hauser redis-2.8.3]$ redis-cli -h 127.0.0.1 -p 6389 -a pass1234 127.0.0.1:6389> set fwy abc OK 127.0.0.1:6389> get fwy "abc"
本机登陆的话,也可以省略-h,如果是用默认端口6379,那么-p也可以省略。如redis-cli -a pass1234登陆即可如果远程登陆,可以用telnet登陆,退出时敲进quit [fengweiyuan513@cnsz081003 ~]$ telnet 10.25.30.143 6389 Trying 10.25.30.143... Connected to 10.25.30.143 (10.25.30.143). Escape character is '^]'. auth pass1234 +OK get fwy $1 2 quit +OK Connection closed by foreign host. [fengweiyuan513@cnsz081003 ~]$
4.停止redis服务 [ldh@hauser ~]$ redis-cli -h 127.0.0.1 -p 6389 -a pass1234 127.0.0.1:6389> shutdown 127.0.0.1:6389> exit 再连接一次已经发现不存在了,也可以通过ps -ef | grep redis来观察 [ldh@hauser ~]$ redis-cli -p 6389 -a pass1234 Could not connect to Redis at 127.0.0.1:6389: Connection refused 远程通过telnet来shutdown也是可以的,感觉挺不安全的。
内容总结
以上是互联网集市为您收集整理的3.启停redis服务全部内容,希望文章能够帮你解决3.启停redis服务所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。