redis数据库的安装及注意事项
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis数据库的安装及注意事项相关的知识,希望对你有一定的参考价值。
? 安装源码包
[[email protected] ~]# tar -xf redis/redis-4.0.8.tar.gz -C .
[[email protected] ~]# cd redis-4.0.8/
[[email protected] redis-4.0.8]# yum -y install gcc gcc-c++
[[email protected] redis-4.0.8]# make && make install
[[email protected] redis-4.0.8]# ./utils/install_server.sh
[[email protected] redis-4.0.8]# vim /etc/redis/6379.conf
70 bind 192.168.4.40 #修改ip
93 port 6040 #修改端口
[[email protected] redis-4.0.8]# ln -s /etc/init.d/redis_6379 /sbin/
[[email protected] redis-4.0.8]# redis_6379 stop
[[email protected] redis-4.0.8]# redis_6379 start
[[email protected] ~]# ss -antulp | grep redis
tcp LISTEN 0 128 192.168.4.40:6040 : users:(("redis-server",pid=4846,fd=6))
此时用脚本关闭redis会报如下错误
[[email protected] ~]# redis_6379 -stop
Please use start, stop, restart or status as first argument
解决方法1:[[email protected] ~]# redis-cli -h 192.168.4.40 -p 6040 shutdown
解决方法2:需要更改脚本文件
[[email protected] ~]# vim /etc/init.d/redis_6379
8 REDISPORT="6040"
43 $CLIEXEC -h 192.168.4.40 -p $REDISPORT shutdown
设置完毕后就可以使用脚步关了
如:
[[email protected] ~]# ss -antulp | grep redis
tcp LISTEN 0 128 192.168.4.40:6040 : users:(("redis-server",pid=4846,fd=6))
关闭redis
[[email protected] ~]# redis_6379 stop
Stopping ...
Redis stopped
设置连接密码
1.修改配置文件
[[email protected] ~]# vim /etc/redis/6379.conf
501 requirepass 123446(密码)
设置秘密后我们用脚本关闭文件会出现如下报错
[[email protected] ~]# 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:
[[email protected] ~]# 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
[[email protected] ~]# redis_6379 stop
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped
以上是关于redis数据库的安装及注意事项的主要内容,如果未能解决你的问题,请参考以下文章