AWS EC2 CentOS release 6.5 部署redis
AWS EC2 CentOS release 6.5 部署redis
参考:http://blog.csdn.net/ludonqin/article/details/47211109
一.安装redis
1) 下载redis安装包
可去官网http://redis.io ,也可通过wget命令:
[root@ip-172-31-46-4 ~]# wget http://download.redis.io/redis-stable.tar.gz
2) 解压
执行命令:
[root@ip-172-31-46-4 ~]# tar –zxvf redis-stable.tar.gz
3) 编译、安装
执行命令:
[root@ip-172-31-46-4 ~]# cd redis-stable
执行命令:
[root@ip-172-31-46-4 redis-stable]# make
在make成功以后,需要执行命令:
[root@ip-172-31-46-4 redis-stable]# make test
成功后可手动拷贝src目录下redis-server、redis-cli、redis-check-aof、redis-check-dump等至/usr/local/bin目录下,也可执行命令:
[root@ip-172-31-46-4 redis-stable]# make install
验证系统目录下启动脚本:
[root@ip-172-31-46-4 ~]# cd /usr/local/bin
[root@ip-172-31-46-4 bin]# ls -ltrh
total 26M
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-server
-rwxr-xr-x 1 root root 5.4M Jan 7 08:03 redis-benchmark
-rwxr-xr-x 1 root root 5.5M Jan 7 08:03 redis-cli
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-check-rdb
lrwxrwxrwx 1 root root 12 Jan 7 08:03 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 22K Jan 7 08:03 redis-check-aof
二.修改配置文件.conf
1) 创建配置文件目录,dump file 目录,进程pid目录,log目录等
配置文件一般放在/etc/下,创建redis目录
[root@ip-172-31-46-4 bin]# cd /etc/
[root@ip-172-31-46-4 etc]# mkdir redis
ll 查看创建的redis目录
~
dump file、进程pid、log目录等,一般放在/var/目录下,
[root@ip-172-31-46-4 etc]# cd /var/
[root@ip-172-31-46-4 var]# mkdir redis
[root@ip-172-31-46-4 var]# cd redis
[root@ip-172-31-46-4 redis]# mkdir data log run
至此,目录创建完毕
2) 修改配置文件,配置参数
首先拷贝解压包下的redis.conf文件至/etc/redis
[root@ip-172-31-46-4 redis]# cp ~/redis-stable/redis.conf /etc/redis/
打开配置文件:
[root@ip-172-31-46-4 redis]# vi /etc/redis/redis.conf
修改端口(默认6379)
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
修改pid目录为新建目录
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/redis/run/redis_6379.pid
修改dump目录为新建目录
# 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.
dir /var/redis/data
修改log存储目录为新建目录
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile /var/redis/log/redis.log
修改配置文件使得redis在background运行(默认redis服务是console模式运行的)
# 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.
daemonize yes
3)持久化
默认rdb,可选择是否开启aof,若开启,修改配置文件appendonly
4)启动redis,查看各目录下文件
[root@ip-172-31-46-4 redis]# cd /usr/bin/
[root@ip-172-31-46-4 bin]# redis-server /etc/redis/redis.conf
redis已启动,查看进程,dump, log, pid等
5)客户端连接redis
[root@ip-172-31-46-4 bin]# redis-cli
默认端口6379
6)至此,redis基础配置完毕,若有其他相关配置调整,可查找文档再修改
三.服务及开机自启动
1) 创建redis启动脚本
拷贝解压包下utils下redis启动脚本至/etc/init.d/
[root@ip-172-31-46-4 bin]# cp ~/redis-stable/utils/redis_init_script /etc/init.d/
修改脚本名称(也可不修改)为redis
[root@ip-172-31-46-4 bin]# mv /etc/init.d/redis_init_script /etc/init.d/redis
修改脚本pid及conf路径为实际路径
[root@ip-172-31-46-4 bin]# vi /etc/init.d/redis_init_script
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
CONF="/etc/redis/redis.conf"
至此,在/etc/init.d/目录下,已经可以通过:
service redis start/stop 命令启动和关闭redis
若在其他目录下,不能够使用这2个命令,请继续配置2),添加权限
2) 给启动脚本添加权限
chmod +x /etc/init.d/redis
实际命令,根据目录的不同,会不一样
相应的删除权限是
chmod –x /etc/init.d/redis
如果需要在开机的时候,redis服务自动启动,可继续3)
3) 设置自启动
chkconfig redis on
如果运行报错,提示
是因为没有在启动脚本里加入redis启动优先级信息,可添加如下
再次执行chkconfig redis on,成功
至此,自启动配置完毕
--------------------------------------------------------
安装可能出错的地方:
a.如果提示:
gcc command不识别,请自行安装gcc;
(执行:yum -y install gcc)
b.如果提示:
couldn’t execute tcl : no such file or dicrectory,请自行安装tcl;
(执行:yum install -y tcl)
c.如果提示:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
原因是编译依赖或原来编译遗留出现的问题
(执行:make distclean)
d.如果提示:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2zmalloc.h:50:31: error: jemalloc/jemalloc.h:;
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数
(执行:make MALLOC=libc)
进阶:
配置文件说明,请参考:http://www.cnblogs.com/kreo/p/4423362.html
redis集群搭建,请参考:http://www.cnblogs.com/wuxl360/p/5920330.html
AWS EC2 CentOS release 6.5 部署redis的更多相关文章
- AWS EC2 CentOS release 6.5 部署zookeeper、kafka、dubbo
AWS EC2 CentOS release 6.5 部署zookeeper.kafka.dubbo参考:http://blog.csdn.net/yizezhong/article/details/ ...
- AWS EC2中部署Apache服务器(LAMP)
关键词: 1.新建aws ec2实例 2.使用putty连接到aws ec2 实例(SSH协议) 3.使用filezilla连接到aws ec2实例(SFTP协议) 4.在aws ec2上部署apac ...
- AWS EC2笔记
朋友想搭一个境外网站,找我帮忙,希望服务器.域名都在境外.我没有在境外建站的经历,只能先尝试.于是上网搜索了一下境外服务器,大家比较常用的是Digital Ocean和AWS,我索性打开这两家的官网, ...
- Redis笔记 -- 在 Centos7.4单机中部署Redis集群(二)
0x00--背景和目的 在单台PC服务器上部署Redis集群,通过不同的TCP端口启动多实例,模拟多台独立PC组成集群. 0x01--环境描述: Centos版本:CentOS Linux relea ...
- 部署Redis Cluster 6.0 集群并开启密码认证 和 Redis-cluster-proxy负载
部署Redis Cluster集群并开启密码认证 如果只想简单的搭建Redis Cluster,不需要设置密码和公网访问,可以参考官方文档. 节点介绍 Cluster模式推荐最少有6个节点,本次实验搭 ...
- Amazon AWS EC2开启Web服务器配置
在Amazon AWS EC2申请了一年的免费使用权,安装了CentOS + Mono + Jexus环境做一个Web Server使用. 在上述系统安装好之后,把TCP 80端口开启(iptable ...
- 在Centos 5.6下安装 redis
先引用redis官方(http://redis.io/) 的介绍: Redis is an open source, advanced key-value store.<br>It is ...
- 如何用docker部署redis cluster
前言 由于本人是个docker控,不喜欢安装各种环境,而且安装redis-trib也有点繁琐,索性用docker来做redis cluster. 本文用的是伪集群,真正的集群放到不同的机器即可.端口是 ...
- AWS EC2服务器的HTTPS负载均衡器配置过程
AWS EC2服务器配置负载均衡器步骤: 1.普通负载均衡器 至少两台EC2实例,这里以Centos6.7系统为例 启动之后先安装个apache的httpd服务器默认80端口,或者使用其他服务 ...
随机推荐
- Python系列之 - 装饰器
装饰器主要是用来对函数的操作,我们把定义的函数比作一个蛋糕的话,那么装饰器就是盒子,如果要吃蛋糕就先打开盒子.具体到程序中就是在函数外层又套了一层,套的那一层就是一个装饰器.这么说可能有点抽象,那么我 ...
- 40叔:自学的伙伴推荐看的PHP视频和书藉
记录一下我的学习编程经历,在自学的路上,看了不少的断断续续的看了不少的视频,现在只会一点PHP增删改查. 同样迷的有没有? 要自己用原生的开发个CMS 或者BBS,ask 系统好像还差的远. 所以回头 ...
- APP的宣传方式有哪些
APP应用已经成为了互联网不可缺少的话题,事实上,开发一款移动APP的成本不是很高,但是怎样以最低的成本得到最大的推广效果,这是企业和开发者都很关心的一个问题.下面,我们来探讨一下这个问题. 1.一款 ...
- Python系列之 - python运算符
废话不多说,上节说的是数据类型,本篇讲讲数据运算. 在算式"1+2"中,"1"和"2"被称为操作数,"+"被称为运算符 ...
- ASwipeLayout一个强大的侧滑菜单控件
Android中侧滑的场景有很大,大部分是基于RecyclerView,但是有些时候你可以动态地addView到一个布局当中,也希望它实现侧滑,所以就产生了ASwipeLayout,该控件不仅支持在R ...
- 机器学习基石:10 Logistic Regression
线性分类中的是非题------>概率题, 设置概率阈值后,大于等于该值的为O,小于改值的为X.------>逻辑回归. O为1,X为0: 逻辑回归假设: 逻辑函数/S型函数:光滑,单调, ...
- [USACO17FEB]Why Did the Cow Cross the Road I S
题目描述 Farmer John's cows are trying to learn to cross the road effectively. Remembering the old " ...
- UVALive4727:jump
约瑟夫环变式 设f[i][j]表示处理i个人,按照处理顺序,倒数第j个人是谁 则有f[i][j]=(f[i-1][j]+k)%i #include<cstdio> #include< ...
- 【tyvj】刷题记录(1001~1099)(64/99)
1001:排序完按照题意做即可. #include<cstdio> #include<iostream> #include<cmath> #include<a ...
- [BZOJ]1177: [Apio2009]Oil
题目大意:给出一个n*m的矩阵,选出3个不相交的k*k子矩阵,使得子矩阵中元素和最大.(k<=n,m<=1500) 思路:选出的子矩阵有3种情况:横着排三个.竖着排三个.三角状分布(其中有 ...