linux 安装redis zookeeper

 

安装redis:

http://www.redis.cn/download.html

安装的前提条件:

需要安装gcc:yum install gcc-c++

wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar -zxvf redis-3.2.8.tar.gz
cd redis-3.2.8
#进行编译 make
make
#创建redis目录 /usr/local/redis
mkdir redis

#进入解压目录
cd /usr/local/redis-3.2.9
#安装目录 make install PREFIX
=/usr/local/redis 如提示make无效需要安装gcc 安装完成

 复制配置文件redis.conf 到安装目录

 

修改配置文件 

daemonize yes 后台启动

 

requirepass redis 设置密码为redis

 

启动

[root@iZ28mgdqcyxZ bin]# ./redis-server redis.conf

 

安装zookeeper

安装之前要安装jdk 略

 wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
#解压
 tar -zxvf zookeeper-3.3.6.tar.gz   
cd zookeeper-3.3.6/conf  
拷贝zoo_samle.cfg为zoo.cfg
cp  zoo_samle.cfg zoo.cfg
vi zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/mnt/disk/word/children/zookeeper-3.3.6/data
dataLogDir=/mnt/disk/word/children/zookeeper-3.3.6/logs
# the port at which the clients will connect
clientPort=2181

 

dataDir=/mnt/disk/word/children/zookeeper-3.3.6/data
dataLogDir=/mnt/disk/word/children/zookeeper-3.3.6/logs

  注意:这里的data和logs是没有的,要自己创建 mkdir data ,mkdir logs

 

设置环境变量

vi /etc/profile

 

#zookeeper
export ZOOKEEPER_HOME=/mnt/disk/word/children/zookeeper-3.3.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin

使环境变量生效 

source /etc/profile

 

启动,任何地方都可以启动

[root@iZ28mgdqcyxZ conf]# zkServer.sh start

 

设置redis & zookeeper 开机启动

vi /etc/rc.d/rc.local

#加载java环境变量 否则不能启动
export JAVA_HOME=/var/lib/jvm/jdk1.7.0_80
#启动zk
/mnt/disk/word/children/zookeeper-3.3.6/bin/zkServer.sh start

#启动redis
/mnt/disk/word/children/redis/bin/redis-server /mnt/disk/word/children/redis/bin/redis.conf

#在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限
chmod +x /etc/rc.d/rc.local

 

centos 7防火墙:

0、开启防火墙:sudo systemctl start firewalld,service

1、关闭防火墙:sudo systemctl stop firewalld.service

2、关闭开机启动:sudo systemctl disable firewalld.service

3、开启开机启动:sudo systemctl enable firewalld.service

centos 6防火墙:

1、关闭防火墙:service iptables stop

2、开启防火墙:service iptables start

3、防火墙状态:service iptables status

完成

posted @ 2017-12-26 19:00  不朽丶  阅读(439)  评论(0编辑  收藏  举报
页脚