Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

To configure the mongodb environment in the Linux server

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Go to the mongodb official website to download a suitable linux environment installation package

As shown in the following picture, put it in a local corner and remember the location.

2. Then you need to have a server and enter

Ssh root@ enter the password for your IP / / enter

3. Upload the downloaded installation package to the service

Open another ssh window (command+n), if it is windows, open a new cmd window, because we have to manipulate the local file, the previous window we have logged on to the server.

There are many ways to pass on, and I will only demonstrate one of them.

Cd "folder where the installation package is located" / / go to the location where you just installed the package scp "local file" root@ your IP / / enter the password to start sending

As shown below, I am transferred to the root directory of the server.

Actually, it is not recommended, you can put it in an inherent directory, such as / usr/local

Transfer the files from the local computer to the server

Ls-l / / is expanded in the form of a list, and we can see that the download has been successful.

A locally uploaded file was received on the server

4. Extract the installation package

Copy the code code as follows: tar-zxvf mongodb-linux-x86_64-3.4.6.tgz / / decompress different files with different decompression commands. Baidu can do it yourself.

Extract the file

5. The step of filling the hole

I just said that you can put each installation in a fixed folder, so I moved the unzipped files to the / usr/local/mongodb directory, if you have put it in your favorite location, you can skip this step. If you don't know how to move it, you can take a look.

Cd / user/local / / enter localmkdir mongodb / / create a mongodb folder cd / / enter the root directory mv mongodb-linux-x86_64-3.4.6 / usr/local/mongodb / * move the extracted package into / usr/local/mongodb*/

Successfully moved in

6. Configure the mongodb running environment

Mkdir data / / create data folder, store database db file mkdir logs / / create logs folder, store log file cd logs / / enter logstouch mongo.log / / create log file cd.. / / return to the previous level mkdir etc / / create a configuration folder cd etc / / enter etcvim mongo.conf / / Edit and create a mongo.conf file

The following is the code in the mongo.conf file. Make sure you don't make mistakes.

After entering the file, you have to press the keyboard I to start writing code.

Dbpath = / usr/local/mongodb/data / / path must be absolute logpath = / usr/local/mongodb/logs/mongo.log / / path must be absolute logappend = truejournal = truequiet = trueport = 27017 / / Port

When you're done, press the ESC key to exit, then press shift+: to appear at the bottom: then type wq to save and exit.

At this point, it's almost over.

7. Start mongodb

Cd mongodb/mongodb-linux-x86_64-3.4.6/bin / / enter the mongod-f / usr/local/mongodb/etc/mongo.conf / / Startup 1 method or. / mongod-f / usr/local/mongodb/etc/mongo.conf / / Startup 2 method in the bin directory of the installation package

If you enter this command, it will appear as shown in the following figure, and there will be no change. Only the cursor blinks.

After startup

8. Whether the local test is successful

My visualization tool Robo 3t

To create a new link, enter the server address in address and fill in the port configured in your mongo.conf. Basically, it's 27027.

Local Visualization tool New Link

Click Save, as shown in the following figure to Connect

Whether the test is successful or not

If you get to this point, it's almost a success, 🎉🎉🎉.

Success

9. Pit warning

What I wrote about the path in mongo.conf is relative, so the following problem arises.

Failed screenshot

And then it was like this.

Failed screenshot

10. Summary

There are many methods, and I wrote only one of them, which I installed for the first time. There are also some potholes. Don't throw in the towel when you encounter problems, they will always be solved. Ha ha

If you write something wrong, I hope you will not hesitate to give us advice.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report