导航:首页 > 源码编译 > dt编译vendor

dt编译vendor

发布时间:2023-05-23 00:19:59

① SElinux权限

在了解SELinux之前,我们先来了解一下Linux的两种访问控制策略:DAC和MAC

DAC,自主访问控制(Discretionary Access control)。系统只提供基本的验证, 完整的访问控制由开发者自己控制。
 DAC将资源访问者分成三类:Owner、Group、Other 。
 将访问权限也分成三类:read、write、execute
资源针对资源访问者设置不同的访问权限。访问者通常是各个用户的进程,有自己的uid/gid,通过uid/gid 和文件权限匹配, 来确定是否可以访问。DAC机制下,每一个用户进程默认都拥有该用户的所有权限。
DAC 有两个严重问题:
 问题一:
 因为Root用户是拥有所有权限的,所以DAC对Root用户的限制是无效的。并且在Linux Kernel 2.1以后,Linux将Root权限根据不同的应用场景划分成许多的Root Capabilities, 普通用户也可以被设置某个Root Capability。普通用户如果被设置了CAP_DAC_OVERRIDE, 也可以绕过 DAC 限制。
 问题二:
 用户进程拥有该用户的所有权限,可以修改/删除该用户的所有文件资源, 难以防止恶意软件。

可见,DAC 有明显的缺陷,一旦被入侵,取得Root权限的用户进程就可以无法无天,胡作非为,早期android版本就深受其害。

MAC, 强制性访问控制(Mandatory Access control)。 系统针对每一项访问都进行严格的限制, 具体的限制策略由开发者给出。

Linux MAC 针对DAC 的不足, 要求系统对每一项访问, 每访问一个文件资源都需要根据已经定义好了的策略进行针对性的验证。系统可以针对特定的进程与特定的文件资源来进行权限的控制。即使是root用户,它所属的不同的进程,并不一定能取得root权限,而得要看事先为该进程定义的访问限制策略。如果不能通过MAC 验证,一样无法执行相关的操作。

与DAC相比,MAC访问控制的“主体”变成了“进程”而不是用户。这样可以限制了Root 权限的滥用,另外要求对每一项权限进行了更加完整的细化, 可以限制用户对资源的访问行为。

SELinux就是目前最好的MAC机制,也是目前的行业标准。

SELinux,安全增强Linux(Security-Enhanced Linux),是由美国国家安全局(NSA)发起, 多个非营利组织和高校参与开发的强制性安全审查机制(Mandatory Access control,简称MAC)。SELinux最早于2000年12月采用GPL许可发布。目前,Linux Kernel 2.6 及以上的版本都已经集成了SELinux。

SELinux 分成三种模式:

Android 5.x及以上强制开启,因此,disabled(关闭)模式并没有什么用了。 通常在调试时,我们会启用Permissve(宽容模式), 以便尽可能的发现多的问题, 然后一次修正。 在量产时启用Enfocing mode(强制模式)来保护系统。

查看SELinux模式:adb shell getenforce
设置SELinux模式:adb shell setenforce 1 //0是Permissve,1是Enfocing

SELinux 的访问控制示意图:

通常我们开发的过程中,就是配置Subject、Object、Security Policy。

SELinux 给Linux 的所有对象都分配一个安全上下文(Security Context), 描述成一个标准的字符串。

安全上下文的标准格式: user:role:type[:range]

Security Label 用来绑定被访问资源和安全上下文,描述它们的对应关系。标准格式为:resource security_context。即:res user:role:type[:range]。这里也可以使用通配符,例如 net.就可以绑定所有以net.开头的属性,除此之外,还有类似正则表达式的*、?等等通配符。Security Label 都定义在type_contexts当中,例如file的定义在file_contexts中,service定义在service_contexts中,property定义在property_contexts中。
举例:
file_contexts:

service_contexts:

查看进程安全上下文: ps -AZ 。例如,查看Settings进程的安全上下文,ps -AZ | grep settings:
  u:r:system_app:s0 system 1381 585 4234504 201072 0 0 S com.android.settings
查看文件安全上下文: ls -Z 。例如,查看文件build.prop的安全上下文:
  u:object_r:system_file:s0 build.prop

