温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

redis数据库的安装及注意事项

发布时间:2020-07-26 14:04:30 来源:网络 阅读:490 作者:落雪无蘅 栏目:关系型数据库

• 安装源码包
[root@40 ~]# tar -xf redis/redis-4.0.8.tar.gz -C .
[root@40 ~]# cd redis-4.0.8/
[root@40 redis-4.0.8]# yum -y install gcc gcc-c++
[root@40 redis-4.0.8]# make && make install
[root@40 redis-4.0.8]# ./utils/install_server.sh
[root@40 redis-4.0.8]# vim /etc/redis/6379.conf
70 bind 192.168.4.40 #修改ip
93 port 6040 #修改端口
[root@40 redis-4.0.8]# ln -s /etc/init.d/redis_6379 /sbin/
[root@40 redis-4.0.8]# redis_6379 stop
[root@40 redis-4.0.8]# redis_6379 start
[root@40 ~]# ss -antulp | grep redis
tcp LISTEN 0 128 192.168.4.40:6040 : users:(("redis-server",pid=4846,fd=6))
此时用脚本关闭redis会报如下错误
[root@40 ~]# redis_6379 -stop
Please use start, stop, restart or status as first argument
解决方法1:[root@40 ~]# redis-cli -h 192.168.4.40 -p 6040 shutdown
解决方法2:需要更改脚本文件
[root@40 ~]# vim /etc/init.d/redis_6379
8 REDISPORT="6040"
43 $CLIEXEC -h 192.168.4.40 -p $REDISPORT shutdown
设置完毕后就可以使用脚步关了
如:
[root@40 ~]# ss -antulp | grep redis
tcp LISTEN 0 128 192.168.4.40:6040 : users:(("redis-server",pid=4846,fd=6))
关闭redis
[root@40 ~]# redis_6379 stop
Stopping ...
Redis stopped

设置连接密码
1.修改配置文件
[root@40 ~]# vim /etc/redis/6379.conf
501 requirepass 123446(密码)
设置秘密后我们用脚本关闭文件会出现如下报错
[root@40 ~]# redis_6379 stop
Stopping ...
(error) NOAUTH Authentication required.
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
。。。。。。。。。。。
解决方法1:
[root@40 ~]# redis-cli -h 192.168.4.40 -p 6040 -a 123446 shutdown
解决方法2:修改脚本文件
43 $CLIEXEC -h 192.168.4.40 -p $REDISPORT -a 123446 shutdown
[root@40 ~]# redis_6379 stop
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI