导读跟大家讲解下有关如何在centos系统下安装redis数据库,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说如何在centos系统
跟大家讲解下有关如何在centos系统下安装redis数据库,相信小伙伴们对这个话题应该也很关注吧,现在就为小伙伴们说说如何在centos系统下安装redis数据库,小编也收集到了有关如何在centos系统下安装redis数据库的相关资料,希望大家看到了会喜欢。
具体安装步骤如下:
一、安装redis
第一步:下载redis安装包
[[emailprotected] local]# wget http://download.redis.io/releas/redis-4.0.6.tar.gz--2017-12-13 12:35:12-- http://download.redis.io/releas/redis-4.0.6.tar.gzResolving download.redis.io (download.redis.io)... 109.74.203.151Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.HTTP request nt, awaiting respon... 200 OKLength: 1723533 (1.6M) [application/x-gzip]Saving to: ‘redis-4.0.6.tar.gz’100%[==========================================================================================================>] 1,723,53动态搞笑图片笑死人3 60卧轨自杀8KB/s in 2.8s 2017-12-13 12:35:15 (608 KB/s) - ‘redis-4.0.6.tar.gz’ saved [1723533/1723533]
第二步:解压压缩包
tar -zxvf redis-4.0.6.tar.gz[[emailprotected] local]# tar -zxvf redis-4.0.6.tar.gz
第三步:yum安装gcc依赖
yum install gcc[[emailprotected] local]# yum install gcc
遇到选择,输入y即可
第四步:跳转到redis解压目录下
cd redis-4.0.6[[emailprotected] local]# cd redis-4.0.6
第五步:编译安装
make MALLOC=libc [[emailprotected] redis-4.0.6]# make MALLOC=libc
将/usr/local/redis-4.0.6/src目录下的文件加到/usr/local/bin目录
cd src && make install
[[emailprotected] redis-4.0.6]# cd src && make install CC Makefile.depHint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install
二、启动redis的三种方式
先切换到redis src目录下
[[emailprotected] redis-4.0.6]# cd src
1、直接启动redis
./redis-rver
[[emailprotected] src]# ./redis-rver18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18685, just started18685:C 13 Dec 12:56:12.507 # Warning: no config file specified, using the default config. In order to specify a config file u ./redis-rver /path/to/redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 4.0.6 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 18685 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog tting of 511 cannot be enforced becau /proc/sys/net/core/somaxconn is t to the lower value of 128.18685:M 13 Dec 12:56:12.508 # Server initialized18685:M 13 Dec 12:56:12.508 # WARNING overcommit_memory is t to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.18685:M 13 Dec 12:56:12.508 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the tting after a reboot. Redis must be restarted after THP is disabled.18685:M 13 Dec 12:56:12.508 * Ready to accept connections
如上图:redis启谦虚动成功但是这种启动方式需要一直打开窗口不能进行其他操作不太方便。
按 ctrl + c可以关闭窗口。
2、以后台进程方式启动redis
第一步:修改redis.conf文件
将
daemonize no
修改为
daemonize yes
第二步:指定redis.conf文件启动
./redis-rver /usr/local/redis-4.0.6/redis.conf [[emailprotected] src]# ./redis-rver /usr/local/redis-4.0.6/redis.conf 18713:C 13 Dec 13:07:41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18713:C 13 Dec 13:07:41.109 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18713, just started18713:C 13 Dec 13:07:41.109 # Configuration loaded
第三步:关闭redis进程
首先使用ps -aux | grep redis查看redis进程
[[emailprotected] src]# ps -aux | grep redisroot 18714 0.0 0.1 141752 2008 ? Ssl 13:07 0:00 ./redis-rver 127.0.0.1:6379root 18719 0.0 0.0 112644 968 pts/0 R+ 13:09 0:00 grep --color=auto redis
使用kill命令杀死进程
[[emailprotected] src]# kill 18714
3、设置redis开机自启动
1、在/etc目录下新建redis目录
mkdir redis[[emailprotected] etc]# mkdir redis
2、将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis目录下并命名为6379.conf
[[emailprotected] redis]# cp /usr/local/redis-4.0.6/redis.conf /etc/redis情侣称呼/6379.conf
3、将redis的启动脚本复制一份放到/etc/init.d目录下
[[emailprotected] init.d]# cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd
4、设置redis开机自启动
先切换到/etc/init.d目录下
然后执行自启命令
[[emailprotected] init.d]# chkconfig redisd onrvice redisd does not support chkconfig
看结果是redisd不支持chkconfig
解决方法:
使用vim编辑redisd文件在第一行加入如下两行注释保存退出
# chkconfig: 2345 90 10# description: Redis is a persistent key-value databa
注释的意思是redis服务必须在运行级2345下被启动或关闭启动的优先级是90关闭的优先级是10
再次执行开机自启命令成功
[[emailprotected] init.d]# chkconfig redisd on
现在可以直接已服务的形式启动和关闭redis了
启动:
rvice redisd start [[emailprotected] ~]# rvice redisd startStarting Redis rver...2288:C 13 Dec 13:51:38.087 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo2288:C 13 Dec 13:51:38.087 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2288, just started2288:C 13 Dec 13:51:38.087 # Configuration loaded
关闭:
方法1:rvice redisd stop
[[emailprotected] ~]# rvice redisd stopStopping ...Redis stopped
方法2:redis-cli SHUTDOWN
三、参考资料
1、http://blog.csdn.net/zc474235918/article/details/50974483
2、http://blog.csdn.net/gxw19874/article/details/51992125
如果出现如下问题:
[[ema天际歌词ilprotected] ~]# rvice redisd start/var/run/redis_6379.pid exists, process is already running or crashed
可参考资料:http://blog.csdn.net/luozhonghua2014/article/details/54649295
相关推荐:redis数据库教程
以上就是如何在centos系统下安装redis数据库的详细内容!
来源:php中文网
本文发布于:2023-02-25 04:08:18,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/167726931035996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:互联网常识:如何在centos系统下安装redis数据库.doc
本文 PDF 下载地址:互联网常识:如何在centos系统下安装redis数据库.pdf
留言与评论(共有 0 条评论) |