Type Enforcement (TE) 是根据Security Context中的 type 进行权限审查, 审查 subject type 对 object type 的某个class 类型中某种permission 是否具有访问权限,是目前使用最为广泛的MAC 审查机制, 简单易用。

TE控制语句格式 : rule_name source_type target_type : class perm_set

Type Enforcement规则说明:

举个例子,logd.te、tombstoned.te中定义的TE规则:
  allow logd runtime_event_log_tags_file:file rw_file_perms;
  dontaudit domain runtime_event_log_tags_file:file { open read };
  auditallow tombstoned anr_data_file:file { append write };
  neverallow logd { app_data_file system_data_file }:dir_file_class_set write;

SELinux 中每一个进程或者文件都对应一个type, 而每一个type 都对应有一个或几个attribute。所有常见的attribute定义在以下文件中:
  system/sepolicy/public/attributes
  system/sepolicy/prebuilts/api/[build version]/public/attributes
  system/sepolicy/prebuilts/api/[build version]/private/attributes
其中的[build version]即为android版本号,例如android O为28.0。常见的attribute定义:

Type对应一个或者几个attribute,Type的定义格式:
  type type_name, attribute1, attribute2;
Type的定义通常分散在各个te文件中。例如,常用普通文件的type定义在file.te中:

SEAndroid对于不同的资源类型,定义了不同的Class。比如普通的file、socket等等,比如SELinux 使用的security, 比如针对每个process 参数的process 等定义相关的class。这些class,每一个class 都有相对应的permissions。 比如file 就有 read, write, create, getattr, setattr, lock, ioctl 等等. 比如process 就有fork, sigchld, sigkill, ptrace, getpgid, setpgid 等等。这些相关的class, 以及他们具有那些Permissions都定义在以下文件中:
  system/sepolicy/private/access_vectors
  system/sepolicy/reqd_mask/access_vectors
  system/sepolicy/prebuilts/api/版本号/private/access_vectors
例如:

定义完之后,在以下对应的security_classes 文件中声明定义的classes。
  system/sepolicy/private/security_classes
  system/sepolicy/reqd_mask/security_classes
  system/sepolicy/prebuilts/api/版本号/private/security_classes
例如:

注意,Classes 和Permissions的定义与Kernel 中相关API是强相关的,普通用户严禁修改。

在SELinux 中, 我们通常称一个进程是一个domain, 一个进程fork 另外一个进程并执行(exec) 一个执行档时, 我们往往会涉及到domain 的切换. 比如init 进程, SELinux 给予了它很大的权限, 而它拉起的服务, 我们要限制这个服务的权限,于是就涉及到从一个domain 切换到另外一个domain, 不然默认就使用init 进程的domain.

在SELinux 里面有专门的一条语法: type_transition statement.
在准备切换前我们先要确保有相关的权限操作:

如下面的demo, init 拉起apache 并且切换到 apache 的domain.
(1). 首先,你得让init_t域中的进程能够执行type为apache_exec_t的文件
  allow init_t apache_exec_t : file {read getattr execute};
(2). 然后,你还得告诉SELinux,允许init_t做DT切换以进入apache_t域
  allow init_t apache_t : process transition;
(3). 然后,你还得告诉SELinux,切换入口(对应为entrypoint权限)为执行apache_exec_t类型 的文件
  allow apache_t apache_exec_t : file entrypoint;
(4).最后,Domain Transition
  type_transition init_t apache_exec_t : process apache_t;

可以看到,整个domain切换过程写起来非常麻烦。因此,Google 为了使用方便, 在system/sepolicy/public/te_macros 文件中定义了宏:

我们可以使用这些宏来完成domain切换。

举例:
kernel启动init进程切换domain:
  domain_auto_trans(kernel, init_exec, init)
init启动netd、vold、zygote、installd切换domain:
  init_daemon_domain(netd)
  init_daemon_domain(vold)
  init_daemon_domain(zygote)
  init_daemon_domain(installd)

一个进程创建在一个目录下创建文件时, 默认是沿用父目录的Security Context, 如果要设置成特定的Label, 就必须进行Object Transitions.
同样是使用:type_transition statement.
对应的必须有两个前提条件:

