一、檢查一下系統中的jdk版本
[root@localhost software]# java -version
顯示:
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
二、檢測jdk安裝包
[root@localhost software]# rpm -qa | grep java
顯示:
java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
python-javapackages-3.4.1-11.el7.noarch
tzdata-java-2016g-2.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
三、卸載openjdk
[root@localhost software]# rpm -e --nodeps tzdata-java-2016g-2.el7.noarch
[root@localhost software]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
[root@localhost software]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
[root@localhost software]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
[root@localhost software]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
或者使用
[root@localhost jvm]# yum remove *openjdk*
以後再次輸入rpm -qa | grep java 查看卸載狀況:
[root@localhost software]# rpm -qa | grep java
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
四、安裝新的jdk
[root@localhost software]# ll
total 181192
-rw-r--r-- 1 root root 185540433 May 20 2017 jdk-8u131-linux-x64.tar.gz
解壓 jdk-8u131-linux-x64.tar.gz安裝包
[root@localhost software]# mkdir -p /opt/soft
[root@localhost software]# mv jdk-8u131-linux-x64.tar.gz /opt/soft
[root@localhost software]# tar -zxvf jdk-8u131-linux-x64.tar.gz
[root@localhost software]# ln -s jdk1.8.0_131 jdk
五、設置環境變量
[root@localhost software]# vim /etc/profile
在最前面添加:
export JAVA_HOME=/opt/soft/jdkexport JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
六、執行profile文件
[root@localhost software]# source /etc/profile
七、檢查新安裝的jdk
[root@localhost software]# java -version
顯示:
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
到此爲止,整個安裝過程結束。
八、腳本安裝
mkdir -p /opt/soft/cd /opt/soft/
#download jdk-8u161-linux-x64.tar.gz#wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz
wget --no-check-certificate --no-cookies --header "Cookie: s_nr=1392900709523; ORA_WWW_PERSONALIZE=v:1~i:6~r:6~g:APAC~l:en~cs:NOT_FOUND~cn:scut; ORASSO_AUTH_HINT=v1.0~20140322121132; ORA_UCM_INFO=3~xxxx21212xxxx~xxxx~xxxx~xxxx@163.com; s_cc=true; oraclelicense=accept-securebackup-cookie; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjava-archive-downloads-javase6-419409.html%23jdk-6u45-oth-JPR; s_sq=%5B%5BB%5D%5D;" http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz
#extract jdk#tar -xvf jdk-8u161-linux-x64.tar.gz
tar -xvf jdk-8u161-linux-x64.tar.gz
rm -f jdk
ln -s jdk1.8.0_161 jdk
#set environmentexport JAVA_HOME="/opt/soft/jdk"if ! grep "JAVA_HOME=/opt/soft/jdk" /etc/profilethen
echo "export JAVA_HOME=/opt/soft/jdk" | tee -a /etc/profile
echo "export JRE_HOME=${JAVA_HOME}/jre " | tee -a /etc/profile
echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" | tee -a /etc/environment
echo "export PATH=${JAVA_HOME}/bin:$PATH" | tee -a /etc/profilefi
#update environmentsource /etc/profileecho "jdk is installed !"
一共三個節點,zk集羣不小於3個節點,要求服務器之間系統時間保持一致。
(一)上傳zk而且解壓
進行解壓: tar -zxvf zookeeper-3.4.6.tar.gz
重命名: mv zookeeper-3.4.6 zookeeper
(二) 修改zookeeper環境變量
vi /etc/profile
export JAVA_HOME=/opt/jdk1.8.0_71
export ZOOKEEPER_HOME=/usr/local/zookeeper
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
source /etc/profile
(三)修改zoo_sample.cfg文件
cd /usr/local/zookeeper/conf
mv zoo_sample.cfg zoo.cfg
修改conf: vi zoo.cfg 修改兩處
(1) dataDir=/usr/local/zookeeper/data(注意同時在zookeeper建立data目錄)
(2)最後面添加
server.0=ip1:2888:3888
server.1=ip2:2888:3888
server.2=ip3:2888:3888
(四)建立服務器標識
服務器標識配置:
建立文件夾: mkdir data
建立文件myid並填寫內容爲0: vi
myid (內容爲服務器標識 : 0)
(五)克隆zookeeper虛擬機服務器
把ip一、 ip2中的myid文件裏的值修改成1和2
路徑(vi /usr/local/zookeeper/data/myid)
(六)啓動zookeeper:
路徑: /usr/local/zookeeper/bin
執行: zkServer.sh start
(注意這裏3臺機器都要進行啓動)
狀態: zkServer.sh status(在三個節點上檢驗zk的mode,一個leader和倆個follower)
注:啓動失敗,可能緣由未關閉防火牆。
查看防火牆狀態:firewall-cmd --state
中止防火牆:systemctl stop firewalld.service
禁止開機啓動:systemctl disable firewalld.service
# 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/soft/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# ZooKeeper server and its port no. # ZooKeeper ensemble should know about every other machine in the ensemble # specify server id by creating 'myid' file in the dataDir # use hostname instead of IP address for convenient maintenance
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2988:3988
server.3=127.0.0.1:2088:3088
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
# autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature <br>
#autopurge.purgeInterval=1
dataLogDir=/opt/soft/zookeeper/log
tickTime:心跳時間,爲了確保鏈接存在的,以毫秒爲單位,最小超時時間爲兩個心跳時間
initLimit:多少個心跳時間內,容許其餘server鏈接並初始化數據,若是ZooKeeper管理的數據較大,則應相應增大這個值
clientPort:服務的監聽端口
dataDir:用於存放內存數據庫快照的文件夾,同時用於集羣的myid文件也存在這個文件夾裏(注意:一個配置文件只能包含一個dataDir字樣,即便它被註釋掉了。)
dataLogDir:用於單獨設置transaction log的目錄,transaction log分離能夠避免和普通log還有快照的競爭
syncLimit:多少個tickTime內,容許follower同步,若是follower落後太多,則會被丟棄。
server.A=B:C:D:
A是一個數字,表示這個是第幾號服務器,B是這個服務器的ip地址
C第一個端口用來集羣成員的信息交換,表示的是這個服務器與集羣中的Leader服務器交換信息的端口
D是在leader掛掉時專門用來進行選舉leader所用
zkCli.sh -server 127.0.0.1:2181 鏈接到 ZooKeeper 服務,鏈接成功後,系統會輸出 ZooKeeper 的相關環境以及配置信息。
命令行工具的一些簡單操做以下:
1. 顯示根目錄下、文件: ls / 使用 ls 命令來查看當前 ZooKeeper 中所包含的內容
2. 顯示根目錄下、文件: ls2 / 查看當前節點數據並能看到更新次數等數據
3. 建立文件,並設置初始內容: create /zk "test" 建立一個新的 znode節點「 zk 」以及與它關聯的字符串
4. 獲取文件內容: get /zk 確認 znode 是否包含咱們所建立的字符串
5. 修改文件內容: set /zk "zkbak" 對 zk 所關聯的字符串進行設置
6. 刪除文件: delete /zk 將剛纔建立的 znode 刪除
7. 退出客戶端: quit
8. 幫助命令: help
zookeeper圖像化客戶端工具ZooInspector
使用cmd運行ZooInspector\build\zookeeper-dev-ZooInspector.jar
輸入的命令爲java -jar zookeeper-dev-ZooInspector.jar圖像化界面連接便可