环境
集群规划为5个节点,每个节点的ip、主机名和部署的组件分配如下:
192.168.20.191 cm191.hadoop.d3dstore.com 元数据库,CM
192.168.20.192 nn192.hadoop.d3dstore.com NameNode、ResourceManger、JobHistoryService
192.168.20.193 dn193.hadoop.d3dstore.com DataNode、NodeManager、Zookeeper、Hive、Sqoop、Flume、Hbase
192.168.20.194 dn194.hadoop.d3dstore.com DataNode、NodeManager
192.168.20.195 dn195.hadoop.d3dstore.com DataNode、NodeManager 、Zookeeper、SecondryNameNode、Flume、Impala
创建1个hadoop用户,并给用户设置无密码sudo权限:
1:adduser hadoop
2:passwd hadoop
3:chmod u+w /etc/sudoers
4:vi /etc/sudoers
增加: hadoop ALL=(root) NOPASSWD:ALL
5:chmod u-w /etc/sudoers
1.1 配置hosts
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=cm191.hadoop.d3dstore.com
$ vi/etc/hosts
192.168.20.191 cm191.hadoop.d3dstore.com
192.168.20.192 nn192.hadoop.d3dstore.com
192.168.20.193 dn193.hadoop.d3dstore.com
192.168.20.194 dn194.hadoop.d3dstore.com
192.168.20.195dn195.hadoop.d3dstore.com
1.2关闭防火墙
$ |
service iptables stop (临时关闭) |
|
$ |
chkconfig iptables off (重启后生效) |
1.3 时钟同步
NTP服务器
集群中所有主机必须保持时间同步,如果时间相差较大会引起各种问题。 具体思路如下:
1. 191节点作为ntp服务器与外界对时中心同步时间,随后对所有datanode节点提供时间同步服务。
2. 所有datanode节点以191节点为基础同步时间。
所有节点安装相关组件:ntp与ntpdate。按顺序安装即可,完成后,配置开机启动:
配置内网NTP服务器(191节点)
在配置之前,先使用ntpdate手动同步一下时间,免得本机与对时中心时间差距太大,使得ntpd不能正常同步。这里选用192.168.20.99作为对时中心。
1 |
ntdate -u 192.168.20.99 |
ntp服务只有一个配置文件,配置好了就OK。这里只给出有用的配置,不需要的配置都用#注掉,这里就不在给出:
$ vi /etc/ntp.conf
server pool.ntp.org prefer
serverstdtime.gov.hk iburst
server2.cn.pool.ntp.org iburst
server2.asia.pool.ntp.org iburst
server 0.centos.pool.ntp.orgiburst
server 1.centos.pool.ntp.orgiburst
server192.168.20.99 iburst
$ service ntpd start
$ chkconfig ntpd on (设置开机启动)
检查是否成功,用ntpstart命令查看同步状态,出现以下状态代表启动成功
1 |
synchronised to NTP server () at stratum 2 |
|
2 |
time correct to within 74 ms |
3 |
polling server every 128 s |
如果出现异常请等待几分钟,一般等待5-10分钟才能同步。
配置ntp客户端(所有datanode节点)
driftfile /var/lib/ntp/drift restrict 127.0.0.1 restrict -6 ::1 restrict default kod nomodify notrap nopeernoquery restrict -6 default kod nomodify notrap nopeernoquery server 192.168.20.191 |
ok保存退出,请求服务器前,请先使用ntpdate手动同步一下时间:
$ ntdate -u 192.168.20.191 (内网ntp服务器)
这里可能出现同步失败的情况,请不要着急,一般是本地的ntp服务器还没有正常启动,一般需要等待5-10分钟才可以正常同步。启动服务:
$ service ntpd start
$ chkconfig ntpd on
1.4 安装mysql
$ yum installmysql-server
Vi /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
log-bin=/data/mysql/logs/binary/mysql_binary_log
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
创建目录,赋予权限
$ mkdir -p/data/mysql/logs/binary/
$ chown -Rmysql:mysql /data/mysql
启动服务
$ mysql_install_db
$ service mysqldstart
设置开机启动服务
[root@:cm191~]$ chkconfig mysqld on
[root@ cm191:~]$ chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mysql服务启动
[root@ cm191:~]$ netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q LocalAddress ForeignAddress State PID/Program name
tcp 0 00.0.0.0:22 0.0.0.0:* LISTEN 2363/sshd
tcp 0 00.0.0.0:10050 0.0.0.0:* LISTEN 4591/zabbix_agentd
tcp 0 00.0.0.0:3306 0.0.0.0:* LISTEN 6262/mysqld
tcp 0 0:::22 :::* LISTEN 2363/sshd
权限配置
[root@ cm191:~ ] $ /usr/bin/mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT ISRECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASEREADEACH STEP CAREFULLY!
Inordertologinto MySQLto secure it, we'llneed the current password for the root user. If you've just installed MySQL,and you haven't set the root password yet, the password will be blank, so youshould just press enter here.
Entercurrent password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobodycan log into the MySQL root user without the proper authorisation.
Set root password? [Y/n]Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has ananonymous user, allowing anyone to log into MySQL without having to have a useraccount created for them. This is intended only for testing, and to makethe installation.
go a bit smoother. You should remove thembefore moving into a production environment.
Remove anonymous users? [Y/n]y
... Success!
Normally, root should only be allowed to connectfrom 'localhost'. Thisensures that someone cannot guess at the rootpassword from the network.
Disallow root login remotely? [Y/n]n
... skipping.
By default, MySQL comes with a database named'test' that anyone canaccess. This is also intended only fortesting, and should be removedbefore moving into a production environment.
Remove test database and access to it? [Y/n]y
- Dropping test database...
... Success!
Reloading the privilege tables will ensure thatall changes made so farwill take effect immediately.
Reload privilege tables now? [Y/n]y
... Success!
Cleaning up...
All done! If you've completed allof the above steps,your MySQLinstallation shouldnow be secure.
Thanks forusing MySQL!
设置远程可登录
mysql> GRANT ALL PRIVILEGES ON *.* TO'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
表的初始化
create database amon;
grant all on amon.* TO 'root'@'192.168.%'IDENTIFIED BY '12345ssdl';
1.5 CM的安装:
1:安装
在/etc/yum.repos.d目录下创建一个定义下载路径的文件
创建 cloudera-manager.repo内容如下
[cloudera-manager]name=Cloudera Manager
baseurl=http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5.2.0/
gpgkey =http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/RPM-GPG-KEY-cloudera
gpgcheck=1
安装cloudera-manager-server-db
$yum installcloudera-manager-server-db-2
为Cloudera Manager建立数据库
注:把mysql的驱动包放在/usr/share/cmf/lib
cp /opt/soft / mysql-connector-java-5.1.31.jar /usr/share/cmf/lib
/usr/share/cmf/schema/scm_prepare_database.sh mysql -h 192.168.20.191 -P 3306 -uroot1 -p12345ssdlh --scm-host cm191.hadoop.d3dstore.com scm root1 12345ssdlh
格式是: scm_prepare_database.sh数据库类型 数据库服务器用户名密码 --scm-host Cloudera_Manager_Server所在的机器
开启Cloudera Manager Server
cd /etc/init.d
servicecloudera-scm-server start;
设置成开机启动:chkconfigcloudera-scm-server on
查看7180是不是启动了
lsof -i :7180
启动 ClouderaManager管理控制台
地址类似 http://192.168.20.191:7180/ ,默认端口是 7180,如果上面没改的话。
用户名密码都是 admin
可以注意到,CDH以前的版本是有最大50个节点限制的,现在没有限制了。继续
点击继续:
添加安装的主机
找到对应的主机
选择需要的数据包和版本
选择oracle JDK点击继续:
用具有sudo权限的hadoop用户安装
集群开始安装:
这样是安装好了所有的安装包
选择需要安装的角色
配置数据源