MongoDB使用docker部署和直接部署的对比?优缺点?

请教吧内大神们,MongoDB使用docker部署和直接部署的优缺点? 我们项目
现在是在考虑使用MongoDB分片集群,三台服务器,每台服务器按照官网推荐部署5个MongoDB节点:1个mongos 1个config server 1个主分片 1个副本集 1个仲裁者,想问一下这种部署方案是直接部署好还是使用docer好?最好有个两者之间详细的优劣对比?

2个回答

docker的优点:方便,免配置,开箱即用,在一个服务器上可以高密度部署,便于迁移。
直接部署:灵活,更充分利用主机性能,效率高,特别是IO效率,更好地和本地其他程序交互。

Docker是基于Linux 64bit的,无法在32bit的linux/Windows/unix环境下使用LXC是基于cgroup等linux kernel功能的,因此container的guest系统只能是linux base的隔离性相比KVM之类的虚拟化方案还是有些欠缺,所有container公用一部分的运行库网络管理相对简单,主要是基于namespace隔离container随着用户进程的停止而销毁,container中的log等用户数据不便收集Docker对disk的管理比较有限
Docker并非适合所有应用场景,Docker只能虚拟基于Linux的服务。Windows Azure 服务能够运行Docker实例,但到目前为止Windows服务还不能被虚拟化。
可能最大的障碍在于管理实例之间的交互。由于所有应用组件被拆分到不同的容器中,所有的服务器需要以一致的方式彼此通信。这意味着任何人如果选择复杂的基础设施,那么必须掌握应用编程接口管理以及集群工具,比如Swarm、Mesos或者Kubernets以确保机器按照预期运转并支持故障切换。
Docker在本质上是一个附加系统。使用文件系统的不同层构建一个应用是有可能的。每个组件被添加到之前已经创建的组件之上,可以比作为一个文件系统更明智。分层架构带来另一方面的效率提升,当你重建存在变化的Docker镜像时,不需要重建整个Docker镜像,只需要重建变化的部分。
可能更为重要的是,Docker旨在用于弹性计算。每个Docker实例的运营生命周期有限,实例数量根据需求增减。在一个管理适度的系统中,这些实例生而平等,不再需要时便各自消亡了。
针对Docker环境存在的不足,意味着在开始部署Docker前需要考虑如下几个问题。首先,Docker实例是无状态的。这意味着它们不应该承载任何交易数据,所有数据应该保存在数据库服务器中。
其次,开发Docker实例并不像创建一台虚拟机、添加应用然后克隆那样简单。为成功创建并使用Docker基础设施,管理员需要对系统管理的各个方面有一个全面的理解,包括Linux管理、编排及配置工具比如Puppet、Chef以及Salt。这些工具生来就基于命令行以及脚本。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
尝试连接到MongoDB容器时,GOLANG客户端Docker容器变得无法访问

<div class="post-text" itemprop="text"> <p>I have a simple program written in golang which connect to a mongodb instance thus:</p> <pre><code>func main() { session, err := mgo.Dial("localhost:27017") if err != nil { panic(err) } defer session.Close() session.SetMode(mgo.Monotonic, true) ensureIndex(session) } </code></pre> <p>I use docker compose to spin up two containers one to spin up my GOLANG API and the other to spin up mongo:</p> <pre><code>version: "3.3" services: api: image: golang:latest volumes: - .:/go working_dir: /go environment: - GOPATH=/go command: go run /go/src/main.go ports: - "8082:8000" depends_on: - db networks: - api-net db: build: . expose: - '27017' container_name: 'mongo' ports: - "27017:27017" networks: - api-net networks: api-net: driver: bridge </code></pre> <p>I use a Dockerfile in order to spin up mongo with a conf file that sets the instance to bind to all IPV4 and IPV6 networks:</p> <pre><code>FROM mongo:latest COPY mongod.conf /etc/mongod.conf CMD mongod --config /etc/mongod.conf## </code></pre> <p>and this is the mongod.conf file:</p> <pre><code>systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: 27017 bindIp: 0.0.0.0 </code></pre> <p>When I run docker-compose.up this is what I get:</p> <pre><code>Building db Step 1/3 : FROM mongo:latest ---&gt; a0f922b3f0a1 Step 2/3 : COPY mongod.conf /etc/mongod.conf ---&gt; Using cache ---&gt; f270e718c11e Step 3/3 : CMD mongod --config /etc/mongod.conf ---&gt; Running in 89ffc2495a2a Removing intermediate container 89ffc2495a2a ---&gt; fe2677d53122 Successfully built fe2677d53122 Successfully tagged carsupermarket_db:latest WARNING: Image for service db was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating mongo ... done Creating carsupermarket_api_1 ... done Attaching to mongo, carsupermarket_api_1 api_1 | panic: no reachable servers api_1 | api_1 | goroutine 1 [running]: api_1 | main.main() api_1 | /go/src/main.go:38 +0x291 api_1 | exit status 2 </code></pre> <p>I've trawled Google and stackoverflow and the only thing I could manage to find which is vaguely related to my issue is:</p> <p><a href="https://stackoverflow.com/questions/38860308/mongod-bind-ip-using-docker-compose-version-2">mongod --bind_ip using docker-compose version 2</a></p> <p>however, my docker-compose.yml file as it stands 'Should' on paper work.</p> <p>Can someone please point me in the correct direction as to why my GOLANG code cannot find my mongodb instance. </p> </div>

