廢話很少說,直接開始吧html
先聲明一下軟件的版本: 我用的是 zookeeper 3.4.5 + solr 5.4.0web
主機環境:apache
三臺服務器 瀏覽器
192.168.15.43bash
192.168.15.44服務器
192.168.15.45ssh
爲了之後ssh方便 我修改了 43 的/etc/hosts:ide
192.168.15.43 solr1ui
192.168.15.44 solr2this
192.168.15.45 solr3
複製到服務器上 解壓安裝
目錄: ~/software
software下 installed-package 下存儲安裝軟件包
新建/software/zookeeper-data 文件夾 //zookeeper的數據存儲位置
將/soft/ zookeeper-3.4.5/ conf 下的zoo_sample.cfg文件名改成zoo.cfg 並修改zoo.cfg文件以下:
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. # do not use /tmp for storage, /tmp here is just # example sakes. # 注意此處寫絕對路徑 不然找不到 dataDir=/root/software/zookeeper-data # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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 #autopurge.purgeInterval=1 server.1=192.168.15.43:2888:3888 server.2=192.168.15.44:2888:3888 server.3=192.168.15.45:2888:3888
分發到 192.168.15.44 和 192.168.15.45 ~下面
可是發現 software下面的快捷方式消失了, 可是配置沒有小時,咱們須要從新 ln -s zookeeper
分別在每臺機器的/soft/zookeeper-data 下建立myid文件存儲該機器的標識碼 好比server.1 的標識碼就是 「1」 myid文件的內容就一行: 1
三臺服務器分別爲 1, 2, 3
注: 有問題能夠查看 bin下面的 zookeeper.out 文件,這個下面是會有異常報出的。
首先將solr-5.4.0.tar.gz包分別展開到各臺服務器的指定目錄下,例如:/root/solr-5.4.0
選擇一臺服務器在/root/下建立solr_home目錄,裏面用來臨時存放自定義的solr配置文件。結構以下:(注:solr4com是用戶自定義的索引核心配置,能夠從5.4自帶的/root/solr-5.4.0/server/solr/configsets/sample_techproducts_configs/中的文件做爲基礎修改獲得)
/root/solr_home/configsets/....
-/solr4com/conf/solrconfig.xml,schema.xml,... (自定義的core)
-/solr.xml,zoo,cfg
須要說明的是:各個自定義模塊的solrconfig.xml內容中的如下內容用系統默認的配置。
${solr.data.dir:}
schema.xml與單機版無異。
執行solr配置文件上傳到zk命令
選擇那臺有solr_home配置文件的服務器,進入/root/solr-5.4.0/server/scripts/cloud-scripts下,執行:
./zkcli.sh -cmd upconfig -confdir /root/solr_home/solr4com/conf -confname solr4com -z solr1:2181,solr2:2181,solr3:2181
進入/root/solr-5.4.0/server/scripts/cloud-scripts下,執行:
./zkcli.sh -cmd linkconfig -collection mycollectionname -confname solr4com -z solr1:2181,solr2:2181,solr3:2181
分別進入cloud1,cloud2,cloud3各臺solr節點服務器的/root/solr-5.4.0/bin 下,執行:
./solr start -cloud -p 8080 -s "/root/solr-5.4.0/server/solr" -z solr1:2181,solr2:2181,solr3:2181
稍等片刻,就能夠經過瀏覽器訪問http://cloud1:8080/solr/ 查看solr的部署狀況。這裏solr已經將使用Jetty作爲默認的web服務器。
在web瀏覽器地址欄輸入:
http://cloud1:8080/solr/admin/collections?action=CREATE&name=col4com&numShards=3&replicationFactor=3&maxShardsPerNode=3&collection.configName=solr4com
其中:col4com 爲集合(collection)名,solr4com 爲關聯的 config名(單機下的core名)
進入solr管理界面便可見到很帥的cloud節點圖。