遵从上面步骤依次执行
1.检查器重,安装器重

CentOS6.4 安装Redis,centos6.4安装redis

遵守上面步骤依次执行
1.检查着重,安装正视

[[email protected] ~]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
[[email protected] ~]# whereis tc
tc: /sbin/tc /usr/lib64/tc /usr/share/tc /usr/share/man/man8/tc.8.gz
[[email protected] ~]# whereis wget
wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz
[[email protected] ~]# yum -y install tcl

2.进入/user/local/src/

[[email protected] ~]# cd /user/local/src/

3.wget下载redis

[[email protected] src]# wget http://download.redis.io/releases/redis-3.0.7.tar.gz

4.解压

[[email protected] src]tar zxvf redis-3.0.7.tar.gz

5.将文件转存到/usr/local/redis

[[email protected] src]mkdir /usr/local/redis
[[email protected] src]mv redis-3.0.7 /usr/local/redis
[[email protected] src]ll /usr/local/redis

6.编译安装

[[email protected] src]cd /usr/local/redis
[[email protected] redis]make && make install

 7.在etc目录下创制redi文件夹并创办布局文件,并修改配置文件

[[email protected] redis]mkdir -p /etc/redis
[[email protected] redis]pwd
[[email protected] redis]cp -fr /usr/local/redis/redis.conf /etc/redis/

8.vim编辑/etc/redis/redis.conf,修改daemonize属性为yes

[[email protected] redis]# vim /usr/local/redis/redis.conf
# 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

 9.执行/usr/loal/bin/redis-server /etc/redis/redis.conf来启动redis服务器

[[email protected] redis]# /usr/loal/bin/redis-server /etc/redis/redis.conf
-bash: /usr/loal/bin/redis-server: No such file or directory
[[email protected]-3c46 redis]# /usr/local/bin/redis-server /etc/redis/redis.conf
73449:M 13 May 10:56:00.839 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 73449
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

 10.再打开2个终端,切换至redis的设置目录执行redis-cli

[[email protected] bin]# redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> 

 

安装Redis,centos6.4安装redis
根据上边步骤依次执行 1.检查看重,安装尊敬
[[email protected]
~]# whereis gccgcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/…

依据上边步骤依次执行
1.检查着重,安装依赖

在公司应用中,对于数据的定点一般接纳数据库,然则数据库的吞吐量依然存在一定的难题的,在高并发高吞吐须求时,一般会一贯促成数据库的宕机或然死锁,方今对于这个难点的架构是在数据库前面在缓存池,redis就是这样一款产品。
对于redis的牵线,去百度呢,它应当被大规模运用在各种门类中,大家来看如何搭建二个redis集群,那里的集群是个真分布式集群哦。

[root@ecs-3c46 ~]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
[root@ecs-3c46 ~]# whereis tc
tc: /sbin/tc /usr/lib64/tc /usr/share/tc /usr/share/man/man8/tc.8.gz
[root@ecs-3c46 ~]# whereis wget
wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz
[root@ecs-3c46 ~]# yum -y install tcl
[root@ecs-3c46 ~]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
[root@ecs-3c46 ~]# whereis tc
tc: /sbin/tc /usr/lib64/tc /usr/share/tc /usr/share/man/man8/tc.8.gz
[root@ecs-3c46 ~]# whereis wget
wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz
[root@ecs-3c46 ~]# yum -y install tcl

首先,我们须求下载redis源代码,然后开展编译,以下命令在linux下进行:

2.进入/user/local/src/

2.进入/user/local/src/

wget
http://download.redis.io/redis-stable.tar.gz

[root@ecs-3c46 ~]# cd /usr/local/src/
[root@ecs-3c46 ~]# cd /usr/local/src/

tar xvzf redis-stable.tar.gz

3.wget下载redis

3.wget下载redis

cd redis-stable

[root@ecs-3c46 src]# wget http://download.redis.io/releases/redis-3.0.7.tar.gz
[root@ecs-3c46 src]# wget http://download.redis.io/releases/redis-3.0.7.tar.gz

make

4.解压

4.解压

前方3步应该没分外,主要的标题是实施make的时候,出现了要命。