Docker出现“服务器选择超时错误” MongoDB Go驱动程序

<div class="post-text" itemprop="text"> <p>I'm working on a very basic (I thought) starter program in Go using MongoDB and Docker. Trying to get a handle on these before we start using them at work. I've got my MongoDB running in a docker container, just using my local host, using the official Docker image. This is running fine, I can connect to it through MongoDB Compass and modify the DB. </p> <p>My next task was to build a separate Docker container that is able to read and write to the DB. I'm using MongoDB-Go-Driver (<a href="https://godoc.org/github.com/mongodb/mongo-go-driver/mongo" rel="noreferrer">https://godoc.org/github.com/mongodb/mongo-go-driver/mongo</a>) for this as mgo is no longer kept up. </p> <p>This is my code, I'm just following the numerous tutorials online to make a simple connection and then ping the DB to ensure connectivity. </p> <pre><code>client, err := mongo.Connect("mongodb://localhost:27017") if err != nil { log.Fatal("error ", err) } // Check the connection err = client.Ping(context.TODO(), nil) if err != nil { log.Fatal("error2 ", err) } fmt.Println("Connected to MongoDB!") </code></pre> <p>It always fails on doing any operation on the DB (Find, FindOne, Ping, etc.) with <code>error2 server selection timeout</code></p> <p>This is my docker-compose file I'm running. </p> <pre><code>version: "3" services: datastore: image: mongo ports: - "27017:27017" networks: - maccaptionNet volumes: - .:/go/src/maccaption_microservice/dbdata jobservice: image: jobservicemaccaption:1.0 networks: - maccaptionNet depends_on: - "datastore" networks: maccaptionNet: driver: bridge </code></pre> <p>I'm brand new to MongoDB and after hours of research haven't made any progress on this. I've read through <a href="https://docs.mongodb.com/manual/core/read-preference-mechanics/" rel="noreferrer">https://docs.mongodb.com/manual/core/read-preference-mechanics/</a> <a href="https://docs.mongodb.com/manual/replication/" rel="noreferrer">https://docs.mongodb.com/manual/replication/</a></p> <p>Can anyone point me in the right direction for this? I haven't been able to find a lot on this specific issue. </p> <p>Thanks!</p> </div>

我试图在docker中部署gRPC(go)服务器并在本地端口中公开端口,但是端口绑定不起作用

<div class="post-text" itemprop="text"> <p>I tried to deploy gRPC server and mongodb in docker. After that I trying to binding docker ports to my local ports. mongodb ports binding was working fine. But, gRPC server ports are not binding my local port </p> <pre><code>ports: - "50051:50051" </code></pre> <p>like this i tried in docker-compose.yml</p> <p><b>docker-compose.yml</b></p> <pre><code>services: auth_server: container_name: auth_service build: . command: go run server.go volumes: - .:/go/src/auth_server working_dir: /go/src/auth_server ports: - "50051:50051" environment: PORT: 50051 </code></pre> <p>In client gRPC file I used host and port like, <b>0.0.0.0:50051</b> </p> <pre><code>conn, err := grpc.Dial("0.0.0.0:50051", grpc.WithInsecure()) </code></pre> <p>but it was not working. I can't find any bug, so I assume I am doing something incorrectly.</p> </div>

