Linux下启动redis

一、直接启动redis

使用这种启动方式需要一直打开窗口,不能进行其他操作,按 ctrl + c可以关闭窗口。

复制代码
[root@xxx ~]# cd /usr/local/redis-4.0.6/src
[root@xxx src]# ./redis-server

二、以后台进程形式启动redis

①设置redis.conf中daemonize为yes,确保守护进程开启,也就是在后台可以运行

复制代码
 [root@xxx ~]# vim /usr/local/redis-4.0.6/redis.conf

②指定redis.conf文件启动

复制代码
[root@xxx ~]# ./redis-server /usr/local/redis-4.0.6/redis.conf

③关闭redis进程

复制代码
[root@xxx ~]# ps -aux|grep redis
[root@xxx ~]# kill -9 1350

三、设置redis开机自启动

①将redis自带的脚本复制到指定目录(/etc/init.d/)的redis文件

复制代码
[root@xxx ~]# cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redis

②修改(/etc/init.d/)redis文件

复制代码
//在文件最前面加入这个注释
# chkconfig: 2345 10 90
# description: Start and Stop redis
//对下面地址、端口号等进行修改
REDISPORT=6379
EXEC=/usr/local/redis-4.0.6/src/redis-server
CLIEXEC=/usr/local/redis-4.0.6/src/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid//与redis.conf中保持一致
CONF="/usr/local/redis-4.0.6/redis.conf"

③授予权限

复制代码
[root@xxx ~]# chkconfig --add redis//添加redis服务
[root@xxx ~]# chkconfig redis on//设为开机启动
[root@xxx ~]# service redis start//开启redis服务
[root@xxx ~]# service redis stop//关闭redis服务

注:启动redis服务时,一般因没有正常关机,可造成如下问题:

复制代码
[root@xxx ~]# service redisd start
/var/run/redis_6379.pid exists, process is already running or crashed

解决办法:

1:可用安装文件启动:redis-server /etc/redis/6379.conf

2:shutdown -r now 软重启让系统自动恢复下就行了

相关推荐
杜子不疼.1 小时前
【Linux】进程概念(六):地址空间核心机制
linux·运维·服务器
APIshop1 小时前
1688 拍立淘接口 item_search_img 返回值超细说明
linux·运维·服务器
礼拜天没时间.1 小时前
《Grafana 企业级可视化监控实战指南:从安装、配置到智能告警》:Grafana 安装部署
linux·运维·信息可视化·zabbix·grafana·监控
丸码1 小时前
JDK1.8新特性全解析
linux·windows·python
特种加菲猫1 小时前
解码TCP:如何实现可靠的数据传输
linux·网络·网络协议·tcp/ip
2401_837088501 小时前
Redis List 的消息队列
数据库·redis·缓存
序属秋秋秋1 小时前
《Linux系统编程之进程环境》【地址空间】
linux·运维·服务器·c语言·c++·系统编程·进程地址空间
mljy.1 小时前
Linux《应用层自定义协议和序列化》
linux
云计算老刘1 小时前
3.Linux项目实战:PXE(自动化安装系统)
linux·运维·自动化