物联网架构实例—Ubuntu 安装Redis

1.准备

更新apt-get源

sudo apt-get update

2.安装

执行Redis 安装命令

sudo apt-get install redis-server

3.检查安装状态

sudo /etc/init.d/redis-server status

查看Redis运行进程

ps -aux|grep redis

4.将Redis添加到服务器启动项

修改/etc/rc.local

vim /etc/rc.local

将下面的命令加到配置文件中,如上图

sudo /etc/init.d/redis-server restart >> /etc/init.d/redis.log 2>&1 &

5.修改Redis的配置

5.1.使用Redis的访问密码

默认情况下,访问Redis服务器是不需要密码的,为了增加安全性我们需要设置Redis服务器的访问密码。修改/etc/redis/redis.conf

vim /etc/redis/redis.conf

5.2.让Redis服务器被远程访问

默认情况下,Redis服务器不允许远程访问,只允许本机访问,所以我们需要设置打开远程访问的功能。同设置密码一样修改/etc/redis/redis.conf

vim /etc/redis/redis.conf

找到bind 127.0.0.1这行,前面加#,将此行注释掉

5.3.重启Redis服务器

最后我们重启一下Redis

sudo /etc/init.d/redis-server restart

这时我们再查看一下Redis的运行状态

sudo /etc/init.d/redis-server status

猜你喜欢

转载自blog.csdn.net/qq_17486399/article/details/128573492