SUSE Linux 11下Redis环境搭建

因为工作环境中有Redis,所以对Redis进行了学习,当然首先就是从搭建环境开始,下面是我对于搭建Redis环境的记录。

系统是SUSE 11 sp2,

软件环境如下所示:

linux-svnfile:/home/apps/redis # ls

redis-3.0.0.gem    ruby-1.9.2-p290.tar.gz  zlib-1.2.7.tar.gz

redis-3.0.0.tar.gz  rubygems-2.4.6.tgz

redis.conf          zlib-1.2.6.tar.gz

安装基础环境:

linux-svnfile:/home/apps/redis # tar -zxf zlib-1.2.6.tar.gz -C /usr/local/src

linux-svnfile:/usr/local/src/zlib-1.2.6 # ./configure --prefix=/usr/local/zlib

linux-svnfile:/usr/local/src/zlib-1.2.6 # make && make install

linux-svnfile:/home/apps/redis # tar -zxf ruby-1.9.2-p290.tar.gz -C /usr/local/src

linux-svnfile:/usr/local/src/ruby-1.9.2-p290 # ./configure --prefix=/usr/local/ruby

linux-svnfile:/usr/local/src/ruby-1.9.2-p290 # make && make install

linux-svnfile:/usr/local/ruby # ln -s /usr/local/ruby/bin/ruby /usr/local/bin

linux-svnfile:/home/apps/redis # tar xf rubygems-2.4.6.tgz -C /usr/local/src

linux-svnfile:/usr/local/src # mv rubygems-2.4.6 ../gem

linux-svnfile:/usr/local/gem # ruby setup.rb

linux-svnfile:/usr/local/gem # cp bin/gem /usr/local/bin/

linux-svnfile:/home/apps/redis # gem install -l redis-3.0.0.gem

Successfully installed redis-3.0.0

Installing ri documentation for redis-3.0.0

Done installing documentation for redis after 0 seconds

1 gem installed

linux-svnfile:/home/apps/redis # tar -zxf redis-3.0.0.tar.gz -C /usr/local/src

linux-svnfile:/usr/local/src # mv redis-3.0.0 ../redis

linux-svnfile:/usr/local/redis # make

至此基础环境搭建完成

下面进行集群的搭建

linux-svnfile:/usr/local/redis # cp src/redis-server /usr/local/bin/

linux-svnfile:/usr/local/redis # cp src/redis-cli /usr/local/bin/

linux-svnfile:/usr/local/redis # cp src/redis-trib.rb /usr/local/bin

linux-svnfile:/usr/local/redis # mkdir -p /usr/local/cluster/{7000..7005}

linux-svnfile:/usr/local/redis # vi redis.conf

daemonize yes

port 7000

cluster-enabled yes

cluster-config-file nodes.conf

cluster-node-timeout 5000

appendonly yes

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7000

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7001

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7002

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7003

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7004

linux-svnfile:/usr/local/redis # cp redis.conf ../cluster/7005

这里需要注意的是文件名对应文件里端口的配置,例如7001文件下的port参数需要改为7001,其他一样做修改。

linux-svnfile:/usr/local/redis # redis-server ../cluster/7000/redis.conf

linux-svnfile:/usr/local/redis # redis-server ../cluster/7001/redis.conf

linux-svnfile:/usr/local/redis # redis-server ../cluster/7002/redis.conf

linux-svnfile:/usr/local/redis # redis-server ../cluster/7003/redis.conf

linux-svnfile:/usr/local/redis # redis-server ../cluster/7004/redis.conf

linux-svnfile:/usr/local/redis # redis-server ../cluster/7005/redis.conf

linux-svnfile:/usr/local/redis # ps -ef | grep redis

root    15590    1  0 18:52 ?        00:00:00 redis-server *:7000 [cluster]   

linux-svnfile:/usr/local/redis # 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

>>> Creating cluster

Connecting to node 127.0.0.1:7000: OK

Connecting to node 127.0.0.1:7001: [ERR] Sorry, can't connect to node 127.0.0.1:7001

You have new mail in /var/mail/root

linux-svnfile:/usr/local/cluster/7000 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7000 # cd ../7001

linux-svnfile:/usr/local/cluster/7001 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7001 # cd ../7002

linux-svnfile:/usr/local/cluster/7002 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7002 # cd ../7003

linux-svnfile:/usr/local/cluster/7003 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7003 # cd ../7004

linux-svnfile:/usr/local/cluster/7004 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7004 # cd ../7005

linux-svnfile:/usr/local/cluster/7005 # redis-server redis.conf

linux-svnfile:/usr/local/cluster/7005 # ps -ef | grep redis

root    17575    1  0 20:05 ?        00:00:00 redis-server *:7000 [cluster]

root    17590    1  0 20:06 ?        00:00:00 redis-server *:7001 [cluster]

root    17604    1  0 20:06 ?        00:00:00 redis-server *:7002 [cluster]

root    17612    1  0 20:06 ?        00:00:00 redis-server *:7003 [cluster]

root    17616    1  0 20:06 ?        00:00:00 redis-server *:7004 [cluster]

root    17624    1  0 20:06 ?        00:00:00 redis-server *:7005 [cluster]

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/323d9cf22241be45960f6996c8950e45.html