下面是一个demo, ext_gateway_t 这个domain 在类型为in_queue_t 的目录下,创建类型为 in_file_t 的文件.

(1). 首先,你得让ext_gateway_t 对in_queue_t 目录具备访问权限
  allow ext_gateway_t in_queue_t : dir { write search add_name };
(2). 然后,你还得告诉SELinux,允许ext_gateway_t 访问in_file_t的文件
  allow ext_gateway_t in_file_t : file { write create getattr };
(3).最后,Object Transition
  type_transition ext_gateway_t in_queue_t : file in_file_t;

同样的,为了方便使用,Google 也在system/sepolicy/public/te_macros 文件中定义了宏:

使用举例:
  file_type_auto_trans(factory, system_data_file, factory_data_file)

android O 以前sepolicy 集中放在boot image 。前面提到SELinux在Android的主要变更历史时,有提到android O 开始,Google将system image 和 vendor image 分离。因此,sepolicy 也相应的被分离存放到system image 以及 vendor image。与system 相关的sepolicy 就存放system image, 与SoC vendor 相关的sepolicy 就存放在vendor image。

对于原生AOSP,Google 设定了不同的存放目录, 以便进行分离, 以Google 默认的sepolicy 为例,sepolicy主目录为 /system/sepolicy,我们主要关注三个子目录:

对于不同的平台,不同平台厂商也设定了不同的存放目录,以MTK平台为例:
首先,根据不同的platform共用sepolicy、platform独有、project独有,分为:

对应的,不同版本会导入不同目录下的sepolicy配置

以mt6763平台为例,导入时:
[common] 路径为:/device/mediatek/sepolicy
[platfrom] 路径为:/device/mediatek/mt6763/sepolicy/
具体的定义在BoardConfig.mk文件中:

然后,basic、bsp、full又可以主要细分为:

Google 在system/sepolicy 中定义了相关的neverallow 规则, 对SELinux Policy 的更新进行了限制, 以防止开发者过度开放权限,从而引发安全问题。并且还会通过CTS测试检测开发者是否有违法相关的规则。

因此,我们需要注意以下几点:

出现SELinux Policy Exception时常见的两种解决方案:

(1). 修改对应节点的SELinux Security Label, 为特定的Subject,如system_app、platform_app、priv_app,例如Settings,SystemUI等内置APP开启权限, 但严禁为untrsted app 开启权限。
(2). 通过system server service 或者 init 启动的service 读写操作, 然后app 通过binder/socket 等方式连接访问. 此类安全可靠, 并且可以在service 中做相关的安全审查, 推荐这种方法.

情景: 定义由 init 进程启动的service, factory, 其对应的执行档是 /vendor/bin/factory。

(1). 在device/mediatek/mt6763/sepolicy/basic/non_plat 目录下创建一个factory.te , 然后将te文件加入编译,如放到这种指定目录下不需要额外配置,sytem/sepolicy/Android.mk中定义的build_policy函数会遍历指定目录导入te文件。

(2). 在factory.te 中定义factory类型,init 启动service 时类型转换,
  type factory, domain;
  type factory_exec, exec_type, file_type, vendor_file_type;
  init_daemon_domain(factory)

(3). 在file_contexts中绑定执行档
  /(system/vendor|vendor)/bin/factory u:object_r:factory_exec:s0

(4). 根据factory需要访问的文件以及设备, 定义其它的权限在factory.te 中.
  #Purpose: For key and touch event
  allow factory input_device:chr_file r_file_perms;
  allow factory input_device:dir rw_dir_perms;

情景: 添加一个自定义的system property: persist.demo,并为platform_app设置读写权限

(1). 在property.te中定义system property类型
  type demo_prop, property_type

(2). 在property_contexts中绑定system property的安全上下文。
  persist.demo u:object_r:demo_prop:s0

(3). 在platform_app.te 中新增写权限,可以使用set_prop宏。
  set_prop(platform_app, demo_prop)

(4). 在platform_app.te 中新增读权限,可以get_prop 宏。
  get_prop(platform_app, demo_prop)

情景: 有一个设备节点/dev/demo,有一个platform_app进程需要读写这个设备节点。

(1). 在device.te中定义device 类型
  type demo_device dev_type;

