internal create-md' terminated with exit code 20 - DRBD - high-availability

I am doing database replication with DRBD. Using different ips for pacemaker, corosync & Drbd traffic.Created one partition (vdc1). I am not able to setup DRBD. It's giving below error-
Command 'drbdmeta 0 v08 /dev/vdc1 internal create-md' terminated with exit code 20
I am not getting what's the issue. Help me in resolving this issue
$ sudo drbdadm create-md clusterdb
read from drbdsetup
: Success
read from drbdsetup
: Success
Command 'drbdmeta 0 v08 /dev/vdc1 internal create-md' terminated with exit code 20
/etc/hosts -
172.0.3.30 app3_pcmk
172.0.3.40 app4_pcmk
172.0.5.30 app3_drbd
172.0.5.30 app4_drbd
172.0.3.9 app4
172.0.3.8 app3
/etc/drbd.d/clusterdb.res
resource clusterdb
{
protocol C;
startup {
wfc-timeout 30;
outdated-wfc-timeout 20;
degr-wfc-timeout 30;
}
net {
cram-hmac-alg sha1;
shared-secret sync_disk;
after-sb-0pri discard-zero-changes;
after-sb-1pri discard-secondary;
after-sb-2pri disconnect;
}
syncer {
rate 10M;
al-extents 257;
on-no-data-accessible io-error;
}
on app3 {
device /dev/drbd0;
disk /dev/vdc1;
address 172.0.3.8:7788;
flexible-meta-disk internal;
}
on app4 {
device /dev/drbd0;
disk /dev/vdc1;
address 172.0.3.9:7788;
meta-disk internal;
}
}

Related

FTP Arduino issue with ESP8266

Trying to do FTP with my router from an ESP8266 WiFi-board and using the Arduino-IDE, I keep getting the following error message:
331 Password required for anonymous.
My code looks like this:
if (client.connect(server, 21)) { // 21 = FTP server
Serial.println(F("Command connected FIRST TIME"));
} else {
Serial.println(F("Command connection failed FIRST TIME"));
}
eRcv();
Serial.println("OUTPUT BUFFER 1");
Serial.println(outBuf);
client.println(F("USER anonymous"));
eRcv();
Serial.println("OUTPUT BUFFER 2");
Serial.println(outBuf);
client.println(F("PASS anonymous"));
eRcv();
Serial.println("OUTPUT BUFFER 3");
Serial.println(outBuf);
client.println(F("SYST"));
eRcv();
Serial.println("OUTPUT BUFFER 4");
Serial.println(outBuf);
client.println(F("Type I"));
eRcv();
My log looks like that:
WiFi connected; IP address: 192.168.178.33
Command connected FIRST TIME
OUTPUT BUFFER 1
220 FRITZ!Box7490 FTP server ready.
OUTPUT BUFFER 2
331 Password required for anonymous.
As you can see, the error message I receive (i.e. err 331) happens already at cmd nr 2 (i.e. "PASS anonymous2).
The router is set to accept an anonymous FTP (that should not be the problem). The router, of course, is set to allow FTP.
I read something about a "passive mode" (client.println(F("PASV"));) but it seems to me that the "PASS anonymous" should go through independent of PASV-mode ore not. Is this correct ?
Are there any other suggestions of what to do here ?
Much appreciated!
P.S. For completion, the FTP-receive (delivering the "outBuf" from the example-code above) looks like this:
//-------------- FTP receive
byte eRcv() {
byte respCode;
byte thisByte;
long StartTimeoutTime = millis();
while (!client.available() && (millis() - StartTimeoutTime < 1000))
{ // wait for answer with 1 second timeout
delay(1);
}
if (millis() - StartTimeoutTime >= 1000)
{
efail();
return 0;
}
respCode = client.peek();
outCount = 0;
while (client.available()) {
thisByte = client.read();
//Serial.write(thisByte);
if (outCount < 127) {
outBuf[outCount] = thisByte;
outCount++;
outBuf[outCount] = 0;
}
}
if (respCode >= '4') {
efail();
return 0;
}
return 1;
} // eRcv()
Anonymous authentication with FTP still requires that you send a username and a password. Traditionally the username is anonymous and an email address is used as a password. Something like user#test.com works fine. Here is a link to RFC 959, File Transfer Protocol.
From here it looks like you might not be waiting long enough for the server to send the 220 message before you send the USER. After you connect, wait for the server to finish sending its welcome message. Then send your USER, wait for the 331, then send your PASS. The server might also be sending multiple strings for the first message. Try logging into the FTP server with the commandline client for your o/s and see exactly what it's sending you, and adjust your code for that.

How to add Multicast Group under a specific interface (Windows)

I can use the command "netsh interface ip show joins" in cmd to show multicast group under each interface. But I really don't know how to add a group to a
interface, like adding a IP address 239.39.188.188 to "Interface 8: VirtualBox Host-Only Network". The simplest way would be appreciated.
Interface 3: Ethernet
Scope References Last Address
---------- ---------- ---- ---------------------
0 0 Yes 224.0.0.1
Interface 1: Loopback Interface
Scope References Last Address
---------- ---------- ---- ---------------------
0 2 Yes 239.255.255.250
Interface 8: VirtualBox Host-Only Network
Scope References Last Address
---------- ---------- ---- ---------------------
0 0 Yes 224.0.0.1
0 1 Yes 224.0.0.251
239.39.188.188 // this is what I want to add
Btw, I tried with some methods, like opening UDP socket and setting IP_ADD_MEMBERSHIP (How to add my host to Multicast Group...!). Also, I tried with a command on linux "ip maddr [ add | del ] MULTIADDR dev STRING".
After that, I observed that IP_ADD_MEMBERSHIP was set successfully. But as the result, in the above table, I cannot add a group under a specific interface.
For opening UDP socket and setting IP_ADD_MEMBERSHIP part, I coded in linux as belows.
ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(_outIP.c_str()); // _outIP is destination address(group address), interface is ethernet interface
mreq.imr_interface.s_addr = _interface.length() > 0 ? inet_addr(_interface.c_str()) : htonl(INADDR_ANY);
if (setsockopt(_udpSock,IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq)) == -1) {
cout << "Fail to add ip membership!!!!" << endl;
}
else {
cout << "Success to add ip membership!!!!" << endl;
s = sprintf(warnmsg, "Success to add ip membership!!!!");
_ofile->write(warnmsg, s);
}
You must keep the socket with which you joined the group open forever. In other words, your program must not terminate. Add a for (;;) { sleep(1000000); } or so at the end.
When you program terminates, the socket gets closed automatically and your OS (Windows or Linux, it does not matter) leaves the group again.
What happens in the OS is slightly more complex as multiple programs may join the same multicast group, so the OS keeps a reference count and the machine only leaves the group when the group is no longer references by any socket.

