Redis 3 在CentOS 6.5上安装笔记,含启动脚本
Redis的强大就不多说了,直接上菜。
第1步:下载、编译、安装
cd /opt
wget http://download.redis.io/releases/redis-3.0.5.tar.gz
tar zxvf redis-3.0..tar.gz
cd redis-3.0.5
make && make install
第2步:配置,修改默认端口为7963、数据目录、日志目录、后台运行方式等
mkdir /etc/redis
mkdir /var/log/redis
mkdir -p /data/redis
cd /opt/redis-3.0.
cp redis.conf /etc/redis/.conf
vi /etc/redis/.conf
--------------------
daemonize no
port
logfile ""
pidfile /var/run/redis.pid
# requirepass foobared
dir ./
改成
daemonize yes
port
logfile "/var/log/redis/7963.log"
pidfile /var/run/redis_7963.pid
requirepass 9k3NgZq%gO!W7x-0y=LI
dir /data/redis
--------------------
通过sed快速修改配置文件命令如下:
sed -i "s/daemonize no/daemonize yes/g" /etc/redis/.conf
sed -i "s/port 6379/port 7963/g" /etc/redis/.conf
sed -i "s/pidfile \/var\/run\/redis.pid/pidfile \/var\/run\/redis_7963.pid/g" /etc/redis/7963.conf
sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/7963.log\"/g" /etc/redis/.conf
sed -i "s/# requirepass foobared/requirepass 9k3NgZq%gO!W7x-0y=LI/g" /etc/redis/.conf
sed -i "s/dir .\//dir \/data\/redis/g" /etc/redis/.conf
第3步:修改系统内存策略,保证数据完整性
# 设置内存策略
grep vm.overcommit_memory /etc/sysctl.conf
# 如果没有输出,就新增一行
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
# 如果有输出,就修改
sed -i "s/vm.overcommit_memory = 0/vm.overcommit_memory = 1/g" /etc/sysctl.conf
# 让配置生效
sysctl -p
第4步:配置启动脚本
cd /opt/redis-3.0.
cp utils/redis_init_script /etc/init.d/redis
vi /etc/init.d/redis
-----------------------------------
# 第二行插入以下2行
# chkconfig:
# description: Simple Redis init.d scrip
# 修改默认端口
REDISPORT=
# 改成
REDISPORT=
# 如果设置了Redis密码,则需要进行以下修改才能正常通过stop命令停止Redis服务
# 在CONF="/etc/redis/${REDISPORT}.conf"下面添加一行自动解析配置文件中的密码
PASS=`grep "requirepass " $CONF | awk {print'$2'}`
# 然后关闭指令根据密码是否为空判断是否需要添加密码参数
$CLIEXEC -p $REDISPORT shutdown
# 改成
if [ -z "$PASS" ]
then
$CLIEXEC -p $REDISPORT shutdown
else
$CLIEXEC -p $REDISPORT -a $PASS shutdown
fi
-----------------------------------
通过sed快速修改启动脚本命令如下:
sed -i "1 a # chkconfig: 2345 90 10" /etc/init.d/redis
sed -i "2 a # description: Simple Redis init.d scrip" /etc/init.d/redis
sed -i "s/REDISPORT=6379/REDISPORT=7963/g" /etc/init.d/redis
# 设置了密码则修改,不设置密码不用修改
sed -i $'13 a PASS=`grep "requirepass " $CONF | awk {print\'$2\'}`' /etc/init.d/redis
sed -i "s/PORT shutdown/PORT -a \$PASS shutdown/g" /etc/init.d/redis
第5步:添加启动项,并启动
#设置为开机自启动Redis
chkconfig redis on
#验证启动项是否设置成功
chkconfig --list redis
#启动Redis服务
service redis start
#关闭Redis服务
service redis stop
Redis默认端口,默认空密码存在严重的安全性问题,所以上面安装过程修改了默认端口也添加了密码管控。
参考资料:
Redis 3 在CentOS 6.5上安装笔记,含启动脚本的更多相关文章
- 记录CentOS 7.4 上安装MySQL&MariaDB&Redis&Mongodb
记录CentOS 7.4 上安装MySQL&MariaDB&Redis&Mongodb 前段时间我个人Google服务器意外不能用,并且我犯了一件很低级的错误,直接在gcp讲服 ...
- 在CentOS或RHEL上安装Nux Dextop仓库
介绍 Nux Dextop是类似CentOS.RHEL.ScientificLinux的第三方RPM仓库(比如:Ardour,Shutter等等).目前,Nux Dextop对CentOS/RHEL ...
- CentOS 6.5上安装MySQL-Cluster
参考博文: CentOS 6.2下MySQL Cluster 7.2 配置数据库集群 CentOS 6.5上安装MySQL-Cluster 7.3.4过程笔记--下一步学习 MySQL Cluster ...
- CentOS 6.9上安装mysql-5.6.36
CentOS 6.9上安装mysql-5.6.36 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/data,而后需要创建/da ...
- [转]在Linux CentOS 6.6上安装Python 2.7.9
在Linux CentOS 6.6上安装Python 2.7.9 查看python安装版本 python -V yum中最新的也是Python 2.6.6,所以只能下载Python 2.7.9的源代码 ...
- 在 CentOS 7.2 上安装 ODOO 10 (2018-10-09 持续更新)
在 CentOS 7.2 上安装 ODOO 10 更新系统 yum update 安装 EPEL 源 1 yum install -y epel-release 安装依赖组件 yum install ...
- CentOS 6.9上安装mysql-5.6.37
CentOS 6.9上安装mysql-5.6.37 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/data,而后需要创建/da ...
- CentOS 6.9上安装Mysql 5.7.18 安装
CentOS 6.9上安装Mysql 5.7.18 安装 下载地址:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-g ...
- 在 CentOS 6.4上安装Erlang
如何在CentOS 6.4上安装erlang,具体的Erlang版本是R15B03-1. 在安装之前,需要先要安装一些其他的软件,否则在安装中间会出现一些由于没有其依赖的软件模块而失败. 一开始,要是 ...
随机推荐
- DOM系统学习-进阶
DOM类型 Node类型: 常用类型: 元素节点 ELEMENT_NODE 属性节点 ATTRIBUTE_NODE 文本节点 TEX ...
- Linq To Sql的各种查询
一.Inner Join //request为查询条件 var result = from a in db.TableA join b in db.TableB on a.ID equal ...
- tengine + lua 实现流量拷贝
环境搭建参考地址:http://www.cnblogs.com/cp-miao/p/7505910.html cp.lua local res1, res2, action action = ngx. ...
- http://blog.csdn.net/rosten/article/details/17068285
http://blog.csdn.net/rosten/article/details/17068285
- webpacke install vue application 报错 Failed at the phantomjs-prebuilt@2.1.14 install script
刚刚在网上下了个开源的项目: https://github.com/ing670/webappkiller 执行npm install 报错:npm ERR! Failed at the phanto ...
- 利用pandas进行数据分析之三:DataFrame与Series基本功能
未经同意请勿转载http://www.cnblogs.com/smallcrystal/ 前文已经详细介绍DataFrame与Series两种数据结构,下面介绍DataFrame与Series的数据基 ...
- 循环List<Object>
List<Object> infoData=ArrayList<>(); for (int i = 0; i < infoData.size(); i++) { Obje ...
- Xml帮助类
public class XMLHelper { #region 将xml文件转换为object对象类型 /// <summary> /// 将xml文件转换为object对象类型 /// ...
- 在训练CNN时,loss稳定在log(类别数)
参见知乎问题! https://www.zhihu.com/question/275774218 很多框架都会有一个问题,当卷积 weight NaN 之后,卷积的 output 会变成 NaN.然后 ...
- Mac 上的传奇效率神器 Alfred 3
下载地址:https://www.alfredapp.com/ 第三方教程:https://www.jianshu.com/p/e9f3352c785f 一.内置快捷键介绍 1.默认快捷呼出热键是: ...