# Redis ### 环境 Ubuntu 18.04 ### 安装redis ```shell apt-get install redis-server ``` ### 修改密码 ```shell vi /etc/redis/redis.conf # requirepass 你的密码 ``` ### 限制外网访问 ```shell vi /etc/redis/redis.conf # bind 127.0.0.1 ::1 ``` ### 卸载 ```shell apt-get purge --auto-remove redis-server ``` ### 修改dump.rdb文件存储路径 ```properties # 修改 /etc/redis/redis.conf dir /data/bin/redis/data # 修改 /etc/systemd/system/redis.service,添加以下文本 ReadWriteDirectories=-/data/bin/redis/data ``` ###### 注:之前只修改了 `/etc/redis/redis.conf` 下的配置,而没有修改 `/etc/systemd/system/redis.service` ,所以一直报如下错误 ```properties 2397:M 17 Sep 17:06:13.910 # Failed opening the RDB file dump.rdb (in server root dir /data/bin/redis/data) for saving: Read-only file system ```