1、安装SSH服务
2、安装JDK,设置环境变量
3、安装zookeeper,设置开机自启动
查看是否已经安装了SSH
rpm -qa |grep ssh
编辑SSH配置文件
vim /etc/ssh/sshd_config
Esc键进入底行命令模式,输入 :set nu 显示行号
检查AuthorizedKeysFile(保存密钥的文件夹)PasswordAuthentication(是否允许密码登录) yes
如有且配置正确没有被注释那么不用做修改退出。
启动SSH服务
service sshd start
检查SSH服务
检查进程是否存在
ps -e |grep sshd
netstat -an |grep 22
yum -y install net-tools
ssh master
检查JAVA是否安装
java -version
tar -zxvf jdk-8u181-linux-x64_oracle.tar.gz
得到了一个解压文件夹
这个压缩包是免安装版本的解压后可以直接使用,不需要进行编译
存放Java根目录
新建/usr/local/java用于存放Java根目录
mkdir /usr/local/java
cp -r jdk1.8.0_181/ /usr/local/java/
设置环境变量
编辑profile,这个是所有用户登录都会运行的文件
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
检查PATH
echo $PATH
java -version
解压缩
tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz
mkdir /usr/local/zookeeper
cp -r apache-zookeeper-3.6.2-bin /usr/local/zookeeper/
chown -R hadoop:hadoop /usr/local/zookeeper/
新建数据存储目录
mkdir -p /home/hadoop/data/zookeeper/zkdata
mkdir -p /home/hadoop/data/zookeeper/zkdatalog
chown -R hadoop:hadoop /home/hadoop/
修改配置文件
配置zoo.cfg zoo.cfg是zoo_sample.cfg复制来的
这里zoo.cfg是生效文件,zoo_sample.cfg是模板文件
cp /usr/local/zookeeper/apache-zookeeper-3.6.2-bin/conf/zoo_sample.cfg /usr/local/zookeeper/apache-zookeeper-3.6.2-bin/conf/zoo.cfg
vim /usr/local/zookeeper/apache-zookeeper-3.6.2-bin/conf/zoo.cfg
dataDir=/home/hadoop/data/zookeeper/zkdata
dataLogDir=/home/hadoop/data/zookeeper/zkdatalog
server.1=master:2888:3888
vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin
export PATH=${ZOOKEEPER_HOME}/bin:$PATH
source /etc/profile
检查PATH
echo $PATH
尝试启动zk
注意这里开启服务一定要使用hadoop用户,因为会生成数据文件,这些数据文件如果是root权限会阻止hadoop用户之后访问。
切换用户
su hadoop
zkServer.sh start
jps
停止zk服务
zkServer.sh stop
创建zk的服务描述文件,使其可以被systemd识别
vim /usr/lib/systemd/system/zookeeper.service
输入内容
[Unit]
Description=Zookeeper
After=network.target
[Service]
Type=forking
User=hadoop
Group=hadoop
Environment=ZOO_LOG_DIR=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin/bin
Environment=JAVA_HOME=/usr/local/java/jdk1.8.0_181
WorkingDirectory=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin/bin
ExecStart=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin/bin/zkServer.sh start
ExecStop=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin/bin/zkServer.sh stop
ExecReload=/usr/local/zookeeper/apache-zookeeper-3.6.2-bin/bin/zkServer.sh restart
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
将zookeeper设为自启动
systemctl enable zookeeper
systemctl is-enabled zookeeper
systemctl start zookeeper
jps
systemctl status zookeeper.service -l