从容器内连接到mongoDB会话

<div class="post-text" itemprop="text"> <p>I'm new to learning how to use goLang to build microservices. I had a whole project up and running locally, but when I tried deploying it I ran into a problem. The session I was working with <code>(mgo.Dial("localhost"))</code> was no longer working. When I put this into a docker image, it failed to connect to the local host, which makes sense, since the docker image builds it over a new OS (alpine in my case). I was wondering what I should do to get it to connect.</p> <p>To be clear, when I was researching this, most people wanted to connect to a mongoDB session that is a docker container, I want to connect to a mongoDB session from within a docker container. Also once I'm ready for deployment I'll be using StatefulSet with kubernetes if that changes anything.</p> <p>For example, this is what I want my program to be like:</p> <pre><code>sess, err := mgo.Dial("localhost") //or whatever if err != nil { fmt.Println("failed to connect") else { fmt.Println("connected") </code></pre> <p>What I tried doing: Dockerfile: </p> <pre><code>FROM alpine:3.6 COPY /build/app /bin/ EXPOSE 8080 ENTRYPOINT ["/bin/app"] </code></pre> <p>In terminal:</p> <pre><code>docker build -t hell:4 . docker run -d -p 8080:8080 hell:4 </code></pre> <p>And as you can expect, it says not connected. Also the port mapping is for the rest of the project, not this part.</p> <p>Thanks for your help!</p> </div>

如何将本地Mongo数据库连接到Docker

<div class="post-text" itemprop="text"> <p>I am working on golang project, recently I read about docker and try to use docker with my app. I am using mongoDB for database. Now problem is that, I am creating Dockerfile to install all packages and compile and run the go project. I am running mongo data as locally, if I am running go program without docker it gives me output, but if I am using docker for same project (just installing dependencies with this and running project), it compile successfully but not gives any output, having error::</p> <pre><code>CreateSession: no reachable servers </code></pre> <p>my Dockerfile::</p> <pre><code># Start from a Debian image with the latest version of Go installed # and a workspace (GOPATH) configured at /go. FROM golang WORKDIR $GOPATH/src/myapp # Copy the local package files to the container's workspace. ADD . /go/src/myapp #Install dependencies RUN go get ./... # Build the installation command inside the container. RUN go install myapp # Run the outyet command by default when the container starts. ENTRYPOINT /go/bin/myapp # Document that the service listens on port 8080. EXPOSE 8080 EXPOSE 27017 </code></pre> </div>

在不能联网的情况下如何使用DockerFile构建基于centos的MongoDB镜像?

如题,请教各位大大,如果我在无网络的情况下,如何使用dockerfile构建基于centos7的MongoDB镜像?因为dockerfile第一句必须是 FROM... 我的生产环境是一个裸机服务器,什么都没有,需要我们首先自己安装Linux服务器,我们使用centos,然后在centos上装docker,安装完成后问题来了。我是内网环境,无法连接外网,如何使用DockerFile构建基于centos的MongoDB镜像?如果可以联网,我直接拉取MongoDB的镜像就完事了。但是我不能联网,docker要求DockerFile第一行必须是FROM。。 但是我无法联网,from拉取不了docker hub的镜像,请教各位大大,我该如何解决?生产环境我可以用U盘,能不能直接在拷贝一个装好的了MongoDB实像的docker进去?或者其他什么解决方案都行,只要能解决问题!

使用Redis作为Docker容器之间的链接

