For Linux, membasebucket cannot be written to the default bucket.

Source: Internet
Author: User
Tags couchbase

For Linux, membasebucket cannot be written to the default bucket.

Membase recently used in the project has found some problems, and reading and writing all kinds of data in the production environment is normal. However, in the new development environment, only the default bucket cannot write data, when you call store, the system always returns FALSE, and the configuration files are the same. I really don't know what went wrong. The other buckets read and write normally, creating a bucket on membase in the development environment is also normal for reading and writing. Finally, we found that membase of the windows version was produced, and the development environment was the Linux (centos) version. it was suspected that it may be related to the server version. Therefore, a new windows version was installed, and everything was normal. For the Linux version (couchbase), it still takes time to find the cause.

Dll used by the project: membase. dll 2.14.0.0, Enyim. Caching. dll 2.11.0.0. You can see the Code through decompilation, but it is not easy to debug. You can find the corresponding source code on the Internet:

  • Https://github.com/enyim/EnyimMemcached
  • Https://github.com/xianrendzw/LightFramework.Net

The second is to package the source code of membase in the LightFramework. Caching project. I will check the reason for this code.

Since it is a store failure, we can track it in one step to see if the default bucket is different from other buckets in the store method.

public bool Store(StoreMode mode, string key, object value){    ulong tmp = 0;    return this.PerformStore(mode, key, value, 0, ref tmp);}

We can see that the actual calling is the mongomstore method, followed by var node = this. pool. locate (hashedKey); returns null, that is, no corresponding bucket is found. What data is written.

Check why the returned value is null. We found that when initializing the membaseclient instance, we need to obtain the bucket information from the registered serverurl (legal or normal) and call the ResolveBucket method, the result is abnormal. 401 error, unauthorized!

When we use other buckets for initialization, we find that credential in the client parameter of this method has a value (username, password), while the default bucket is null. This is the cause. Set the username of credential to default and request the bucket verification information again.

I wonder, isn't it the default and cannot set the password? Why do I need to verify it here? Google-related problems found that many people do not know how to solve them, or even the membase bug:

  • Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url
  • Https://issues.couchbase.com/browse/MB-2166
  • Http://qnalist.com/questions/5796245/membase-client-401-getting-config-from-pool-url
  • Http://grokbase.com/t/gg/enyim-memcached/11anh26mtr/membase-client-401-getting-config-from-pool-url

When searching for problems, I found that if the bucket is default, membase. dll will leave its bucketname and password empty, meaning that no authentication is required, and the special port 11210 is used (Other buckets use 11211 for verification ), now that all the annotations are described in this way, do I still need identity authentication for Mao's request for bucket authentication information?

The failure of writing by Default is caused by the above reasons. For the windows version of membase server, it does not exist. I have tested it and there is no authentication restriction for the default bucket. For Linux, You can manually change the authentication information during source code tracking, which can also be read and written normally. Unfortunately, you cannot correctly configure the credential when initializing membaseclient externally. Another solution is to use MemcachedClient. Because membase is compatible with the memcached sdk, You can initialize the instance as follows:

var config = new MemcachedClientConfiguration();config.AddServer("192.168.1.12",11211);var client = new MemcachedClient(config);client.Store(StoreMode.Set, DateTime.Now.ToString("HHmmss"), "testValue");

It is also normal to read and write the default bucket in this way.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.