(2). 在 file_contexts中绑定demo_device
  /dev/demo u:object_r:demo_device:s0

(3). 在platform_app.te中,允许platform_app使用demo device 的权限
  allow platform_app demo_device:chr_file rw_file_perms;

情景: 有一个扩展的系统服务demo_service供APP调用。

(1). 在service.te 中定义service 类型
  type demo_service, app_api_service, system_server_service, service_manager_type;

(2). 在service_contexts 中绑定service
  demo u:object_r:demo_service:s0

(3). 在frameworks/base/core/java/android/content/Context.java中定义服务常量
  public static final String DEMO_SERVICE = "demo";

(4). 在frameworks/base/core/java/android/app/SystemServiceRegistry.java中,参照其它系统服务注册demo_service

(5). 在frameworks/base/services/java/com/android/server/SystemServer.java中,启动DemoService,添加到service_manager进行管理。

(6). 最后一步,参考其它系统服务,实现DemoManager、DemoService,并定义如IDemoService等等的AIDL接口。

情景: 一个native service 通过init 创建一个socket 并绑定在 /dev/socket/demo, 并且允许某些process 访问.

(1). 在file.te中定义socket 的类型
  type demo_socket, file_type;

(2). 在file_contexts中绑定socket 的类型
  /dev/socket/demo_socket u:object_r:demo_socket:s0

(3). 允许所有的process 访问,使用宏unix_socket_connect(clientdomain, socket, serverdomain)
  unix_socket_connect(appdomain, demo, demo)

(1). 在device/mediatek/mt6763/sepolicy/basic/non_plat目录下创建一个demo.te。

(2). 在demo.te 中定义demo 类型,init 启动service 时类型转换。并可以根据demo 需要访问的文件以及设备, 定义其它的权限在demo.te 中。
  type demo, domain;
  type demo_exec, exec_type, file_type;
  init_daemon_domain(demo)

(3). 绑定执行档 file_context 类型
  /vendor/bin/demo u:object_r:demo_exec:s0

(4). 创建demo的入口执行档demo_exec、并配置相应的权限。

(1). 将SELinux 调整到Permissive 模式复测
使用eng/userdebug 版本,adb shell setenforce 0 将SELinux 模式调整到Permissive 模式,然后复测。如果还能复现问题,则与SELinux 无关; 如果原本很容易复现, 而Permissive mode 不能再复现, 那么就可能与SELinux相关。

(2). 查看LOG 中是否有标准的SELinux Policy Exception.
在Kernel LOG / Main Log 中查询关键字 "avc: denied" 看看是否有与目标进程相关的SELinux Policy Exception, 并进一步确认这个异常是否与当时的逻辑相关。

一般情况我们在符合Google sepolicy策略及neverallow策略的前提下,根据LOG中的内容,需要什么权限就加什么权限。例如LOG:
2020-03-27 14:11:02.596 1228-1228/com.android.systemui W/FaceIdThread: type=1400 audit(0.0:481): avc: denied { read } for name="als_ps" dev="tmpfs" ino=10279 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:als_ps_device:s0 tclass=chr_file permissive=0

LOG说明如下:

一般我们需要重点关注的是四个:permission、source type、target type、target class

根据这四个就可以配置出的所需要的selinux权限:
   allow [source type] [target type]: [target class] [permission]
例1:
03-27 03:45:22.632 2958 2958 W Camera: type=1400 audit(0.0:314): avc: denied { read } for name="u:object_r:graphics_debug_prop:s0" dev="tmpfs" ino=2649 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:graphics_debug_prop:s0 tclass=file permissive=0

解决方案:
按正常的套公式,应该是这样修改platform_app.te,增加:
  allow platform_app graphics_debug_prop:file r_file_perms;
这里我们利用system/sepolicy/te_macros中定义的宏get_prop:

更多相关的宏定义请参考:system/sepolicy/public/te_macros。
所以最终简化后,修改platform_app.te,增加:
  get_prop(platform_app, graphics_debug_prop)

例2:
03-27 14:11:02.596 1228-1228/com.android.systemui W/BackThread: type=1400 audit(0.0:481): avc: denied { read } for name="als_ps" dev="tmpfs" ino=10279 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:als_ps_device:s0 tclass=chr_file permissive=0

