一、centosos6.6下載html
windows 64位:redis
windows 32位:windows
http://pan.baidu.com/s/1o8GrpB8centos
計劃安裝四臺centos6.6虛擬機 centos一、centos二、centos三、centos4,使用VMware® Workstation 12 Pro安裝api
二、NAT聯網服務器
設置固定IP,注意gatway是192.168.121.2,最後一位是2網絡
四臺centos機器ip分別是ssh
192.168.121.129 centos1分佈式
192.168.121.130 centos2
192.168.121.131 centos3
192.168.121.132 centos4
三、更改centos機器名與hosts文件
vim /etc/sysconfig/network 更改HOSTNAME=centos1 ,同步更新另幾臺機器centos二、centos三、centos4
更改hosts文件
四、關閉防火牆
後期搭建zookeeper、redis等集羣時,可能出現通訊問題,所以把防火牆關閉。
命令:service iptables stop;
五、免密登陸
集羣機器之間通訊,須要設置免密登陸。使用命令:ssh 機器名(如ssh centos1),若是無需輸入密碼,直接登陸,即已設置免密登陸。
一、先免密登陸本機。
([root@centos bin]# ssh localhost,命令也會要求輸入密碼,配置完後就不用輸入)
命令:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
上面命令便是在本機生成公鑰/私鑰對,將公鑰追加到authorized_keys文件
keygen: 生成公鑰/私鑰對
-t dsa: 加密方式dsa,也可選擇rsa
-P ‘’: 密碼爲空
-f ~/.ssh/id_dsa: 產生私鑰文件,指定私鑰後,會同步生成公鑰文件id_dsa.pub
cat:將公鑰文件追加到authorized_keys文件內。
二、把公鑰複製到其它機器的authorized_keys中
把centos1的~/.ssh/id_dsa.pub內容追加到centos2和centos3的~/.ssh/authorized_keys中
把centos2的~/.ssh/id_dsa.pub內容追加到centos1和centos3的~/.ssh/authorized_keys中
把centos3的~/.ssh/id_dsa.pub內容追加到centos1和centos2的~/.ssh/authorized_keys中
常常經過ssh 或者 scp 鏈接一堆遠程主機,一樣是 Linux 主機,其中一些建立 ssh 鏈接速度特別慢,鏈接創建以後執行操做速度卻很正常,看來應該不是網絡緣由。解決的方法是經過ssh 的-v參數來查看調試信息的:
用 ssh -v 來查看詳細的鏈接創建過程,立刻用一臺創建鏈接很慢的主機試了一下,在一大堆輸出信息中發如今這裏停留最久:
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Next authentication method: publickey
原來是由於嘗試了個沒有意義並且會失敗的 gssapi-with-mic 認證方式浪費了時間,打開(遠程服務器) /etc/ssh/ssh_config 把裏面的 GSSAPIAuthentication yes 改爲 no 關掉它,便可讓 ssh 直接嘗試美妙的 publickey 認證方式。
六、jdk環境搭建
後期搭建的分佈式集羣,大部分是JAVA環境下運行的。如zookeeper,hadoop,所以虛擬機內都要配置jdk環境。
具體jdk環境搭建,請參考http://www.centoscn.com/image-text/install/2014/0827/3585.html