start_udev导致监听自动停止问题处理

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.3 and later
Linux x86-64

SYMPTOMS

Dynamically added new disks to storage using udev rules(as per the docs note 414897.1, 1528148.1, 371814.1 etc).

During start_udev, udev has deleted the public network interface and this caused the listener to crash, and clusterware moved all services, scan listeners and the VIP on node 1 to node 2.

CHANGES

 Trying to add disk to storage using udev

CAUSE

 udev has deleted the public network interface.

SOLUTION

As per RHEL you are advised to set HOTPLUG="no" for the network configuration scripts.

Add HOTPLUG="no" to the ifcfg-eth0 (public), ifcfg-eth1 (private) and ifcfg-eth2 (backup) network config files in /etc/sysconfig/network-scripts directory.

REFERENCES

NOTE:1528148.1  - How To Setup Partitioned Linux Block Devices Using UDEV (Non-ASMLIB) And Assign Them To ASM?
NOTE:414897.1  - How To Setup UDEV Rules For RAC OCR And Voting Devices On SLES10, RHEL5, OEL5, OL5

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28612416/viewspace-2120003/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28612416/viewspace-2120003/

在Linux下使用系统API(如libudev库)来打印USB设备的信息,你需要编写C代码来遍历USB设备列表并获取其信息。以下是一个简单的示例,首先安装必要的库,然后编写和执行代码: 1. 安装`libudev`库(如果未安装): ```sh sudo apt-get install libudev-dev ``` 2. 包含必要的头文件,并链接到`udev.h`和`udev`库: ```c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <udev.h> ``` 3. 初始化UDEV上下文,然后打开USB设备数据库: ```c int main(int argc, char *argv[]) { struct udev *udev; int ret; udev = udev_new(); if (udev == NULL) { perror("udev_new"); return -1; } // 打开设备数据库 ret = udev_monitor_init_from_netlink(udev, "udev"); if (ret < 0) { perror("udev_monitor_init_from_netlink"); goto error; } ``` 4. 创建一个事件处理器函数来处理新连接的USB设备: ```c static void device_add(const char *action, const struct udev_device *device, void *data) { const char *name = udev_device_get_name(device); printf("Detected USB Device: %s\n", name); } ``` 5. 注册事件处理器并开始监听: ```c // 添加事件处理udev_monitor_filter_add_match_subsystem_devtype(udev_monitor_get_monitor(udev), "usb", NULL); // 开始接收事件 ret = udev_monitor_start_watching(udev_monitor_get_monitor(udev)); if (ret < 0) { perror("udev_monitor_start_watching"); goto error; } // 设备添加时调用我们的处理udev_monitor_settle_timeout(udev_monitor_get_monitor(udev), 1000); // 等待1秒 udev_monitor_filter_add_match_action(udev_monitor_get_monitor(udev), "add", device_add, NULL); // ...(其他错误处理) ``` 6. 错误处理和结束: ```c error: if (udev != NULL) { udev_unref(udev); } return ret; } // 编译并执行 gcc -o usbdetection usbdetection.c -ludev -lrt ./usbdetection ``` 这个程序会持续运行,直到你停止它。当你插入或移除USB设备时,它将打印出相应的设备名称。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值