解决方案:
修改platform_app.te增加:
  allow platform_app als_ps_device:chr_file r_file_perms;

(1). 不符合neverallow规则或者修改了neverallow规则
编译报错:
  neverallow check failed at xxx
CTS测试项failed:
  android.cts.security.SELinuxNeverallowRulesTest#testNeverallowRulesXXX
这类问题在android O vendor和system分离之后,尤其容易出现。基本上这类问题都是因为修改或者增加的te配置不符合neverallow规则,导致编译报错。而为了解决编译报错,又修改了neverallow规则,最终在跑CTS时,没法通过相关的测试项。

解决思路:

(2). init进程fork新进程没有做domain切换
CTS测试项failed:
  android.security.cts.SELinuxDomainTest # testInitDomain

解决思路:
fork进程时,参考3.4节中做domain切换。

本文主要参考了MTK-Online的Quick-start中《SELinux 问题快速分析》的内容,感谢原作者们的辛勤付出。另外,结合源码和自身开发实践,增加了一些自身理解和实践内容。

② 【Camera专题】Camera驱动源码全解析_下

1、手把手撸一份驱动 到 点亮 Camera
2、Camera dtsi 完全解析
3、Camera驱动源码全解析上
4、Camera驱动源码全解析下
上篇文章分析了C文件函数的实现,本文继续分析h文件的配置信息。

推荐文章:
MIPI CSI2学习(一):说一说MIPI CSI2
高通camera驱动分析

参照sensor规格书或者咨询fae,配置:

2.1 sensor帧的输出和关闭

sensor以流的方式 输出帧.

2.2 开启sensor 端的group 功能

开启sensor 端的group 功能,将曝光(line),gain等打包,保证在同一帧进去生效

2.3 sensor嵌入式数据

2.4 sensor初始化相关寄存器

2.5 sensor分辨率相关寄存器

以上的sensor寄存器配置一般有fae厂商提供,驱动工程师尽可能的掌握相关寄存器代表的含义。
如控制宽高、帧率、曝光等等寄存器

我们只用到16位,因此
sensor_id_reg_addr = 0x300b,
sensor_id = 0x0D42,

曝光时间以行长为单位; PCLK以Hz为单位;
行长以周期数为单位,帧长以行长数为单位;其中周期数就是频率
T 周期以ms为单位;
f 频率以Hz为单位;
f = 1 / T;

可以参考这篇文章:
camera曝光和帧率_songqiangzmt的博客

比如这里又3个寄存器,每个寄存器是8bit:
max_linecount = 0x ff ff -8

暂时没弄清楚

这里指的是暗电流值,
一般来说 raw8 都是 16, raw10为 16x4=64, raw12 =16x4x4

传感器可以流式传输许多不同的 数据类型(DT)
该数据被包装在不同的流中。 在一个流中,可以有一个或多个不同的DT。 一种 虚拟通道(VC) 分配给每个流。 DT和VC的组合应为唯一,并分配了一个通道ID(CID)。
有关如何指定CID的要求/限制。 当前的MIPI CSI_Rx支持四个VC,每个VC最多可以有四个CID,如下表所示。

传感器可能具有内置的pattern generator。 通过设置专用寄存器,传感器可以将生成的图案输出。

当出现图像异常时,可以使用此功能看看sensor本身输出是否有问题。

binning_factor主要是用来控制拍照亮度跟预览亮度一致的,当然也可以解决预览噪点过大的问题!
3A算法里,曝光时间 snap_exp_time *= (float)(binning_multiplier);

3A源码

赋值源码

关键日志:

CSI :Camera Serial Interface 定义了一个位于处理器和摄像模组之间的高速串行接口

为使CSI_Tx(传感器)和CRI_Rx(设备)正常工作,需要一段时间它们之间需要同步。
此时间在此处设置为计时器时钟滴答数。 它必须介于公式计算的MIN和MAX值之间
MIN [Settle count * T(Timer clock)] > T(HS_SETTLE)_MIN
MAX [Settle count * T(Timer clock)] < T(HS-PREPARE)+T(HS_ZERO) - 4*T(Timer clock)