dtrace OS X thread name

I'm trying to get the thread name in a dtrace script on OS X.
The script should record the context switches of threads in my application.
#!/usr/sbin/dtrace -s
#pragma D option quiet
BEGIN
{
printf("Start dtrace script: time %ul\n\n", walltimestamp);
}
proc:::exec-success
/ execname == "MyApplication" /
{
trace(execname);
}
sched:::off-cpu
/ execname == "MyApplication" /
{
printf("tid: %ul (%s), off-cpu at: %ul\n", tid, curthread->td_name, walltimestamp);
}
sched:::on-cpu
/ execname == "MyApplication" /
{
printf("tid: %ul, on-cpu at: %ul\n", tid, walltimestamp);
}
But I get the error:
dtrace: failed to compile script dtrace_test.d: line 20: td_name is not a member of struct thread
How can I get the name of the thread?
or analysis I also tried to get the generated intermediate code for my dtrace script (with -S).
sudo dtrace -s ./dtrace_test.d
But I get the same error:
dtrace: failed to compile script dtrace_test.d: line 20: td_name is not a member of struct thread
I also couldn't find the name in the thread struct here: http://www.opensource.apple.com/source/xnu/xnu-2050.9.2/osfmk/kern/thread.h
Thx

For the un-finished 3-way TCP handshake, why the windows OS report the FD_ACCEPT event to the application

