HeartBeat源代码学习

来源:互联网 发布:淘宝提高动态评分 编辑:程序博客网 时间:2024/05/16 08:01

HeartBeat源代码学习

 

用kill(pid,0) >= 0 || errno != ESRCH 可以判断是不是存在个processinit_procinfo--用来保存一个全系统的变量(进程之间用)可以定义一些宏,然后让这些宏由configure指定,就可以定义出程序要用的文件的信息!#ifndef HA_PLUGIN_D#define HA_PLUGIN_DHALIB "/plugins"#endifplugin的处理,用plis libplis lib的使用Provides a general plugin and interface loading library/usr/lib/pils/plugins/InterfaceMgr/generic.soInterfaceMgr/generic.c--用来定义load interface。。。???可以连续的杀进程if (CL_KILL((pid_t)running_hb_pid, SIGTERM) >= 0) {/* Wait for the running heartbeat to die */alarm(0);do {sleep(1);continue;}while (CL_KILL((pid_t)running_hb_pid, 0) >= 0);cleanexit(LSB_EXIT_OK);}init_config???initialize_heartbeat创建fifo register fifo    pipe status_pipeOpen all our heartbeat channels(???)--建立与一些so的通讯pathhb_mediawrite_childread_childReads hb channel (tty, UDP, etc)copying to master status pipe For ttys ONLY:copying to tty write pipes (incrementing hop count andfiltering out "ring wraparounds")master_status_process用来记录child的信息(serial,udp。。。)clustermsg_input_dispatchprocess_clustermsg--Process a message coming in from our status FIFO(从Control process或者child)APIregistration_input_dispatchprocess_registermsghb_send_local_statussend_local_statushb_dump_all_proc_statsapi_audit_clientsGmain_hb_signal_process_pendinghb_signal_process_pendingMaster Status process: Reads master status pipe(从Control process)forks children, etc. to deal with status changescontrol_processControl process:Reads a control fifo for input Writes master status pipe Writes heartbeat channel pipeshb_rsc_recover_dead_resources--Node 'hip' has died.    Take over its resources (if any)  This may mean we have to STONITH them.tips:可以在加参数-d来增加调试heartbeat是用来保证集群调度器的死活mon是用来保证后面的东西的死活Heartbeat runs on both machines, but Apache and Mon is only running on the active onemon的alert把heartbeat停止,就可以换了 
原创粉丝点击