settle_cnt(即稳定计数)– 必须根据传感器输出特性配置该值,以确保传感器的 PHY
发送器与 MSM 的 PHY 接收器无障碍同步。
对于 28 nm 以及更小的 MSM 芯片,使用以下公式计算稳定计数:
settle_cnt = T(HS_SETTLE)_avg /T(TIMER_CLK),
其中 T(HS_SETTLE)_avg = (T(HS_SETTLE)_min + T(HS_SETTLE)_max) / 2,如传
感器数据表所指示

如果sensor可以直接流式传输HDR帧,该函数才有用。

这里的 rolloff compensations = Lens Shading Correction (LSC)
有些sensor可以自己内部做lsc补偿。rolloff_config就是用了配置sensor的这些信息。

注意:如果你使用了sensor LSC补偿,平台端 lsc补偿就要关闭,否则双倍补偿,可能会造成图片失真。

typedef enum {
SENSOR_DELAY_EXPOSURE, /* delay for exposure /
SENSOR_DELAY_ANALOG_SENSOR_GAIN, / delay for sensor analog gain /
SENSOR_DELAY_DIGITAL_SENSOR_GAIN, / delay for sensor digital gain /
SENSOR_DELAY_ISP_GAIN, / delay for sensor ISP (error) gain*/
SENSOR_DELAY_MAX,
} sensor_delay_type_t;

SENSOR_DELAY_EXPOSURE – Sets the exposure of frame N at frame N + delay
SENSOR_DELAY_ANALOG_SENSOR_GAIN – Sets the analog gain register at frame N + delay
SENSOR_DELAY_DIGITAL_SENSOR_GAIN – Sets the digital gain register at frame N + delay
SENSOR_DELAY_ISP_GAIN – Passes the isp digital gain to the isp mole at frame N + delay

如果出现ae闪烁问题,可以尝试修改延迟,让gain和expose同步。

This is the readout time (in nanoseconds) of the sensor’s analog-to-digital converter. Usually it is
the minimum line time when the sensor is running at the maximum pixel clock.
NOTE: This is the sensor mole’s own information. Refer to the sensor vendor for more information

noise_coeff 小波里用来定义噪声的模板
噪声系数模型: N(x) = sqrt(Sx + O)

这些参数一般由tunning团队修改。

关于角度

注意:
如果 <MountAngle>360</MountAngle>; 这个值配置成360度,那么以dtsi配置的角度为准。

源码:

关于帧率
https://www.cnblogs.com/ZHJEE/p/10351155.html

继续当一名咸鱼( ̄︶ ̄)!

③ (转)java 中的tools.jar和dt.jar分别是干什么的求答案

设置在classpath里是为了让你 import *
web系统都用到tool.jar1.
rt.jar 默认就在 根classloader的加载路径里面 放在claspath是多此一举
不信你可以去掉classpath里面的rt.jar
然后用 java -verbose XXXX 的方式运行一个简单的类 就知道 JVM的系统根Loader的路径里面
不光rt.jar jre\lib下面的大部分jar 都在这个路径里2.
tools.jar 是系统用来编译一个类的时候用到的 也就是javac的时候用到
javac XXX.java
实际上就是运行
java -Calsspath=%JAVA_HOME%\lib\tools.jar xx.xxx.Main XXX.java
javac就是对上面命令的封装 所以tools.jar 也不用加到classpath里面3.
dt.jar是关于运行环境的类库,主要是swing的包 你要用到swing时最好加上Sun的Java文档中是这么说的

④ 1..为什么java程序,环境变量classpath中 tools.jar dt.jar是必须

1:
dt.jar和tools.jar是两个java最基本的包,里面包含了从java最重要的lang包到各种高级功能如可视化的swing包,是java必不可少的。
rt.jar是JAVA基础类库,dt.jar是关于运行环境的类库,tools.jar是工具类库
设置在classpath里是为了让你 import *
这三个jar最基本也是最常用的,包含了大部分能用到的,如果你能非要用其他的,那么也要在这里面设置
2:
如果用IDE,那么就不需要设置classpath,设置path都不需要(eclipse需要配置eclipse.ini),java_home是虚设,在Windows-Preferences-Java-->Installed JRES,配置你的jdk目录,IDE会自动找到你项目的编辑命令和类库(path和classpath)