Test Scenario
I had written a windows program which I simply called it "simpleServer.exe". This program is just a simulation of a very basic server application. It listens on a port, and wait for incoming messages. The listening Socket was defined to be a TCP Stream Socket. that's all that this program is doing.
I had been deploying this exact same program on 2 different machines, both running on windows 7 professional 64bit. This machine will act as a host. and they are stationed in the same network area.
then, using the program "nmap", I used another machine on the same network, to act as a client. using the "-sS" parameter on "nmap", I do a Syn Scan, to the IP and Port of the listening simpleServer on both machine (one attempt at a time).
(note that the 2 hosts already had "wireshark" started, and is monitoring on tcp packets from the client's IP and to the listening port.)
In the "wireshark" entry, on both machine, I saw the expected tcp packet for Syn Scan:
client ----(SYN)----> host
client <--(SYN/ACK)-- host
client ----(RST)----> host
the above packet exchange suggests that the connection was not established.
But on the "simpleServer.exe", only one of it had "new incoming connection" printed in the logs, while the other instance was not alerted of any new incoming connection, hence no logs at all.
Code Snippets
iRetVal = WSAEventSelect (m_Socket, m_hSocketEvent, FD_ACCEPT);
if (SOCKET_ERROR == iRetVal)
{
if (WSAGetLastError()==WSAENOTSOCK)
{
return E_SOCKET_INVALID;
}
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() Error while WSAEventSelect(). Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error while WSAEventSelect(). Error code: %ld\n", WSAGetLastError() );
#endif
return E_FAILED_RECV_DATA;
}
// Wait for Network Events to occcur
dwRetVal = WSAWaitForMultipleEvents ( 1,
&m_hSocketEvent,
FALSE,
lTimeout,
TRUE);
if ( WSA_WAIT_TIMEOUT == dwRetVal )
{
return E_TIMEOUT;
goto CleanUp;
}
if ( WSA_WAIT_FAILED == dwRetVal)
{
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() WSAWaitForMultipleEvents() failed. Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error in WSAWaitForMultipleEvents() failed. Error code: %ld\n", WSAGetLastError() );
#endif
dwReturn = E_FAILED_RECV_DATA;
goto CleanUp;
}
// Parse the Results from the Network Events.
iRetVal = WSAEnumNetworkEvents (m_Socket, m_hSocketEvent, &mEvents);
if (SOCKET_ERROR == iRetVal)
{
CHKLOGGER (m_pLogger->Log (LOGGER_LOG_ERROR,"GHLSocket::OnAccept() Error while WSAEnumNetworkEvents(). Error code: ", WSAGetLastError() ));
#if defined GHLSOCKET_DEBUG_VERSION
printf ("Error while WSAEnumNetworkEvents(). Error code: %ld\n", WSAGetLastError() );
#endif
dwReturn = E_FAILED_RECV_DATA;
goto CleanUp;
}
// ACCEPT event Detected.
if (mEvents.lNetworkEvents & FD_ACCEPT)
{
// Perform accept operation.
*p_SOCKET = accept (m_Socket, NULL,NULL);
}
Help That I Needed
why is the different behavior from the 2 same of the same application on a different machine with the same OS?

kernel module's reference count

I have a module to maintain, and it appears it has issues with reference counter being kept in the kernel, which results in that I'm unable to rmmod my module, after I kill the daemon opening 3 raw sockets to the module. Interestingly, after loading the daemon 'lsmod' displays 6 references to the module exist, I'd expect only three.
This is occuring on ARM-based embedded system with Linux-2.6.31, and rmmod doesn't have 'force' mode to try enforce unload a module (it's anyway not good idea).
I've analyzed the code and here is what I have:
1) The module creates new socket address family AF_HSL and registers with the kernel:
static struct proto_ops SOCKOPS_WRAPPED (hsl_ops) = {
family: AF_HSL,
owner: THIS_MODULE,
release: hsl_sock_release,
bind: _hsl_sock_bind,
connect: sock_no_connect,
socketpair: sock_no_socketpair,
accept: sock_no_accept,
getname: _hsl_sock_getname,
poll: datagram_poll,
ioctl: sock_no_ioctl,
listen: sock_no_listen,
shutdown: sock_no_shutdown,
setsockopt: sock_no_setsockopt,
getsockopt: sock_no_getsockopt,
sendmsg: _hsl_sock_sendmsg,
recvmsg: _hsl_sock_recvmsg,
mmap: sock_no_mmap,
sendpage: sock_no_sendpage,
};
static struct net_proto_family hsl_family_ops = {
family: AF_HSL,
create: _hsl_sock_create,
owner: THIS_MODULE
};
...
static int
_hsl_sock_create (struct net *net, struct socket *sock, int protocol)
{
struct sock *sk = NULL;
sock->state = SS_UNCONNECTED;
sk = sk_alloc (current->nsproxy->net_ns, AF_HSL, GFP_KERNEL, &_prot);
if (sk == NULL)
goto ERR;
sock->ops = &SOCKOPS_WRAPPED(hsl_ops);
sock_init_data (sock,sk);
sock_hold (sk); /* XXX */
...
}
static void
_hsl_sock_destruct (struct sock *sk)
{
struct hsl_sock *hsk, *phsk;
if (!sk)
return;
...
sock_orphan (sk);
skb_queue_purge (&sk->sk_receive_queue);
sock_put (sk);
}
int
hsl_sock_release (struct socket *sock)
{
struct sock *sk = sock->sk;
/* Here goes logic to destroy net_devices */
...
_hsl_sock_destruct (sk);
sock->sk = NULL;
return 0;
}
2) the daemon creates sockets in such way
fd = socket(AF_HSL, SOCK_RAW, 0);;
bind();
getsockname();
However I don't think _hsl_sock_create() should be calling sock_hold(), that would bump socket's reference count, but it's already set to 1 by sock_init_data(), and at socket delete phase sock_put() would decrement by 1, however this would not have the socket free;d and completely removed from the system.
So I experimented and removed sock_hold(); Now killing daemon yields in all references removed and 'rmmod' succedes, however the number of references after starting daemon is still 3.
I also have checked code at socket_create() whick calls internal function __socket_create(), which in turn calls try_module_get() and holds module's reference count. This appears to be the only place I've found that explicitly increments the module's refcnt.
I am still confused. Would anyone try to help understand what is happening?
Looking forward to hearing from you.
Mark

Resources