安装的节点如下:
1个namenode、1个hiveserver、3个dataNode
192.168.1.139 namenode1
192.168.1.146 hiveserver
192.168.1.164 datanode1
192.168.1.165 datanode2
192.168.1.166 datanode3
===========安装步骤记录================================
一、主机环境配置(所有节点都要配置)
1、配置主机名、JDK、网卡、关闭防火墙及SElinux
[root@namenode1 ~]# cat /etc/sysconfig/network (主机名小写、不要有下划线)
NETWORKING=yes
HOSTNAME=namenode1
[root@namenode1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:C2:0C:25
TYPE=Ethernet
UUID=048c738b-8b3a-4deb-9478-e17c760b92bd
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.139
MASK=255.255.255.0
GATEWAY=192.168.1.1
[root@namenode1 ~]# getenforce (selinux设置为disabled、关闭防火墙(不要开机启动))
Disabled
[root@namenode1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.139 namenode1
192.168.1.146 hiveserver
192.168.1.164 datanode1
192.168.1.165 datanode2
192.168.1.166 datanode3
Java环境安装
(rhel6.5使用系统默认安装的jdk)
编辑"/etc/profile"文件,在后面添加Java的"JAVA_HOME"、"CLASSPATH"以及"PATH"内容如下:
# set java environment
export JAVA_HOME=/usr/java/jdk1.7.0_25/
export JRE_HOME=/usr/java/jdk1.7.0_25/jre
export CLASSPATH=.:CLASSPATH: CLASSPATH:JAVA_HOME/lib:$JRE_HOME/lib
export PATH=PATH: PATH:JAVA_HOME/bin:$JRE_HOME/bin
执行source /etc/profile
2、swap配置
Cloudera 建议将 /proc/sys/vm/swappiness 设置为 0。默认设置为 60。
查看当前swap分区设置cat /proc/sys/vm/swappiness
临时修改值:sudo sysctl vm.swappiness=0
永久修改值:vim /etc/sysctl.conf,在最后加一行vm.swappiness = 0
swappiness的值的大小对如何使用swap分区是有着很大的联系
swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间
swappiness=100的时候表示积极的使用swap分区,并且把内存上的数据及时的搬运到swap空间里面
3、时间同步配置
http://www.cnblogs.com/rusking/p/5378854.html
二、配置本地YUM源及安装必要的Packages
YUM源需要在单独的一台安装服务器上配置,也可以在上面5台服务器中的任意一台,我这里是配置在namenode1服务器上。
1、 挂截系统镜像文件 #mount /dev/cdrom /media/os_repo
2、修改配置文件local.repo
[root@namenode1 os_repo]# vi /etc/yum.repos.d/local.repo
###文件名字只能是local.repo,把原来的配置文件改名或删除,这个Local.repo文件只需要在安装服务器namenode1的创建就行。
[rhel6]
name=rhel6
baseurl=file:///media/os_repo/Server --注意这里是Server目录,而不是Packages目录
enabled=1
gpgcheck=0
4、安装apache
[root@namenode1 /]# yum install httpd
[root@namenode1 /]# vi /etc/httpd/conf/httpd.conf
将里面的 #ServerName localhost:80 注释去掉
[root@namenode1 /]# service httpd restart
[root@namenode1 /]# chkconfig httpd on --开机启动
5、安装桌面环境
(用于X-Manager连接安装)--可以不用安装,后来发现直接用CRT连接过去也能执行安装
检查是是否安装:
[root@namenode1 ~]# yum grouplist "X Window System"
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Group Process
Installed Groups:
X Window System
Done
[root@namenode1 ~]# yum grouplist "Desktop"
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Group Process
Installed Groups:
Desktop
Done
安装命令:
yum groupinstall "X Window System"
yum groupinstall "Desktop"
安装createrepo工具:
[root@namenode1]# yum install createrepo-0.9.9-18.el6.noarch.rpm
6、配置远程YUM源
把安装包拷贝到/var/www/html目录下
[root@namenode1 hadoop-installer]# ls --解压cdh5.5.0-bin.zip
cdh5 cm5
[root@namenode1 hadoop-installer]# ls cdh5/
noarch x86_64
[root@namenode1 hadoop-installer]# ls cm5/
x86_64
[root@namenode1 html]# pwd
/var/www/html
[root@namenode1 hadoop-installer]# cp -rf cdh5/ /var/www/html/
[root@namenode1 hadoop-installer]# cp -rf cm5/ /var/www/html/
[root@namenode1 hadoop-installer]# cp -rf Packages/ /var/www/html/os/ --Packages是操作系统ISO镜像里自带的RPM包目录
创建yum库:
[root@namenode1 ~]# createrepo -d /var/www/html/cm5/
[root@namenode1 ~]# createrepo -d /var/www/html/cdh5/
[root@namenode1 ~]# createrepo -d /var/www/html/os/
修改目录权限:
[root@namenode1 html]# chmod -Rf 777 *
[root@namenode1 html]# ll
total 12
drwxrwxrwx 5 root root 4096 Mar 20 22:09 cdh5
drwxrwxrwx 4 root root 4096 Mar 20 22:09 cm5
drwxrwxrwx 4 root root 4096 Mar 20 22:12 os
检查YUM是否配置正确:
yum list
通过浏览器访问,测试是否正常:
http://192.168.1.139/os
http://192.168.1.139/cm5
http://192.168.1.139/cdh5
查看能否进到各个子目录,看到安装包。
创建hadoop.repo文件:
[root@namenode1 yum.repos.d]# vi /etc/yum.repos.d/hadoop.repo --这个配置文件,每个节点都要修改,删除或修改所有原来的配置文件为bak
[cdh5]
name=cdh5
baseurl=http://192.168.1.139/cdh5
gpgcheck=0
[cm5]
name=cm5
baseurl=http://192.168.1.139/cm5
gpgcheck=0
[os-pkg]
name=os-pkg
baseurl=http://192.168.1.139/os
gpgcheck=0
~
三、创建hadoop用户及配置Ssh免密码登录
1、root账号登录,每个节点都创建hadoop用户及创建密码
useradd hadoop
passwd hadoop
2、hadoop用户登录,每台服务器都生成公有密钥
执行命令:
ssh-keygen -t rsa --生成密钥
NameNode1节点生成认证密钥文件:
[hadoop@namenode1 .ssh]$ cp id_rsa.pub authorized_keys
[hadoop@namenode1 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub
3、root账号登录,每台服务器都要修改sshd_config配置文件
[root@namenode1 ~]# vi /etc/ssh/sshd_config
RSAAuthentication yes # 启用 RSA 认证
PubkeyAuthentication yes # 启用公钥私钥配对认证方式
AuthorizedKeysFile %h/.ssh/authorized_keys # 公钥文件路径
4、root账号登录,修改sudoers配置文件
vi /etc/sudoers --root账号修改,增加以下两项
hadoop ALL=(ALL) ALL
hadoop ALL=(ALL) NOPASSWD: ALL
修改完后,service sshd restart
5、hadoop用户登录每台服务器,发送各自的公有密钥文件到NameNode1
[hadoop@DataNode1 .ssh]$ scp /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.139:/home/hadoop/.ssh/id_rsa.pub_DataNode1
[hadoop@DataNode2 ~]$ scp /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.139:/home/hadoop/.ssh/id_rsa.pub_DataNode2
[hadoop@DataNode3 ~]$ scp /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.139:/home/hadoop/.ssh/id_rsa.pub_DataNode3
[hadoop@HiveServer ~]$ scp /home/hadoop/.ssh/id_rsa.pub hadoop@192.168.1.139:/home/hadoop/.ssh/id_rsa.pub_HiveServer
6、hadoop用户登录NameNode1节点,将公有密钥文件追加到authorized_keys文件
[hadoop@namenode1 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub id_rsa.pub_DataNode1 id_rsa.pub_DataNode2 id_rsa.pub_DataNode3 id_rsa.pub_HiveServer
[hadoop@namenode1 .ssh]$ cat id_rsa.pub_DataNode1 >> authorized_keys
[hadoop@namenode1 .ssh]$ cat id_rsa.pub_DataNode2 >> authorized_keys
[hadoop@namenode1 .ssh]$ cat id_rsa.pub_DataNode3 >> authorized_keys
[hadoop@namenode1 .ssh]$ cat id_rsa.pub_HiveServer >> authorized_keys
7、hadoop用户登录,将上一步生成的authorized_keys再发回给每一台服务器的hadoop用户
[hadoop@namenode1 .ssh]$ scp /home/hadoop/.ssh/authorized_keys hadoop@192.168.1.164:/home/hadoop/.ssh/authorized_keys
[hadoop@namenode1 .ssh]$ scp /home/hadoop/.ssh/authorized_keys hadoop@192.168.1.165:/home/hadoop/.ssh/authorized_keys
[hadoop@namenode1 .ssh]$ scp /home/hadoop/.ssh/authorized_keys hadoop@192.168.1.166:/home/hadoop/.ssh/authorized_keys
[hadoop@namenode1 .ssh]$ scp /home/hadoop/.ssh/authorized_keys hadoop@192.168.1.146:/home/hadoop/.ssh/authorized_keys
8、root账号登录,所有服务器重启sshd服务
# service sshd restart
9、测试hadoop用户,免密码相互登录各台服务器
[root@namenode1 ~]# su - hadoop
[hadoop@namenode1 ~]$ ssh hadoop@datanode1 --第一次连接需要输入yes确认
The authenticity of host 'datanode1 (192.168.1.164)' can't be established.
RSA key fingerprint is 60:3b:d1:69:67:85:9e:7f:3a:9f:93:0e:6f:47:6d:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'datanode1' (RSA) to the list of known hosts.
[hadoop@DataNode1 ~]$ exit
logout
Connection to datanode1 closed.
[hadoop@namenode1 ~]$ ssh hadoop@datanode1 --不需要输入密码,直接登录
Last login: Sat Mar 19 23:54:35 2016 from namenode1
[hadoop@DataNode1 ~]$
同样的方法,再测试hadoop用户登录到其它服务器。
[hadoop@namenode1 ~]$ ssh hadoop@hiveserver
[hadoop@namenode1 ~]$ ssh hadoop@datanode2
[hadoop@namenode1 ~]$ ssh hadoop@datanode3
同时,其它服务器也可以用同样的方法,不需要输入密码,相互登录。
四、安装hadoop程序
1、将介质中cloudera-manager-installer.bin文件复制到安装监控服务器的/opt目录中,然后执行下面的命令:
./cloudera-manager-installer.bin --skip_repo_package=1
安装完成后,会有对话框提示:
Your browser should now open to http://192.168.1.139:7180/.Log in to cloudera manater with username and passwd set to admin to continue installation.
Installation was successful.
2、通过浏览器访问http://192.168.1.139:7180/ 在web界面继续完成Hadoop的安装及基本配置。
- 安装过程中使用自定义存储库:
- 钩选:安装Java无限制强度加密政策文件
安装过程中,注意记下postgresql数据库的用户名密码 - ssh登录凭据使用非root账号hadoop
- 使用嵌入式数据库PostgreSQL,这里也可以使用其它用户自定义安装的数据库。