Redis是一个NoSQL数据库,在数据需要频繁更新,并且数据的访问热点范围比较广的应用场景下,Redis的效率很不错。
下面介绍Redis的安装过程,如下面的步骤所示。
1、下载安装
1
2
3
4
5
|
wget http: //redis .googlecode.com /files/redis-2 .2.13. tar .gz tar -zxf redis-2.2.13. tar .gz cd redis-2.2.13 make sudo make install |
这时Redis 的可执行文件被放到了/usr/local/bin。
2、下载配置文件和init启动脚本
1
2
3
4
5
|
wget https: //github .com /ijonas/dotfiles/raw/master/etc/init .d /redis-server wget https: //github .com /ijonas/dotfiles/raw/master/etc/redis .conf sudo mv redis-server /etc/init .d /redis-server sudo chmod +x /etc/init .d /redis-server sudo mv redis.conf /etc/redis .conf |
3、初始化用户和日志路径
第一次启动Redis前,建议为Redis单独建立一个用户,并新建data和日志文件夹。
1
2
3
4
5
|
sudo useradd redis sudo mkdir -p /var/lib/redis sudo mkdir -p /var/log/redis sudo chown redis.redis /var/lib/redis sudo chown redis.redis /var/log/redis |
4、设置开机自动启动,关机自动关闭
1
|
sudo update-rc.d redis-server defaults |
5、启动Redis
1
|
sudo /etc/init .d /redis-server start |
6、验证启动成功
1
2
3
|
ps -ef | grep redis redis 9544 1 0 21:06 ? 00:00:00 /usr/local/bin/redis-server /etc/redis .conf hadoop 9549 7429 0 21:06 pts /3 00:00:00 grep --color=auto redis |
7、启动client客户端
1
2
3
4
5
6
7
|
redis-cli redis 127.0.0.1:6379> help redis-cli 2.6.14 Type: "help @<group>" to get a list of commands in <group> "help < command >" for help on < command > "help <tab>" to get a list of possible help topics "quit" to exit |