设为首页 收藏本站
查看: 3031|回复: 0

[经验分享] thrift+scribe安装+hadoop

[复制链接]

尚未签到

发表于 2015-11-28 17:32:59 | 显示全部楼层 |阅读模式
  需要
  libevent,libevent-devel,boost,python,python-devel
  boost一定要1.45的
  下载  thrift0.7.0 scribe-2.2装不上,直接下载最新的scribe代码
  先安装thrift
  

./configure  --enable-gen-php --with-cpp  --with-php    --with-boost  --with-libevent --enable-gen-cpp
make && make install
  
  zend_std_get_constructor错误如果报
  是因为php版本问题,改成5.3.8就没事了
  报php.h没找到的错
  因为php安装目录不在/usr/include/php
  

ln -s /usr/web_soft/php/include/php /usr/include/php

就行了  
  然后安装fb303就在thrift的contrib下
  如果./bootstrap.sh 没有执行权限,要加上
  

chmod +x bootstrap.sh./bootstrap.sh会生成configure文件  
  

./configure --with-thriftpath=/usr/local/ make && make install需要指定 thrift安装目录,即使是默认安装/usr/local也要指定  编译php 的c语言扩展,提高处理效率
  在thrift-0.7.0/lib/php/src/ext/thrift_protocol/这里


  


  安装scribe
  ./bootstrap.sh出现boostlib的错误提示不用管,只需要生成configure
  make时候提示
  error:   overriding ‘virtual scribe::thrift::ResultCode::type scribe::thrift::scribeIf::Log(


  boost版本不对,一定要1.45的,删掉原来的boost目录,重新安装
  或者使用pcting版本
  https://github.com/pcting/scribe



./configure --with-thriftpath=/usr/local/ --with-fb303path=/usr/local/



编译时候目录只能指定到这里,他自己会去匹配/usr/local/bin/thrift文件
如果报错找不到 lthriftnb 重新安装一次thrift就好了,我这是这样的
如果要使用hdfs,就加上这些
--enable-hdfs --with-hadooppath=/usr/web_soft/hadoop/ CPPFLAGS="-I/usr/web_soft/hadoop/src/c++/libhdfs -I/usr/java/jdk1.6.0_25/include/ -I/usr/java/jdk1.6.0_25/include/linux/"  启动时候如果
  error while loading shared libraries xxx.so
  表示找不到相关so文件
  找到这个so文件存放路径
  在/etc/ld.so.conf.d/xxx.conf中加入xxx.so所在的目录
  /sbin/ldconfig –v生效
  
  php使用:
  生成php文件
  /usr/local/bin/thrift -o ./php_code -I /usr/local/share/ --gen php /usr/local/share/fb303/if/fb303.thrift

/usr/local/bin/thrift -o  ./php_code -I /usr/local/share/ --gen php /source/to/scribe/if/scribe.thrift
  cp thrift的php文件
  cp /source/to/thrift/lib/php/src  ./php_code  -r
  


  把目录设置成
  
  Lib/Thrift
  ├── packages
  │   ├── fb303
  │   │   ├── FacebookService.php
  │   │   └── fb303_types.php
  │   └── scribe
  │       └── scribe_types.php
  ├── protocol
  │   ├── TBinaryProtocol.php
  │   ├── TBinarySerializer.php
  │   └── TProtocol.php
  ├── scribe.php
  ├── server
  │   ├── TServer.php
  │   └── TSimpleServer.php
  ├── Thrift.php
  └── transport
  ├── TBufferedTransport.php
  ├── TFramedTransport.php
  ├── THttpClient.php
  ├── TMemoryBuffer.php
  ├── TNullTransport.php
  ├── TPhpStream.php
  ├── TServerSocket.php
  ├── TServerTransport.php
  ├── TSocket.php
  ├── TSocketPool.php
  ├── TTransportFactory.php
  └── TTransport.php

建packages目录,放fb303和scribe/scribe_types.php
然后:
<?php

$GLOBALS['THRIFT_ROOT'] = './includes';



include_once $GLOBALS['THRIFT_ROOT'] . '/scribe.php';

include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';

include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TFramedTransport.php';

include_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';



$msg1['category'] = 'keyword';

$msg1['message'] = &quot;This is some message for the category/n&quot;;

$msg2['category'] = 'keyword';

$msg2['message'] = &quot;Some other message for the category/n&quot;;

$entry1 = new LogEntry($msg1);

$entry2 = new LogEntry($msg2);

$messages = array($entry1, $entry2);



$socket = new TSocket('localhost', 1463, true);

$transport = new TFramedTransport($socket);

$protocol = new TBinaryProtocol($transport, false, false);

$scribe_client = new scribeClient($protocol, $protocol);



$transport->open();

$scribe_client->Log($messages);

$transport->close();
现在可以多个scribe client日志,存储到一个scribe center了
client配置
port=1464
max_msg_per_second=2000000
check_interval=3

# DEFAULT - forward all messages to Scribe on port 1463
<store>
category=default
type=buffer
target_write_size=20480
max_write_interval=1
buffer_send_rate=1
retry_interval=30
retry_interval_range=10
<primary>
type=network
remote_host=xxx.xxx.xxx.xxx
remote_port=1463
</primary>
<secondary>
type=file
fs_type=std
file_path=/path/scribe
base_filename=scribe_tmp_file
max_size=1073741824
</secondary>
</store>
center配置
port=1463
max_msg_per_second=2000000
check_interval=3
<store>
category=default
type=buffer
target_write_size=20480
max_write_interval=1
buffer_send_rate=2
retry_interval=30
retry_interval_range=10
<primary>
type=file
fs_type=std
file_path=/tmp/scribetest
base_filename=thisisoverwritten
max_size=100000000
</primary>
<secondary>
type=file
fs_type=std
file_path=/tmp
base_filename=thisisoverwritten
max_size=3000000
</secondary>
</store>









装hadoop
直接下载解压,配置文件参考
http://hadoop.apache.org/common/docs/r0.20.0/quickstart.html#PseudoDistributed
按网上教程配置hadoop
1.conf/core-site.xml
<configuration>
<property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:8000</value>
  </property>
</configuration>
2.conf/hdfs-site.xml
<configuration>
<property>
    <name>dfs.replication</name>
    <value>1</value>
  </property>
</configuration>
3.conf/mapred-site.xml
<configuration>
<property>
    <name>mapred.job.tracker</name>
    <value>localhost:8001</value>
  </property>
</configuration>
启动
bin/start-all.sh  如果报权限错误
  
  error: org.apache.hadoop.security.AccessControlException: Permission denied: user=root, access=WRITE, inode=&quot;&quot;:hadoop:supergroup:rwxr-xr-x
  org.apache.hadoop.security.AccessControlException: Permission denied: user=root, access=WRITE, inode=&quot;&quot;:hadoop:supergroup:rwxr-xr-x

conf/hdfs-site.xml里加上  
  

<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
操作命令:
http://hadoop.apache.org/common/docs/r0.18.2/cn/hdfs_shell.html#cat
转::
有的时候, datanode或者tasktracker crash,或者需要向集群中增加新的机器时又不能重启集群。下面方法也许对你有用。

1.把新机器的增加到conf/slaves文件中(datanode或者tasktracker crash则可跳过)

2.在新机器上进入hadoop安装目录

  $bin/hadoop-daemon.sh start datanode

  $bin/hadoop-daemon.sh start tasktracker

3.在namenode上

  $bin/hadoop balancer  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-144457-1-1.html 上篇帖子: Python easy_install 遇到“ImportError: No module named pkg_resources”错误 下篇帖子: [4] Scribe使用例子3
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表