咱们经过和数据库的交互获取数据,可是某些数据加载会严重影响性能,由于查询数据库是一个比较耗时的事情。咱们能不能提升查询数据的效率?javascript
这个时候咱们就须要使用 redis了。(固然提高查询效率不仅有redis)java
若是图片连接失效能够直接在github上看,并且更新更及时,也更加有条理。在项目模块有相关文章github.com/leosanqing/…c++
目前已经有将近300个stargit
到官网下载redis redis.io/downloadgithub
而后经过filezilla上传至相应的虚拟机 我上传至/opt
文件夹下redis
tar -zxvf <压缩包名>
make && make install
yum install gcc-c++
安装一下就行进入redis目录下,打开 redis.conf
文件 vim redis.conf
数据库
找到以下参数,并修改vim
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
#工做目录,持久化 aof rdb都会存放在这个目录下,若是修改了 须要建立相应的目录
dir /opt/redis5/working
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 将127.0.0.1 改为 0.0.0.0 全部ip都能访问
bind 0.0.0.0
# 保护模式关闭
protected-mode no
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 是否后台运行,设置成yes
daemonize yes
# 还有其余一下参数,好比 密码什么的,由于是在虚拟机上运行,因此不须要设置
复制代码
redis_init_script
文件复制到 /etc/init.d/
下 。 cp redis_init_script /etc/init.d/
cd /etc/init.d
,修改相应文件 vim redis_init_script
将其配置文件路径改为 咱们的配置文件存放的路径CONF="/opt/redis5/redis.conf"
chmod 777 redis_init_script
。./redis_init_script start
查看进程号 ps -ef|grep redis
ide
vim /etc/init.d/redis_init_script
添加以下内容性能
#chkconfig: 22345 10 90
#description: Start and Stop redis
复制代码
重启虚拟机 reboot
。再查看进程号是否存在啊