Linux common environment configuration

1. sqlite3

1. Official website address

SQLite Download Page

2. Download in Linux

Right-click to copy the source code link and download it with wget in linux

wget https://www.sqlite.org/2023/sqlite-autoconf-3410200.tar.gz

3. Unzip

tar -xzvf sqlite-autoconf-3410200.tar.gz

4. Compile

# 进入解压目录
cd sqlite-autoconf-3410200/ 

./configure
make
make install

5. View version

sqlite3 --version

You can see the version number to indicate that the installation was successful

2. MongoDB

1. Official website address

Download MongoDB Community Server | MongoDB

Select a different version, system and installation package type. This tutorial selects the following version (the file type is tgz file after downloading)

2. Create a folder

Create a MongoDB folder under the server /usr/local to store installation packages, services, and subsequent MongoDB database and log files

cd /usr/local            # 进入安装目录
mkdir MongoDB            # 创建MongoDB文件夹
cd MongoDB               # 进入创建的MongoDB文件夹
mkdir source             # 在MongoDB文件夹下创建source文件夹用于保存安装包
mkdir data               # 在MongoDB文件夹下创建data文件夹用于后续数据库信息保存
mkdir log                # 在MongoDB文件夹下创建log文件夹用于保存数据库日志

3. Download in Linux

cd /usr/local/MongoDB/source
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse15-6.0.5.tgz

4. Unzip

tar -zxvf mongodb-linux-x86_64-suse15-6.0.5.tgz -C /usr/local/MongoDB/

# 重命名解压文件夹名称,方便后续使用
cd /usr/local/MongoDB
mv mongodb-linux-x86_64-suse15-6.0.5/ mongodbServer/

5. Configuration

5.1, configure environment variables

Add the mongod command path to the system command, so that the mongod command can be executed in any path

export MONGODB_HOME=/usr/local/MongoDB/mongodbServer
export PATH=$PATH:$MONGODB_HOME/bin

Execute the command to make the system environment variables take effect:

source /etc/profile

5.2. Configure MongoDB startup file

Create a mongod.conf file under the bin folder of the mongoDB service

vim /usr/local/MongoDB/mongodbServer/bin/mongod.conf

Write the following configuration:

storage:
    dbPath: "/usr/local/MongoDB/data"
systemLog:
    destination: file
    path: "/usr/local/MongoDB/log/mongod.log"
    logAppend: true
net:
    port: 27017
    bindIpAll: true
processManagement:
    fork: true

6. Test start

Execute the command in any path to start the mongoDB service

mongod --config /usr/local/MongoDB/mongodbServer/bin/mongod.conf

When the following screen appears, the startup is successful, and you can enter the mongoDB database at this time

#查看进程
ps -ef | grep mongod

7. Enter the database

Note: After mongodb6.0, major changes have been made. Mongodb no longer installs the shell tool for you by default, so you need to install an additional shell: Install mongosh — MongoDB Shell , this tool is called mongosh

Versions below 7.1 and mongodb6.0

Execute the following command in any path of versions below mongodb6.0 to enter the shell command line of mongoDB

mongo

如果mongodb6.0以上版本版本执行会出现:Command 'mongo' not found, but can be installed with:

7.2、mongodb6.0以上版本

需要额外安装mongosh工具:安装 mongosh — MongoDB Shell

安装成功后执行以下命令

mongosh

Guess you like

Origin blog.csdn.net/qq_62594984/article/details/130248874