#yum -y install wget 安装wget #yum search libaio #yum install gcc gcc-c++ ncurses-devel perl #yum install -y unzip zip
下载reids包
$ wget http://download.redis.io/releases/redis-3.2.6.tar.gz $ tar xzf redis-3.2.6.tar.gz
先安装编译环境:
安装cmake
# mkdir /usr/local/cmake # cd /usr/local/cmake # tar zxvf cmake-2.8.10.2.tar.gz # cd cmake-2.8.10.2 # ./configure # make # make install # cd ~ # vi /etc/profile export PATH=/usr/local/mysql/cmake-2.8.10.2/bin:$PATH #添加这句话 #source /etc/profile #更新配置 $ cd redis-3.2.6 $ make
碰到下面的问题
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 2
解决办法
make MALLOC=libc
$ cd src $ make install $ mkdir /usr/local/redis $ mkdir -p /usr/local/redis/etc $ mkdir -p /usr/local/redis/bin $ cp /usr/local/redis-3.2.6/redis.conf /usr/local/redis/etc 这里要cp好几个 $ cp /usr/local/redis-3.2.6/src/redis-cli /usr/local/redis/bin 等等几个启动命令 到/usr/local/redis/bin # ./redis-server # ./redis-cli 以上的是装单个
集群的安装
mkdir -p /usr/local/cluster mkdir -p /usr/local/cluster/7000 mkdir -p /usr/local/cluster/7001 mkdir -p /usr/local/cluster/7002 mkdir -p /usr/local/cluster/7003 mkdir -p /usr/local/cluster/7004 mkdir -p /usr/local/cluster/7005 cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7000/ cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7001/ cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7002/ cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7003/ cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7004/ cp -rf /usr/local/redis3.2.6/redis.conf /usr/local/cluster/7005/ 修改配置文件 vi /usr/local/cluster/7000/redis.conf 这几个 port 7000 daemonize yes cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes bind 本地ip地址 vi /usr/local/cluster/7001/redis.conf vi /usr/local/cluster/7002/redis.conf vi /usr/local/cluster/7003/redis.conf vi /usr/local/cluster/7004/redis.conf vi /usr/local/cluster/7005/redis.conf 启动 /usr/local/redis/bin/redis-server /usr/local/redis-cluster/7001/redis.conf /usr/local/redis/bin/redis-server /usr/local/redis-cluster/7002/redis.conf ... 查看是否启动成功 ps -ef|grep redis 或者 ps -aux |grep redis 如果启动成功 cd /usr/local/redis-3.2.6/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 或者(最好是这样启动) ./redis-trib.rb create --replicas 1 192.168.63.129:7001 192.168.63.129:7002 192.168.63.129:7003 192.168.63.129:7004 192.168.63.129:7005 192.168.63.129:7006 redis.conf中配置的pind是多少就是多少 如果不成功就安装ruby yum install ruby yum install rubygems gem install redis 如果下载不下来 (redis高版本可能用不了,参考http://www.wityx.com/database/) wget https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem gem install -l ./redis-3.2.1.gem ./redis-trib.rb create --replicas 1 192.168.63.129:7001 192.168.63.129:7002 192.168.63.129:7003 192.168.63.129:7004 192.168.63.129:7005 192.168.63.129:7006 启动完毕