show dbs Error: [js] uncaught exception: Error: listDatabases failed

When mongo is built with replica set cluster.
If you log into one of the SECONDARY nodes and execute the command show dbs, you will get an error:

2022-08-16T15:20:00.606+0800 E  QUERY    [js] uncaught exception: Error: listDatabases failed:{
    "operationTime" : Timestamp(1660634399, 2),
    "ok" : 0,
    "errmsg" : "not master and slaveOk=false",
    "code" : 13435,
    "codeName" : "NotMasterNoSlaveOk",
    "$clusterTime" : {
        "clusterTime" : Timestamp(1660634399, 2),
        "signature" : {
            "hash" : BinData(0,"NPF356c5NKl0PqHLlmiQ9vey9e4="),
            "keyId" : NumberLong("7101680539345616897")
        }
    }
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:147:19
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:99:12
shellHelper.show@src/mongo/shell/utils.js:906:13
shellHelper@src/mongo/shell/utils.js:790:15
@(shellhelp2):1:1

 

This is because the SECONDARY node does not have the permission to execute the show dbs command.
In this case, there are two solutions
1. Login to the PRIMARY node
2. Use the cluster connection method
mongo –host  testmongo/ip:port,ip:port,ip:port -uusername -p’passwd’ –authenticationDatabase admin

Python+Selenium Error: AttributeError: ‘WebDriver‘ NameError: name ‘By‘ is not defined

python 3.10.1

selenium 4.4.3

Old version Package:

from selenium import webdriver

New version Package:

from selenium import webdriver
from selenium.webdriver.common.by import By

You need to import one more, otherwise the ‘By’ will report an error

Positioning statement

drive.find_element(By.NAME,"username").send_keys("astudy")

[Solved] Virtual machine Failed to restart network Error: Error:Failed to start LSB: Bring up/down networking

Problem description

A virtual machine that has been running normally. After a shutdown and restart, it is found that SSH cannot connect

Restart network discovery failed

service networkrestart

Solution:

[root@lexsaints ~]#systemctl stop NetworkManager
[root@lexsaints ~]#systemctl disable NetworkManager
[root@lexsaints ~]#systemctl restart  network
or
[root@lexsaints ~]#systemctl  restart NetworkManager
[root@lexsaints ~]#systemctl restart  network

Cause of problem

NetworkManager is a program that detects the network and automatically connects to the network.

Whether it’s wireless or wired, it makes it easy for you to manage.

For wireless networks, the network manager can automatically switch to the most reliable wireless network.

The program using the network manager can freely switch between online and offline modes.

The network manager can preferentially select wired network and support VPN.

The network manager was originally developed by RedHat and is now managed by gnome.

[Solved] error indicates that your module has parameters that were not used in producing loss

Error Messages:
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel, and by
making sure all forward function outputs participate in calculating loss.
If you already have done the above, then the distributed data parallel module wasn’t able to locate the output tensors in the return value of your module’s forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).
Parameter indices which did not receive grad for rank 0: 160 161 182 183 204 205 230 231 252 253 274 275 330 331 414 415 438 439 462 463 486 487 512 513 536 537 560 561 584 585
In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error

Solution:

Original Code

 class AttentionBlock(nn.Module):
    def __init__(
        self,
    ):
        super().__init__()
        self.encoder_kv = conv_nd(1, 512, channels * 2, 1) #这行没有注释掉
        self.encoder_qkv = conv_nd(1, 512, channels * 3, 1)
        self.trans = nn.Linear(resolution*resolution*9+128,resolution*resolution*9)
    def forward(self, x, encoder_out=None):
        b, c, *spatial = x.shape
        x = x.reshape(b, c, -1)
        qkv = self.qkv(self.norm(x))
        if encoder_out is not None:
            # encoder_out = self.encoder_kv(encoder_out)  #这行代码注释了,没有用self.encoder_kv
            encoder_out = self.encoder_qkv(encoder_out)
        return encode_out

Error reason:

self.encoder_kv is written in def__init__, but not used in forward, resulting in an error in torch.nn.parallel.DistributedDataParallel. Correction method

Modified code

class AttentionBlock(nn.Module):
   def __init__(
       self,
   ):
       super().__init__()
       #self.encoder_kv = conv_nd(1, 512, channels * 2, 1) #这行在forward中没有用到注释掉
       self.encoder_qkv = conv_nd(1, 512, channels * 3, 1)
       self.trans = nn.Linear(resolution*resolution*9+128,resolution*resolution*9)
   def forward(self, x, encoder_out=None):
       b, c, *spatial = x.shape
       x = x.reshape(b, c, -1)
       qkv = self.qkv(self.norm(x))
       if encoder_out is not None:
           # encoder_out = self.encoder_kv(encoder_out)  
           encoder_out = self.encoder_qkv(encoder_out)
       return encode_out

Comment out the function self.encoder_kv = conv_nd(1, 512, channels * 2, 1) that is not used in the forward, and the program will run normally.

[Solved] No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.errError: Network Error

Console error message

Access to XMLHttpRequest at 'http://**/login' from origin 'http://**:9528' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
errError: Network Error

Cause analysis

According to Access-Control-Allow-Origin, it can be seen that it is a cross domain problem. If one address accesses another address, if any of the three places is different in this process, cross domain problems will occur.

1. Access agreement

HTTP, https

2. The port number is different

My error report here is to use 9528 to access 8001

3. Different IP addresses

Solution:

1. Add a comment on the back-end interface controller @CrossOrigin
2. Use the gateway to solve the problem

[Solved] Mindspore 1.3.0 Compile Error: CMake Error at cmake/utils

[Function Module].
Compile mindspore 1.3.0 with error CMake Error at cmake/utils.cmake:301 (message): Failed patch:

[Steps & Problems]
1. The compilation process after executing bash build.sh -e ascend gives an error, as follows:

-- Build files have been written to: /root/mindspore-v1.3.0/build/mindspore/_deps/icu4c-subbuild
[100%] Built target icu4c-populate
icu4c_SOURCE_DIR : /root/mindspore-v1.3.0/build/mindspore/_deps/icu4c-src
patching /root/mindspore-v1.3.0/build/mindspore/_deps/icu4c-src -p1 < /root/mindspore-v1.3.0/build/mindspore/_ms_patch/icu4c.patch01
patching file icu4c/source/runConfigureICU
Reversed (or previously applied) patch detected!  Assume -R?[n]
Apply anyway?[n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file icu4c/source/runConfigureICU.rej
CMake Error at cmake/utils.cmake:301 (message):
  Failed patch:
  /root/mindspore-v1.3.0/build/mindspore/_ms_patch/icu4c.patch01
Call Stack (most recent call first):
  cmake/external_libs/icu4c.cmake:36 (mindspore_add_pkg)
  cmake/mind_expression.cmake:85 (include)
  CMakeLists.txt:51 (include)

-- Configuring incomplete, errors occurred!
See also "/root/mindspore-v1.3.0/build/mindspore/CMakeFiles/CMakeOutput.log".
See also "/root/mindspore-v1.3.0/build/mindspore/CMakeFiles/CMakeError.log".

——————————————————————————————————————————-
This situation is usually due to the failure of the last compilation on the way, try to compile again, please try to deal with the following.

rm -rf mindspore/build/mindspore/_deps/icu*

Then retry the compilation.

request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;

request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’; nested exception is java.lang.NumberFormatException: For input string : “undefined” at _default (request.js?b775:101:1)

Database and entity class type comparison

 

 Entity class id to write @JsonFormat(shape = JsonFormat.Shape.STRING)

 

 time to write this

 

 Vue’s time display format:

 

[Solved] qt phonon Play wav file Error:“symbol lookup error: /usr/lib/kde4/plugins/phonon_backend/phonon_gstreamer.so: undefined symbol: _ZNK6Phonon11MediaSource3mrlEv”

Linux:
there is no problem with using it before. After reinstalling the system, it will prompt qt to use phonon to play the wav file, and it will prompt “symbol lookup error: /usr/lib/kde4/plugins/phonon_backend/phonon_gstreamer.so: undefined symbol: _ZNK6Phonon11MediaSource3mrlEv ” this error, and then the program crashes, as if to say the reason for this library version.

My Solution:
find the libphonon_gstreamer.so library in the qt installation directory, then copy it to the directory indicated by the error (rename libphonon_gstreamer.so to phonon_gstreamer.so), replace the phonon_gstreamer.so inside, and return to normal.

[Solved] ORB_SLAM Install Error: error: ‘std::chrono::monotonic_clock’ has not been declared

The reason for this problem is that there is a difference between the C++ versions.

Momotonic_clock is no longer available in C++11, there is steady_clock instead.

I got the solution from Stack Overflow.

So the author of orb-slam used ifdef in the code to determine the user’s C++ version:

#ifdef COMPILEDWITHC11
        std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
#else
        std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
#endif
 
        //Pass the image to the SLAM system
        SLAM.TrackMonocular(im,tframe);
 
#ifdef COMPILEDWITHC11
        std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
#else
        std::chrono::monotonic_clock::time_point t2 = std::chrono::monotonic_clock::now();
#endif

But this part of monotonic_clock will still report an error!

If you report an error in this part, there is a high probability that your C++ is version 11, then we can actually delete this part of the judgment statement and keep only

std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
 
 //Pass the image to the SLAM system
 SLAM.TrackMonocular(im,tframe);
 
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
 
//......

This part is fine. After deleting the code of monotonic_clock, it can be compiled normally!

[Solved] Disconnected from the target VM, address : ‘127.0.0.1:6847’ , transport : ‘socket’

Disconnected from the target VM, address : ‘127.0.0.1:6847’ , transport : ‘socket’

Cause Analysis 1 The Tomcat used by the server, the compilation and packaging method is not set to war [the default packaging method is jar]
Scenes Unable to start when starting projectimage

1. Set the packaging method to war in pom.xml
image-20220727191657448

Cause Analysis 2 Port is occupied
Scenes Unable to start when starting projectimage

1. First check the startup status of the port

​ Win+R Enter cmd to open the DOS command box, enter netstat -ano | findstr 8060 [where 8060 is the port number of the running project] If this is image
displayed, it means that the background port 8060 is still running, and the PID is 10316, so kill the port process, Just restart the project

2. Kill the process, choose one of the two methods

​ 2.1, Ctrl + alt + delete, start the task manager, find the corresponding program according to the PID, right-click to end the taskimage

​ 2.2. According to tasklist | findstr 10316, query what program is occupying port 8060, of which 10316 is the PID queried above.image

​ Just continue to execute taskkill /f /t /im java.exe
​ (or) directly execute taskkill /pid 10316 -t -f to force kill the process

[Solved] Rancher Add User Error: x509: certificate has expired Internal error occurred: failed calling webhook “rancherauth.cattle.io”:

Error message:

Internal error occurred: failed calling webhook " rancherauth.cattle.io " :
Post https: // rancher-webhook.cattle-system.svc:443/v1/webhook/validation?timeout=10s: x509: certificate has expired or is not yet valid

Check the validity period of the certificate, it has expired 24 days

Solution:
0. Backup the yaml file of the cattle-webhook-tls certificate (the yaml file contains tls.crt and tls.key information)
1. Delete the expired cattle-webhook-tls certificate
2. Restart rancher-webhook pod
3. Check the validity period of the certificate again, it is already 1 year