3:

class文件运行当然需要lib支持,可以最简单的

public class HelloWorld{
public static void main(String args[]){
System.out.print("Test File");
}
}
d:\>javac HelloWorld.java
d:\>
d:\>java -classpath ./junit.jar HelloWorld //重新指定类库
错误: 找不到或无法加载主类 HelloWorld
d:>

⑤ 怎么在github上编译 apache zeppelin

用于做数据分析和可视化

一、二进制安装

1)下载二进制包

wget http://mirrors.tuna.tsinghua.e.cn/apache/incubator/zeppelin/0.5.6-incubating/zeppelin-0.5.6-incubating-bin-all.tgz

2)解压缩

tar -xzvf zeppelin-0.5.6-incubating-bin-all.tgz

cd zeppelin-0.5.6-incubating-bin-all

bin/zeppelin-daemon.sh start

注:默认端口是8080,若此端口被占用,到conf下

cp zeppelin-site.xml.template zeppelin-site.xml

vim zeppelin-site.xml

<property>

<name>zeppelin.server.addr</name>

<value>172.16.1.29</value>

<description>Server address</description>

</property>

<property>

<name>zeppelin.server.port</name>

<value>8080</value>

<description>Server port.</description>

</property>

修改zeppelin.server.port端口,zeppelin.server.addr默认是0.0.0.0可以不修改,也可以修改成本机ip(云服务器一定要ip addr看一下本机的ip,而不是绑定的外网ip),java版本1.7。

访问Zeppelin

localhost:8080 访问到zepplin主页。

注:1.主界面默认端口为8080,若此端口被占用,则启动会出错。可以到conf目录下

[root@public_view_databank conf]# cp zeppelin-site.xml.template zeppelin-site.xml

修改其中的参数

<property>

<name>zeppelin.server.addr</name>

<value>0.0.0.0</value>

<description>Server address</description>

</property>

<property>

<name>zeppelin.server.port</name>

<value>9090</value>

<description>Server port.</description>

</property>

修改zeppelin.server.port

Zeppelin.server.addr可以默认0.0.0.0也可以修改成本地ip

二、源码安装

1)下载源码包
Zeppelin 0.5.6-incubating:
wget http://mirror.bit.e.cn/apache/incubator/zeppelin/0.5.6-incubating/zeppelin-0.5.6-incubating.tgz
Zeppelin 0.6.0-SNAPSHOT:
git clone https://github.com/apache/zeppelin.git
2)配置环境
# Requirements
+ Git
+ Java 1.7
+ Tested on Mac OSX, Ubuntu 14.X, CentOS 6.X, Windows 7 Pro SP1
+ Maven (if you want to build from the source code)
+ Node.js Package Manager (npm, downloaded by Maven ring build phase)
# 编译环境构建
## git install
[root@gitlab-machine ~]# git version
git version 1.7.1

## install jdk
[root@gitlab-machine~]#wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz

[root@gitlab-machine ~]# tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/

[root@gitlab-machine ~]# cd /opt/

[root@gitlab-machine opt]# ln -s jdk1.7.0_79 jdk

[root@gitlab-machine opt]# vim ~/.bash_profile 追加
export JAVA_HOME=/opt/jdk

export PATH=.:$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

[root@gitlab-machine opt]# source ~/.bash_profile
[root@gitlab-machine opt]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

## install maven
[root@gitlab-machineopt]#wget http://www.eu.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz

[root@gitlab-machine opt]# tar -zxf apache-maven-3.3.3-bin.tar.gz

[root@gitlab-machine opt]# ln -s apache-maven-3.3.3 maven

[root@gitlab-machine opt]# echo "export MAVEN_HOME=/opt/maven" >> ~/.bash_profile

[root@gitlab-machineopt]# echo "export PATH=$MAVEN_HOME/bin:$PATH:$HOME/bin" >> ~/.bash_profile

[root@gitlab-machine opt]# source ~/.bash_profile
[root@gitlab-machine opt]# mvn -version
Apache Maven 3.3.3 (; 2015-04-22T19:57:37+08:00)
Maven home: /opt/maven
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /opt/jdk1.7.0_79/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-504.el6.x86_64", arch: "amd64", family: "unix"