<div class="post-text" itemprop="text"> <p>I have a docker-compose file with several containers in, two of which are supposed to communicate via a Redis DB. Both containers have connections to Reids and I can read/write from both. However I'd like a container to be triggered every time the something is added from the other container. I thought I could accomplish this via Redis Sub/Pub but it when I run the code it never triggers anything, even when I can see I've added new items to the Redis queue. </p> <p>From this I have two questions: 1. Is what I'm looking to do even possible? Can I do publish/subscribe in in two separate docker containers and expect it work as described above? 2. If it is possible, can someone please point me below where I"m going wrong with this tools? </p> <p>This is my function that I add new data to the Redis queue and then publish the data in Docker container 1. </p> <pre><code>func redisShare(key string, value string) { jobsQueue.Set(key, value, 0) //setting in the queue jobsQueue.Publish(key, value) //publishing for the other docker container to notice fmt.Println("added ", key, "with a value of ", value, "to the redis queue") } </code></pre> <p>I'm using this line in my other docker container to subscribe to the Redis queue and listen for changes: <code>redisdb.Subscribe()</code></p> <p>I would expect if something was added to the redis queue it would share the data to the other container and I'd see the message received, but right now Docker Container 2 just runs and then closes. </p> <p>Thanks! </p> </div>

PHP源码从LINUX上拷贝到windows环境下,使用的是mongodb 数据库,部署后提示整数溢出

