ubuntu安装redis

Redis在线安装

  1. 输入命令 sudo apt-get install redis-server 安装完成后,Redis服务器会自动启动。

  2. 使用命令 ps -aux|grep redis 可以看到服务器系统进程默认端口6379

  3. 使用命令 netstat -nlt|grep 6379 可以看到redis服务器状态

  4. 使用命令 sudo /etc/init.d/redis-server status 可以看到Redis服务器状态

Redis基本配置

  • 打开redis配置文件 sudo vi /etc/redis/redis.conf

  • 添加Redis的访问账号
    Redis服务器默认是不需要密码的,假设设置密码为123。去掉requirepass 前面的注释#,在后面添加密码
    requirepass 123

  • 开启Redis的远程连接 注释掉绑定地址#bind 127.0.0.1

  • 修改Redis的默认端口 port 6379

  • Redis以守护进程运行
    如果以守护进程运行,则不会在命令行阻塞,类似于服务
    如果以非守护进程运行,则当前终端被阻塞,无法使用
    推荐改为yes,以守护进程运行
    daemonize no|yes
    Redis的数据文件
    dbfilename dump.rdb

  • 数据文件存储路径
    dir /var/lib/redis

  • 配置完成后重新启动服务器
    sudo /etc/init.d/redis-server restart

    sudo service redis-server restart

    sudo redis-server /etc/redis/redis.conf

posted @ 2020-04-08 09:58  蹲坑思考人生  阅读(602)  评论(0)    收藏  举报