## install node.js

yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum repolist

[root@gitlab-machine opt]# yum search nodejs npm|wc -l
21

[root@gitlab-machine opt]# sudo yum install nodejs npm --enablerepo=epel

[root@gitlab-machine opt]# node -v
v0.10.42

[root@gitlab-machine opt]# npm -v
1.3.6

[root@gitlab-machine opt]# cd /data/

## build zeppline
[root@gitlab-machine opt]# cd /data/

[root@gitlab-machinedata]#wget https://github.com/apache/zeppelin/archive/v0.5.6.zip
[root@gitlab-machine data]# unzip v0.5.6.zip
[root@gitlab-machine data]# cd zeppelin-0.5.6/
[root@gitlab-machine
zeppelin-0.5.6]# nohup mvn clean package -Pspark-1.6 -Phadoop-2.6
-Pyarn -Ppyspark -DskipTests > nohup.out &
[root@gitlab-machine zeppelin-0.5.6]# jobs
[1]+ Running nohup mvn clean package -Pspark-1.6 -Phadoop-2.6 -Pyarn -Ppyspark -DskipTests > nohup.out &

参考地址:https://github.com/apache/zeppelin/

[root@gitlab-machine zeppelin-0.5.6]# tail -f nohup.out

1.Exception in thread "main" Exception: java.lang.OutOfMemoryError thrown
解决办法:
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
2.[INFO] Zeppelin: Elasticsearch interpreter ................ SUCCESS [15:56 min]
[INFO] Zeppelin: web Application .......................... FAILURE [03:51 min]
[INFO] Zeppelin: Server ................................... SKIPPED
[INFO] Zeppelin: Packaging distribution ................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20:57 min
[INFO] Finished at: 2016-06-08T02:19:40-04:00
[INFO] Final Memory: 93M/957M
[INFO] ------------------------------------------------------------------------
[ERROR]
Failed to execute goal
com.github.eirslett:frontend-maven-plugin:0.0.23:npm (npm install) on
project zeppelin-web: Failed to run task: 'npm install --color=false'
failed. (error code 126) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :zeppelin-web

网上查找修改zeppelin-web下的pom.xml
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>

<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>--allow-root install</arguments>
</configuration>
</execution>

<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>--no-color --force</arguments>
</configuration>
</execution>

</executions>
</plugin>
[root@host-172-16-1-80 zeppelin-web]# npm install
[root@host-172-16-1-80 zeppelin-web]# bower –alow-root install
[root@host-172-16-1-80 zeppelin-web]# grunt –force
[root@host-172-16-1-80 zeppelin-web]# mvn install -DskipTests
启动zeppelin
[root@bigdata-redhadoop-1 src]# cd zeppelin-0.5.6-incubating
[root@bigdata-redhadoop-1 zeppelin-0.5.6-incubating]# bin/zeppelin-daemon.sh start
Log dir doesn't exist, create /opt/bigcrh/zeppelin/src/zeppelin-0.5.6-incubating/logs
Pid dir doesn't exist, create /opt/bigcrh/zeppelin/src/zeppelin-0.5.6-incubating/run
Zeppelin start [ OK ]

[root@public_view_databank ~]# jps
18710 ZeppelinServer

阅读全文

与dt编译vendor相关的资料

热点内容
单片机程序员培训 浏览:990
PHP商城源代码csdn 浏览:634
怎么把电脑里文件夹挪出来 浏览:693
java流程处理 浏览:685
ftp创建本地文件夹 浏览:659
腰椎第一节压缩 浏览:738
xp去掉加密属性 浏览:117
2345怎么压缩文件 浏览:982
迷你夺宝新算法 浏览:407
服务器如何防止木马控制 浏览:715
压缩空气用电磁阀 浏览:742
微信为什么不能设置加密认证 浏览:672
邓伦参加密室逃脱视频 浏览:391
音频压缩编码标准 浏览:300
常提到的app是表示什么 浏览:261
天津程序员传销 浏览:349
下班之后的程序员 浏览:73
检测支持ssl加密算法 浏览:344
衢州发布新闻什么APP 浏览:85
中国移动长沙dns服务器地址 浏览:253