1、虚拟机网络连接模式选择桥接,虚拟安装好之后
cd /etc/sysconfig/network-scripts
vi ifcfg-ens33
修改一下内容
BOOTPROTO=static
增加(看你自己的电脑 网络连接-适配器-ipv4属性)
IPADDR=192.168.2.190 ##虚拟机ip地址,自己定
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
DNS1=101.198.199.200
DNS2=192.68.2.1
ZONE=public
2、yum安装jdk
yum list java*
yum -y install java-1.8.0-openjdk.x86_64 ##版本你自己选
java -version
3、安装zookeeper
创建一个目录,我创建的是/usr/data/apps/zookeeper
cd /usr/data/apps/zookeeper
curl -o zookeeper-3.4.13.tar.gz http://http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
tar -zxvf zookeeper-3.4.13.tar.gz ##到这一步就解压好了,可以准备修改配置启动服务了
cd zookeeper-3.4.13/conf
cp zoo_sample.cfg zoo.cfg
./bin/zkServer.sh start ##启动服务
4、设置zookeeper开机启动
cd /etc/init.d
touch zookeeper
vi zookeeper ##写入一下内容
#!/bin/bash
#chkconfig: 2345 10 90 ##2345是默认启动级别(百度linux默认启动级别),10是启动优先级,90是停止优先级,数字越大表示优先级越低(0-100)
#description: service zookeeper
export JAVA_HOME=/opt/java/jdk1.8.0_121
export ZOO_LOG_DIR=/opt/zookeeper/log
ZOOKEEPER_HOME=/usr/data/apps/zookeeper/zookeeper-3.4.13
case "$1" in
start) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start;;
start-foreground) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start-foreground;;
stop) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh stop;;
status) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh status;;
restart) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh restart;;
upgrade)su root ${ZOOKEEPER_HOME}/bin/zkServer.sh upgrade;;
print-cmd)su root ${ZOOKEEPER_HOME}/bin/zkServer.sh print-cmd;;
*) echo "requirestart|start-foreground|stop|status|restart|print-cmd";;
esac
chmod +x /etc/rc.d/init.d/zookeeper ###为文件添加可执行权限
chkconfig --add zookeeper ##添加脚本到开机启动项
chkconfig --list ##查看是否添加到启动项中
5、修改/bin/zkEnv.sh
增加ZOO_LOG_DIR=/usr/data/apps/zookeeper/zookeeper-3.4.13/logs
6、关闭防火墙
systemctl stop firewalld
7、ss -antl|grep 2181
网友评论