参考文献:
https://cwiki.apache.org/confluence/display/AMBARI/Ambari+Code+Layout
1.配置nodejs
1.1 下载nodejs
建议下载编译ambari时使用的版本的nodejs(v0.10.44)
[root@hadron ~]wget https://nodejs.org/download/release/v0.10.44/node-v0.10.44-linux-x64.tar.gz
1.2 环境变量配置
[root@hadron ~]mkdir -p /opt/app
[root@hadron ~]tar -zxvf node-v0.10.44-linux-x64.tar.gz -C /opt/app/
[root@hadron ~]vi /etc/profile
#set for nodejs
export NODE_HOME=/opt/app/node-v0.10.44-linux-x64
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
1.3 重启计算机
1.4 查看node和npm版本号
[root@hadron ~]# node -v
v0.10.44
[root@hadron ~]# npm -v
2.15.0
1.4 安装低版本的brunch
[root@hadron ~]# npm i -g brunch@1
2 构建ambari-web
2.1 进入ambari-web目录
[root@hadron ~]# cd apache-ambari-2.4.2-src/ambari-web
2.2 安装本地依赖模块
[root@hadron ambari-web]# npm install
2.3 构建
[root@hadron ambari-web]# brunch build
17 Mar 15:14:07 - info: compiled 1210 files into 5 files, copied 319 in 4286ms
3 运行amabri-web
3.1 在观看模式下启动Brunch
brunch watch –server (or use the shorthand: brunch w -s)
[root@hadron ambari-web]# brunch watch -s
17 Mar 15:14:51 - info: application started on http://localhost:3333/
17 Mar 15:14:55 - info: compiled 1210 files into 5 files, copied 319 in 3755ms
npm i -g brunch@117 Mar 15:17:00 - info: copied info.json in 121ms
3.2 打开浏览器
在服务于最终应用程序的http:// localhost:3333上启动HTTP服务器。 这有助于查看使用模拟数据的UI,而无需部署整个Ambari服务器。
输入地址:http://localhost:3333/即可打开,可以看到ambari登录页面,但是无法登录
3.3 info.json文件
进入ambari-web下的app/assets/data/clusters目录,创建一个info.json文件,给定一些集群信息:
[root@hadron ambari-web]# cd app/assets/data/clusters
[root@hadron clusters]# vi info.json
{
"items" : [
{
"Clusters" : {
"cluster_name" : "cc",
"provisioning_state" : "INSTALLED",
"version" : "HDP-2.4.3"
}
}
]
}
再次登录,即可看到Ambari运维页面,其中左上角可以看到集群名称“cc”