![这个是本地运行报的错误](https://img-ask.csdn.net/upload/201811/09/1541755855_206318.png)

docker上部署的消息队列,在docker宕掉后,消息队列中的消息还没恢复么?

最近在研究RocketMQ,说的消息持久化的问题。查资料RocketMQ是支持消息持久化到mysql数据中的(目前还没查到如何做)。而且持久化到数据库中效率比持久化到文件系统中要慢。 向问一下各位大神:RocketMQ部署到docker容器中,如果docker的容器宕掉的话,消息队列服务恢复后,持久化了的消息还能恢复么?

尝试使用docker compose文件连接Redis时连接被拒绝

<div class="post-text" itemprop="text"> <p>我在尝试使用redis-golang驱动程序连接到Redis时遇到问题。 这是我的 <code>docker-compose.yml</code>文件 : </p> <pre><code>version: "3" services: driver: build: ./API-Golang command: go run app.go volumes: - ./API-Golang:/app ports: - "8080:8080" depends_on: - db - redis links : - redis - db redis: image: redis container_name: redis ports: ["6379:6379"] db: image: mongo:3.4.2 container_name: mongodb ports : ["27017:27017"] </code></pre> <p>这是我试图连接到redis (API-Golang/数据库/allSystem.go)的代码:</p> <pre><code>redisConn := RedisHost{ Address: "localhost:6379", Password: "", DB: 0, } redisConnection, err := redisConn.Connect() if err != nil { panic(err) } </code></pre> <p>我试图改变 <code>localhost</code>为 <code>redis</code> 但它还是不管用。错误如下:</p> <pre><code>driver_1 | panic: dial tcp [::1]:6379: getsockopt: connection refused driver_1 | driver_1 | goroutine 1 [running]: driver_1 | github.com/Gujarats/API-Golang/database.SystemConnection(0x48) driver_1 | /go/src/github.com/Gujarats/API-Golang/database/allSystem.go:32 +0x3d3 driver_1 | main.main() driver_1 | /go/src/github.com/Gujarats/API-Golang/app.go:24 +0x34 driver_1 | exit status 2 </code></pre> <p>你知道哪里出错了吗?</p> <p><a href="https://github.com/Gujarats/Go-docker" rel="nofollow noreferrer">源代码</a></p> </div>

非宿主机外部访问docker容器问题

简单介绍一下我的环境: 1、docker宿主机(os:centos7, ip:192.168.0.100) 2、宿主机中用brctl新建一个虚拟网桥bridge0(brctl addbr bridge0),并分配IP为192.168.227.1 (ifconfig bridge0 192.168.227.1 netmask 255.255.255.0) 3、然后docker容器以网桥方式用pipework挂到bridge0下: docker run -idt --privileged -h="h2" -p 80:80 --net=none --name h2 7322fbe74aa5 /sbin/init pipework bridge0 h2 192.168.227.2/24@192.168.227.1 综上所诉:宿主机和非宿主机都是192.168.0网段;而docker容器是192.168.227网段 现在的问题是: 我用一台非宿主机(os:win8, ip:192.168.0.101)试图连docker容器h2失败(ping 192.168.227.2 不通),而宿主机ping 192.168.227.1和192.168.227.2 都是能ping通的,在容器h2中ping这台win8机器也能ping通,而且能访问公网。要怎么设置才能让一台非宿主机在外部直接访问容器?比如用ssh直接从192.168.0.101登录到192.168.227.2中?

mongoDB和Redis在java web中的使用场景

mongoDB和REDIS在java web开发中的使用场景有哪些?

python+django能够同时使用mongodb和mysql两种数据库引擎吗?

各位朋友们好,我原来做一个项目:因为表没有关联,所以用的是非关系型数据库mongodb,项目开发环境用的是python+django,部署在ubuntu上。当时用了pymongo做python和mongodb的连接,用mongoengine做了django与mongodb的连接。 现在来了新的需求,表之间有关联,因此我准备添加一个mysql数据库。 请教各位朋友们,django展示网页的时候,能够同时展示mongodb中表的内容和mysql中表的内容吗?settings.py中应该如何配置数据库呢? 希望朋友们能指点一下,万分感谢。

MongoDB不能与Docker中的Symfony应用程序一起使用

<div class="post-text" itemprop="text"> <p>I have a Symfony app for a REST API that run in Docker container.</p> <p>All routes works but when I try to access a route for add information in database or extract information from database I receive the message</p> <pre><code>Oops! An Error Occurred The server returned a "500 Internal Server Error". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused. </code></pre> <p>docker-compose file created* with <a href="https://phpdocker.io/" rel="nofollow noreferrer">PHPDocker</a> is</p> <pre><code>version: "3.1" services: mongo: image: mongo:3.0 container_name: mongo command: mongod --smallfiles expose: - 27017 webserver: tty: true image: phpdockerio/nginx:latest container_name: code-webserver working_dir: /application volumes: - .:/application - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf ports: - "8000:80" php-fpm: build: context: . dockerfile: phpdocker/php-fpm/Dockerfile container_name: code-php-fpm ### MOVE ENVIRONMENT VARIABLES HERE environment: SYMFONY__MONGO_ADDRESS: mongo SYMFONY__MONGO_PORT: 27017 working_dir: /application volumes: - .:/application - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php5/fpm/conf.d/99-overrides.ini </code></pre> <p>*I tried to added links to mongo image, but doesn't work.</p> <p>Result of command <code>docker-compose up</code>.</p> <pre><code>PS E:\API\web_server\code&gt; docker-compose up Starting code-php-fpm Starting mongo Starting code-webserver Attaching to mongo, code-php-fpm, code-webserver mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/ db 64-bit host=5c9a4a252688 mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] db version v3.0.14 mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] git version: 08352afcca24bfc145240a0fac9d28b978ab 77f3 code-php-fpm | [22-Apr-2017 23:11:52] NOTICE: fpm is running, pid 5 mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] build info: Linux ip-10-30-223-232 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 BOOST_LIB_VERSION=1_49 mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] allocator: tcmalloc code-php-fpm | [22-Apr-2017 23:11:52] NOTICE: ready to handle connections mongo | 2017-04-22T23:11:52.947+0000 I CONTROL [initandlisten] options: { storage: { mmapv1: { smallFiles: true } } } code-php-fpm | [22-Apr-2017 23:11:52] NOTICE: systemd monitor interval set to 10000ms mongo | 2017-04-22T23:11:52.959+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal mongo | 2017-04-22T23:11:52.959+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery n eeded mongo | 2017-04-22T23:11:53.395+0000 I JOURNAL [durability] Durability thread started mongo | 2017-04-22T23:11:53.395+0000 I JOURNAL [journal writer] Journal writer thread started mongo | 2017-04-22T23:11:53.653+0000 I NETWORK [initandlisten] waiting for connections on port 27017 </code></pre> <p>Log when I tried to access a simple page <code>(localhost:8000)</code> from application - it's ok</p> <p><code>code-php-fpm | 172.19.0.4 - 22/Apr/2017:23:24:52 +0000 "GET /app.php" 200</code></p> <p>Log when I tried to access an url <code>(localhost:8000/transactions/user=invalid&amp;day=1492453903&amp;threshold=100)</code> valid but with invalid data - it's ok</p> <p><code>code-php-fpm | 172.19.0.4 - 22/Apr/2017:23:23:32 +0000 "GET /app.php" 400</code></p> <p>Log when I tried to access an url <code>(localhost:8000/transactions/user=100&amp;day=1492453903&amp;threshold=100)</code> valid with a valid data from insert in mongo database - isn't ok</p> <p><code>code-php-fpm | 172.19.0.4 - 22/Apr/2017:23:13:09 +0000 "GET /app.php" 500</code></p> <p>'parameters.yml' file</p> <pre><code># This file is auto-generated during the composer install parameters: database_host: 127.0.0.1 database_port: null database_name: symfony database_user: root database_password: null mailer_transport: smtp mailer_host: 127.0.0.1 mailer_user: null mailer_password: null secret: ThisTokenIsNotSoSecretChangeIt mongodb_server: 'mongodb://mongo:27017' </code></pre> <p><code>config.yml</code> file contain</p> <pre><code>doctrine_mongodb: connections: default: server: "%mongodb_server%" options: {} default_database: hootsuite_database document_managers: default: mappings: DBBundle: ~ </code></pre> <p>Logs from Symfony project:</p> <pre><code>[2017-04-23 07:03:25] request.INFO: Matched route "db_transaction_gettransactions". {"route":"db_transaction_gettransactions","route_parameters":{"_controller":"DBBundle\\Controller\\TransactionController::getTransactionsAction","_route":"db_transaction_gettransactions"},"request_uri":"http://localhost:8000/transactions/?day=1492453903&amp;threshold=123&amp;user=500","method":"GET"} [] [2017-04-23 07:03:25] security.INFO: Populated the TokenStorage with an anonymous Token. [] [] [2017-04-23 07:03:25] request.CRITICAL: Uncaught PHP Exception MongoConnectionException: "Failed to connect to: localhost:27017: Connection refused" at /application/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php line 282 {"exception":"[object] (MongoConnectionException(code: 71): Failed to connect to: localhost:27017: Connection refused at /application/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php:282)"} [] </code></pre> <p>When I try to view database with Robomongo on <code>localhost:27017</code> works.</p> <p>Any advice? Thanks!</p> </div>

在MongoDB中使用WHERE和JOIN

<div class="post-text" itemprop="text"> <p>I have 2 collections, I want to select the records from a collection according to another collection,</p> <p>let me explain my mean by example:</p> <p>Collection1:</p> <pre><code>id, user_id, completed 1 , 1 , true 2 , 1 , false 3 , 2 , true 4 , 3 , true 5 , 4 , false </code></pre> <p>Collection2:</p> <pre><code>id, username 1 , test 2 , test 2 3 , test 3 4 , test 4 </code></pre> <p>I want to select users from <code>collection2</code> which the <code>completed</code> column in <code>collection1</code> are <code>false</code> (the result should be (1,test),(2,test 4) )</p> <p>because I'm a newbie in MongoDB I don't know what should I do, I can do it in MySQL and PostgreSQL with <code>join</code> but here what should I do?</p> <p>I read the <a href="https://docs.mongodb.com/v3.2/core/aggregation-pipeline/" rel="nofollow noreferrer">aggregation-pipeline</a> in MongoDB documentation but I cannot figure out.</p> </div>

本地部署mongodb能正常,部署到线上linux执行就报错~

在下新手 以下是错误提示、麻烦大神看下 ``` 22-Sep-2016 09:36:55.434 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.ApplicationContext.log Set web app root system property: 'qdshop.root' = [/mnt/gohihi/back/apache-tomcat-8.5.4/webapps/ROOT/] 22-Sep-2016 09:38:47.267 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 22-Sep-2016 09:38:47.354 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext 22-Sep-2016 09:39:20.399 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Set web app root system property: 'qdshop.root' = [/mnt/gohihi/back/apache-tomcat-8.5.4/webapps/ROOT/] 22-Sep-2016 09:39:20.526 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok) 22-Sep-2016 09:39:20.547 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'qdshop' 22-Sep-2016 09:48:16.718 SEVERE [http-nio-8888-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [qdshop] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.BasicMongoPersistentProperty.findAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;] with root cause java.lang.NoSuchMethodError: org.springframework.data.mongodb.core.mapping.BasicMongoPersistentProperty.findAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation; at org.springframework.data.mongodb.core.mapping.BasicMongoPersistentProperty.getFieldName(BasicMongoPersistentProperty.java:145) at org.springframework.data.mongodb.core.mapping.CachingMongoPersistentProperty.getFieldName(CachingMongoPersistentProperty.java:82) at org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity$AssertFieldNameUniquenessHandler.assertUniqueness(BasicMongoPersistentEntity.java:218) at org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity$AssertFieldNameUniquenessHandler.doWithPersistentProperty(BasicMongoPersistentEntity.java:209) at org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity$AssertFieldNameUniquenessHandler.doWithPersistentProperty(BasicMongoPersistentEntity.java:203) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:195) at org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity.verify(BasicMongoPersistentEntity.java:112) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:285) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:190) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:159) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:69) at org.springframework.data.mongodb.core.MongoTemplate.getPersistentEntity(MongoTemplate.java:1709) at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:802) at com.qdshop.foundation.service.impl.OrderFormLogServiceImpl.mongosave(OrderFormLogServiceImpl.java:35) at com.qdshop.foundation.service.impl.OrderFormLogServiceImpl$$FastClassByCGLIB$$b6384c11.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622) at com.qdshop.foundation.service.impl.OrderFormLogServiceImpl$$EnhancerByCGLIB$$b587a094.mongosave(<generated>) at com.qdshop.manage.seller.action.OrderSellerAction.order_shipping_code_save(OrderSellerAction.java:1137) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at com.qdshop.core.filter.ShopFilter.doFilter(ShopFilter.java:111) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at com.qdshop.core.filter.SecondDomainFilter.doFilter(SecondDomainFilter.java:56) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ```

mongodb 读取不到数据

我在Swarm集群中部署了一个mongo的docker ,然后挂载了一个数据卷 -v data/db:/data/db,然后,将这个数据卷copy到k8s集群中的一个节点上,然后在k8s中部署一个mongo的docker, 也挂载这个卷,但是这个mongo启动之后,之前的数据库都不存在了 ,我查询了导过来的数据卷大小和之前的数据卷大小是一样的, 有没有知道这个问题的原因的,请告知小弟一下

使用mongodb的gridfs当做文件存储系统如何?

项目中,对于文件的存放想找一个解决方案,文件有大有小,小的可能2K,大的可能10G以内。 目的想实现文件在多台服务器之间的备份,避免单台服务器物理损毁造成文件丢失 第一种方案:直接存放在linux的文件系统中,自行分目录存放。可是要自己实现备份,有点重新造轮子的感觉 第二种方案:就是标题提出的方案,使用mongodb的gridfs做文件保存,可以实现自动文件复制 第三种方案:使用fastdfs做文件保存,也可以实现自动文件复制 我想听听各位小伙伴怎么看,我不知道mongodb在各公司是否有人专门用来存放文件的。 fastdfs是国内的,据说还不错。 我自己做了简单的测试,mongodb的gridfs在操作小图片(2.5K)保存、下载都比fastdfs快一些些。 大伙可以给出自己的建议,只是用于文件保存、备份。

使用临时Docker容器时,显示以下错误消息“”无法解组DNS消息”

<div class="post-text" itemprop="text"> <p>I am trying to run a scratch docker container on my local from my go code. The Dockerfile is as follows:</p> <pre><code>FROM golang:1.11.4 as builder WORKDIR /app ADD . . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARM=7 make FROM scratch COPY --from=builder /app/myprogram . </code></pre> <p>In my code I try to connect to mongodb using the following url <code>mongodb+srv://myusername:mypassword@my-staging-vki7g.gcp.mongodb.net</code></p> <p>I can connect to this mongodb perfectly fine on my local mongoshell. However, when I run my scracth container, I get the following error</p> <pre><code>error parsing uri (mongodb+srv://myusername:mypassword@my-staging-vki7g.gcp.mongodb.net): lookup provendb-staging-vki7g.gcp.mongodb.net on 192.168.65.1:53: cannot unmarshal DNS message </code></pre> <p>Are there any dependencies that need to be added?</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

立即提问
相关内容推荐