What does the environmental variable "term" mean in the mongo config? - mongodb

I was trying to create a sharded mongo cluster and came across the env. variable "term", with value "xterm". Need help to understand the config field.
environment:
TERM: xterm

TERM is an env var that contains the terminal emulator used by your system. This var is not related to MongoDB.
In my Ubuntu 16.04, if I type echo $TERM, I'll get xterm-256color.
If you are using Docker, that TERM: xterm means that the terminal emulator used when you access your container will be xterm.
TERM affects MongoDB in the following way: Different terminal emulators generate different escape sequences when you press keys like Arrows, Home, End, Delete, etc; Mongo Shell, that runs on top of the emulator, will translate those sequences into its own 'language' to guarantee that each keystroke will present the same result in different terminals. Mongo uses Linenoise to do this job.
The value of TERM is not that important for 'keystroke processing'. Mongo Shell will try to translate the escape sequence from each terminal 'language' it supports. On the other hand, TERM is used to decide if the shell can show colors or not.

Related

mongo' is not recognized as an internal or external command, operable program or batch file

mongo is not recognized as an internal or external commandmongodb is not recognized as an internal or external commandI'm encountering these errors after having installed mongodb using a tutorial and after having tried the edit environment variables fix.I've edited the environment variables The mongosh keyword is recognized when I type it in in the command line but mongo and mongodb aren't. Mongod results in something I'm not certain it should be resulting in.is this expected? I noticed that the number of files available in my bin folder which is where mongodb is installed is less than that of others that I've seen.this is my bin folder with less files I also noticed that after installing mongodb, the mongo compass didn't auto install. I did that manually. How can I overcome these errors and start using mongodb?
mongod is the binary that runs the database. It has many flags, documented here. The output you see is expected. You will often run this in the background via --fork and send the output to a logfile.
mongo is the legacy shell that is deprecated as of 6.0 and no longer ships.
mongosh is the new shell that should provide all the same functionality as the legacy shell.
mongodb there is no binary with this name.
If you are trying to connect to MongoDB Atlas or an existing database, you should not need to run mongod yourself.

gcloud sdk in mac terminal - backspace does not work

Mac 10.14.6
iTerm2 Build 3.4.8
Google Cloud SDK 351.0.0
beta 2021.07.30
bq 2.0.70
core 2021.07.30
gsutil 4.66
Logging in to my virtual gcloud server without errors with:
gcloud compute ssh myserver
However, the backspace key in the terminal registers as a space key.
Tried exactly the same with the stock Mac terminal, the same behaviour.
What gives?
The backspace key will often seem to register as a space key if the environment variable TERM is not set to a value that is defined in your terminfo configuration.
You can check the value of TERM by running:
echo $TERM
terminfo can be configured in several places, but on Google Compute Engine it is likely using the values from /lib/terminfo. (Other possibilities include $HOME/.terminfo and /usr/share/terminfo.) You can check if your current setting for TERM corresponds to a file in this directory by running:
find /lib/terminfo -name $TERM
If the value is present, you will see something like /lib/terminfo/s/screen-256color. If it is not present, you will not see any output.
You can fix the problem by ensuring that your TERM environment variable is set to one of the files defined in terminfo.

How do you convert mongod to mongo service?

I have been running MongoDB on two Windows 10 PCs. However, one has mongo always running it seems where I only need to open command prompt and type mongo. This gives me access to the db on PC #1.
However, on PC #2, I must open command prompt and type mongod. Then I have to open a second command prompt to type in mongo, then I get access to the db on PC #2.
After doing this for about a year, I find I want to just want both PCs to work like PC #1, where I just type in mongo and not mongodb and only have to use one command prompt.
I checked online but there's nothing I found straightforward to accomplish this specifically.
Does anybody know the answer?
If in PC#2, your MongoDB version is < 4.0, then you can't do anything i.e., you have to continue with mongod to start Mongo as you do now.
But if your MongoDB version is >= 4.0 or you want to upgrade from lower version of MongoDB, you can follow the below steps.
Take backup of all databases with mongodump. If it is large volume data, then go through this.
Uninstall your MongoDB using Windows Uninstall Program features.
Reinstall MongoDB using the link.
While installing, ensure you select 'MongoDB Service' feature.
Start the MongoDB now in PC#2 as you do in PC#1.
Restore the old databases with mongorestore.

Is processManagement (fork to true) needed when MongoDB is only application running on Linux?

I am having problems logging into the mongo shell when I have configuration file set with processManagement fork set to true. Each time I have fork set to true, I have issues connecting to the mongo shell. Turn fork off (false), I have no issues connecting to the shell. I am using vagrant to build 3 Debian 10 boxes where the only thing I am adding to each box is MongoDB. Each MongoDB box will be a part of a replicaSet and communicate to each other on a private network ip. Do I need to set mongodb to run in the background of a linux OS? If I do, what is the advantage of doing so?
You do not necessarily need to fork/daemonize mongod. For example, this isn't necessary in docker.
For some of the reasons why programs daemonize, see https://unix.stackexchange.com/questions/287793/why-do-we-daemonize-processes.

synchronizing history when ipython notebook and console are connected to the same kernel

I have ipython notebook running on a remote server, i.e.
ipython notebook --profile=nbserver
which I access from my local machine. Further, I ssh to the remote server from my machine, and start ipython console (terminal) on that server. I have found following command to work well:
ipython console --existing \
~/.config/ipython/profile_nbserver/security/kernel-*.json
Now I am connected to the same remote kernel from two different clients (lets call them browser and terminal). Everything works well, except one annoying detail:
1) in browser, I type a=1
2) in terminal, I type b=2
3) in both clients I can see both commands using %history. But when I want to cycle through the history (in terminal) using Up, it only shows the commands which have been typed in the terminal, (i.e b=2). Similarly, I am unable to use a + PageDown in the terminal, to go back in history and find the command starting with a.
From what I understand, my two clients are using two separate history files history.sqlite. But why does %history show all commands ?
Question:
Is there any way to configure using one history.sqlite for both clients ?
I find, having easy access to history is absolutely crucial. Moreover, I see using both terminal and browser as complementary, they both have tradeoffs and are best used combined.
You can set where the history gets loaded either by setting it at the terminal:
ipython --HistoryManager.hist_file=$HOME/ipython_hist.sqlite
or within the ipython config files:
import os
c.HistoryManager.hist_file=os.path.expanduser("~/ipython_hist.sqlite")