[root@ecs-3c46 src]tar zxvf redis-3.0.7.tar.gz
[root@ecs-3c46 src]tar zxvf redis-3.0.7.tar.gz

异常一:

5.将文件转存到/usr/local/redis

5.将文件转存到/usr/local/redis

make[2]: cc: Command not found

[root@ecs-3c46 src]mkdir /usr/local/redis
[root@ecs-3c46 src]mv redis-3.0.7 /usr/local/redis
[root@ecs-3c46 src]ll /usr/local/redis
[root@ecs-3c46 src]mkdir /usr/local/redis
[root@ecs-3c46 src]mv redis-3.0.7 /usr/local/redis
[root@ecs-3c46 src]ll /usr/local/redis

可怜原因:没有安装gcc

6.编译安装

6.编译安装

化解方案:yum install gcc-c++

[root@ecs-3c46 src]cd /usr/local/redis
[root@ecs-3c46 redis]make && make install
[root@ecs-3c46 src]cd /usr/local/redis
[root@ecs-3c46 redis]make && make install

异常二:

 7.在etc目录下创办redi文件夹并创办布局文件,并修改配置文件

 7.在etc目录下开创redi文件夹并创办布局文件,并修改配置文件

zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory

[root@ecs-3c46 redis]mkdir -p /etc/redis
[root@ecs-3c46 redis]pwd
[root@ecs-3c46 redis]cp -fr /usr/local/redis/redis.conf /etc/redis/
[root@ecs-3c46 redis]mkdir -p /etc/redis
[root@ecs-3c46 redis]pwd
[root@ecs-3c46 redis]cp -fr /usr/local/redis/redis.conf /etc/redis/

老大原因:一些编译依赖或原来编译遗留出现的难题

8.vim编辑/etc/redis/redis.conf,修改daemonize属性为yes

8.vim编辑/etc/redis/redis.conf,修改daemonize属性为yes

焚林而猎方案:make distclean。清理一下,然后再make。

[root@ecs-3c46 redis]# vim /etc/redis/redis.conf
# 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
[root@ecs-3c46 redis]# vim /etc/redis/redis.conf
# 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

【澳门金沙国际】怎么搭建redis集群。在make成功之后,要求make test。在make test出现十分。

 9.执行/usr/loal/bin/redis-server /etc/redis/redis.conf来启动redis服务器

 9.执行/usr/loal/bin/redis-server /etc/redis/redis.conf来启动redis服务器

异常一:

[root@ecs-3c46 redis]# /usr/local/bin/redis-server /etc/redis/redis.conf
-bash: /usr/local/bin/redis-server: No such file or directory
[root@ecs-3c46 redis]# /usr/local/bin/redis-server /etc/redis/redis.conf
73449:M 13 May 10:56:00.839 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 73449
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               
[root@ecs-3c46 redis]# /usr/loal/bin/redis-server /etc/redis/redis.conf
-bash: /usr/loal/bin/redis-server: No such file or directory
[root@ecs-3c46 redis]# /usr/local/bin/redis-server /etc/redis/redis.conf
73449:M 13 May 10:56:00.839 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 73449
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

couldn’t execute “tclsh8.5”: no such file or directory

 10.再打开三个终极,切换至redis的装置目录执行redis-cli

 10.再打开三个极端,切换至redis的装置目录执行redis-cli

格外原因:没有安装tcl

[root@ecs-3c46 bin]# redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> 
[root@ecs-3c46 bin]# redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> 

消除方案:yum install -y tcl。

 

 

在make成功之后,会在src目录下多出一部分可执行文件:redis-server,redis-cli等等。

便利时期用cp命令复制到usr目录下运维。

cp redis-server /usr/local/bin/

cp redis-cli /usr/local/bin/

下一场新建目录,存放配置文件

mkdir /etc/redis

mkdir /var/redis

mkdir /var/redis/log

mkdir /var/redis/run

mkdir /var/redis/6379

在redis解压根目录中找到配置文件模板,复制到如下地方。

cp redis.conf /etc/redis/6379.conf

经过vim命令修改

daemonize yes

pidfile /var/redis/run/redis_6379.pid

logfile /var/redis/log/redis_6379.log

dir /var/redis/6379

最终运营redis:

$ redis-server /etc/redis/6379.conf

Redis集群安插文档(centos6体系)

(要让集群不奇怪干活最少需求一个主节点,在那里大家要成立五个redis节点,其中多少个为主节点,七个为从节点,对应的redis节点的ip和端口对应涉及如下)

127.0.0.1:7000
127.0.0.1:7001

127.0.0.1:7002

127.0.0.1:7003

127.0.0.1:7004

127.0.0.1:7005

1:下载redis。官网下载3.0.0本子,从前2.几的版本不辅助集群方式

下载地址:https://github.com/antirez/redis/archive/3.0.0-rc2.tar.gz

2:上传服务器,解压,编译

tar -zxvf redis-3.0.0-rc2.tar.gz

mv redis-3.0.0-rc2.tar.gz redis3.0

cd /usr/local/redis3.0

make

make install

3:创立集群要求的目录

mkdir -p /usr.local/cluster

cd /usr.local/cluster

mkdir 7000

mkdir 7001

mkdir 7002

mkdir 7003

mkdir 7004

mkdir 7005

4:修改配置文件redis.conf

cp /usr/local/redis3.0/redis.conf /usr.local/cluster

vi redis.conf

修改配置文件中的上边选项

port 7000

daemonize yes

cluster-enabled yes

cluster-config-file nodes.conf

cluster-node-timeout 5000

appendonly yes

修改完redis.conf配置文件中的那一个配置项之后把这么些布局文件分别拷贝到7000/700七分之一002/7003/7004/7005目录上边

cp /usr/local/cluster/redis.conf /usr/local/cluster/7000

cp /usr/local/cluster/redis.conf /usr/local/cluster/7001

cp /usr/local/cluster/redis.conf /usr/local/cluster/7002

cp /usr/local/cluster/redis.conf /usr/local/cluster/7003

cp /usr/local/cluster/redis.conf /usr/local/cluster/7004

cp /usr/local/cluster/redis.conf /usr/local/cluster/7005

专注:拷贝已毕以往要修改70014.29%002/7003/7004/7005索引上边redis.conf文件中的port参数,分别改为相应的文书夹的名目

5:分别运转那伍个redis实例

cd /usr/local/cluster/7000

redis-server redis.conf

cd /usr/local/cluster/7001

redis-server redis.conf

cd /usr/local/cluster/7002

redis-server redis.conf

cd /usr/local/cluster/7003

redis-server redis.conf

cd /usr/local/cluster/7004

redis-server redis.conf

cd /usr/local/cluster/7005

redis-server redis.conf

起步将来选拔命令查看redis的启航状态ps -ef|grep redis

如下图显示则印证运维成功

6:执行redis的开创集群命令创立集群

cd /usr/local/redis3.0/src

./redis-trib.rb create –replicas 1 127.0.0.1:7000 127.0.0.1:7001
127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

6.1执行上边的吩咐的时候会报错,因为是实践的ruby的台本,要求ruby的环境

荒唐内容:/usr/bin/env: ruby: No such file or directory

故而需求安装ruby的条件,这里推荐使用yum install ruby安装

yum install ruby

6.2然后再实施第伍步的创立集群命令,还会报错,提示缺少rubygems组件,使用yum安装

错误内容:

./redis-trib.rb:24:in `require’: no such file to load — rubygems
(LoadError)

from ./redis-trib.rb:24

yum install rubygems

6.3重复实施第四步的指令,还会报错,提醒不可以加载redis,是因为不够redis和ruby的接口,使用gem
安装

荒唐内容:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require’: no such file to load — redis (LoadError)

from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’

from ./redis-trib.rb:25

gem install redis

要求手工下载并设置:

澳门金沙国际 ,wget
https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
gem install -l ./redis-3.2.1.gem

6.4 重新实施第四步的授命,不奇怪实施

输入yes,然后配置完结。

至此redis集群即搭建成功!

7:使用redis-cli命令进入集群环境

redis-cli -c -p 7000

相关文章