1.Prepare a Linux server. See System Requirements for more details.
2.Log in to the Linux server as the root user.
Note: It is highly recommended to install numactl on the MongoDB Server to optimize its performance. Run the rpm -qa|grep numactl command to check whether numactl has been installed. If it is not installed, run the yum install numactl command to install it.
3.Run the mkdir command to create a directory under the /opt directory to place the installation package. For example, netbraintemp.
Note: Don't place the installation package under any personal directories, such as /root.
4.Obtain the mongodb-linux-x86_64-rhel7-3.6.4.tar.gz file from NetBrain, and then copy it to the /opt/netbraintemp directory.
▪Option 1: If the Linux server has no access to the Internet, upload the mongodb-linux-x86_64-rhel7-3.6.4.tar.gz file to the /opt/netbraintemp directory by using a file transfer tool.
▪Option 2: If the Linux server has access to the Internet and the yum command has been installed:
1)Run the yum -y install wget command to install the wget command if it has not been installed.
2)Run the cd /opt/netbraintemp command to navigate to the /opt/netbraintemp directory.
3)Run the wget <NetBrain IE 7.1a2 MongoDB download link> command under the /opt/netbraintemp directory to directly download the mongodb-linux-x86_64-rhel7-3.6.4.tar.gz file to this directory.
Tip: Contact NetBrain Support Team to get the download link address.
Note: The download link is case-sensitive.
5.Run the tar -zxvf mongodb-linux-x86_64-rhel7-3.6.4.tar.gz command under the /opt/netbraintemp directory to extract installation files.
[root@localhost netbraintemp]# tar -zxvf mongodb-linux-x86_64-rhel7-3.6.4.tar.gz
MongoDB/
MongoDB/fix_releaseinfo.json
MongoDB/install.sh
MongoDB/install_mongodb.conf
MongoDB/mongodbconfig-7-1.noarch.rpm
MongoDB/mongodbconfig.sh
MongoDB/preinstallcomponents/
MongoDB/preinstallcomponents.sh
MongoDB/preinstallcomponents/CentOS7/
MongoDB/preinstallcomponents/CentOS7/lsof-4.87-4.el7.x86_64.rpm
MongoDB/preinstallcomponents/RedHat7/
MongoDB/preinstallcomponents/RedHat7/lsof-4.87-4.el7.x86_64.rpm
6.Run the cd MongoDB command to navigate to the MongoDB directory.
7.Modify the parameters in the install_mongodb.conf file located under the MongoDB directory according to your environment and save the changes. For how to modify the configuration file, see Appendix: Editing a File with VI Editor for more details.
#NetBrain Database configuration file
#Note: other than the database username and password, other entries
#can only contain letters and numbers, and should start with a letter.
DBServiceName mongod
DBSystemUser netbrain
DBSystemGroup netbrain
ConfPath /home/mongodb
DataPath /home/mongodb/data
LogPath /home/mongodb/log
BindIp 10.10.3.142
#The port must be between 1025 and 65535.
DBPort 27017
#Replica set name can only contain letters and numbers and start with a letter.
ReplicaSetName rs
UseSSL no
Certificate /etc/ssl/cert.pem
PrivateKey /etc/ssl/key.pem
#either dbuser or dbpassword was set to empty,mongodbconfig.sh will not add user and password
#The DBUser or DBPassword should not contain: {}[]:",'|<>@&^%\ or a space.
#The length of DBUsername or DBPassword should not be more than 64 characters.
DBUser mongodb
DBPassword mongodb
#CGroups config
CPULimit 55%
MemoryLimit 55%
#CPULimit 35%
#MemoryLimit 35%
#List all replica set members. The members should be separated with spaces. The total number of members should an odd number.
#The first member will be used as the primary member, the last will be used as the arbiter. The rest are the secondary members.
#It is recommended to use FQDN. The address of 0.0.0.0 or 127.0.0.0 is not allowed. For example:
#ReplicaSetMembers 192.168.1.1:27017 192.168.1.2:27017 192.168.1.3:27017
ReplicaSetMembers 10.10.3.142:27017
...
8.Run the ./install.sh script under the MongoDB directory to install the MongoDB Server and initialize the MongoDB service as well as the admin username and password.
[root@localhost MongoDB]# ./install.sh
Installing third-party components. It will take a few minutes, please wait.
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Successfully installed lsof.
Successfully executed preinstallcomponents.sh
...
Total memory: 15
cgroup memory: 8
Cache size: 4
Redirecting to /bin/systemctl status firewalld.service
MongoDB shell version v3.6.4
connecting to: mongodb://10.10.3.142:27017/test
MongoDB server version: 3.6.4
bye
Successfully connected mongodb node:10.10.3.142:27017
Mongodb has been installed successfully
MongoDB shell version v3.6.4
connecting to: mongodb:/10.10.3.142:27017/test
MongoDB server version: 3.6.4
bye
Successfully connected MongoDB node 10.10.3.142:27017
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.6.4
{
"ok" : 1,
"operationTime" : Timestamp(1543296001, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1543296001, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
Successfully initialized replica set rs of MongoDB service mongod.
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.6.4
Successfully added user: {
"user" : "mongodb",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
Successfully added user: "mongodb", password: "******" for MongoDB service: mongod
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.6.4
bye
Successfully logged in MongoDB with username: "mongodb", password: "******"
Finished running MongoDB configuration script.
Successfully ran install.sh.
9.Restart the machine manually by entering the reboot command.
10. After the machine starts, run the ps -ef|grep mongo or service mongod status command to verify whether its service starts successfully.
[root@localhost ~]# ps -ef|grep mongo
netbrain 5653 1 7 Jan16 ? 1-00:58:39 /bin/mongod -f /opt/mongodb/mongod.conf
root 60833 30651 0 03:19 pts/0 00:00:00 grep --color=auto mongo
[root@localhost ~]# service mongod status
mongod.service - SYSV: Mongo is a scalable, document-oriented database.
Loaded: loaded (/etc/rc.d/init.d/mongod)
Drop-In: /etc/systemd/system/mongod.service.d
50-CPUQuota.conf, 50-MemoryLimit.conf
Active: active (running) since Tue 2018-11-27 00:20:39 EST; 37min ago
Docs: man:systemd-sysv-generator(8)
Process: 52521 ExecStop=/etc/rc.d/init.d/mongod stop (code=exited, status=0/SUCCESS)
Process: 52662 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=0/SUCCESS)
Main PID: 52680 (mongod)
Memory: 142.2M (limit: 8.0G)
CGroup: /system.slice/mongod.service
52680 /bin/mongod -f /opt/mongodb/mongod.conf
...
Note: When your disk space is insufficient for large amounts of logs, you can modify the log settings in the mongod.conf file under the directory configured in the ConfPath parameter. For example, to reduce the log size, you can add the verbosity parameter to set the log level, or add the logRotate parameter to overwrite the log file. See the documentation on MongoDB official website for reference.
Tip: You do not need to initialize NetBrain data in the MongoDB Server because the initialization will be automatically performed when you install the Web API Server or Worker Server later.
Refer to the following table for the parameters of MongoDB Server.
Parameter |
Default Value |
Description |
---|---|---|
DBServiceName |
mongod |
The service name of the MongoDB Server. Keep the default name as it is. Note: The DBServiceName, DBSystemUser, and DBSystemGroup parameters can only contain letters and numbers. |
DBSystemUser |
netbrain |
The system user created on the Linux server to run the MongoDB service. Keep the default name as it is. Note: If you modified the default umask value, make sure this system user has the read and execute permissions to all the directories (including their parent directories) where the MongoDB Server is installed. These directories include that you specified in ConfPath, DataPath, LogPath, CertPath, and KeyPath. |
DBSystemGroup |
netbrain |
The system group created on the Linux server to run the MongoDB service. Keep the default name as it is. |
/opt/mongodb |
The storage path for the MongoDB configuration file. Note: If you modified the default umask value, you must run the chmod o+rx /opt/mongodb command to assign the read and execute permissions of the /opt/mongodb directory to the system user that you specify in the DBSystemUser parameter. This note also applies to DataPath, LogPath, CertPath, and KeyPath. Note: The ConfPath parameter has the following requirements. The same rules apply to the DataPath, LogPath, CertPath, and KeyPath parameters. - Cannot be placed under any personal directories. For example, /root is not allowed. - Cannot contain "/var/lib". For example, /var/lib/mogodb/log is not allowed. - Cannot contain any special characters or spaces, except slashes (/). |
|
DataPath |
/opt/mongodb/data |
The storage path for all MongoDB data files. Note: Make sure the destination directory has more than 50GB free space to save all the data files on the primary and secondary nodes, and has more than 30GB free space on the arbiter node. Tip: You can run the df -h command to check which directory has been mounted to a large disk. |
LogPath |
/opt/mongodb/log |
The storage path for all MongoDB log files. Note: Make sure the destination directory has more than 10GB free space to save all the log files. |
BindIp |
192.168.1.1 |
The IP address of this MongoDB Server. Note: Don't use 127.0.0.1. Note: Don't use 0.0.0.0 if you want to deploy a replica set. Note: If you modify the parameter to 0.0.0.0, you must use the fully qualified domain name (FQDN) in the ReplicaSetMembers parameter and the MongoDB connection information in the installation of other system components. |
DBPort |
27017 |
The port number that the MongoDB service listens to. Keep the default value as it is. |
ReplicaSetName |
rs |
The replica set name used for replication. Note: It can only contain letters and numbers, and must start with a letter. Note: Each member in the replica set must have the same replica set name, DBUser, and DBPassword. |
UseSSL |
no |
Whether to encrypt the connections to this MongoDB Server with SSL. To enable SSL, replace no with yes. For detailed requirements of SSL certificates and keys, see Appendix. |
Certificate |
/etc/ssl/cert.pem |
The name and storage path of certificate file that contains the public key. Note: It is required only if UseSSL is enabled. |
PrivateKey |
/etc/ssl/key.pem |
The name and storage path of the private key file. Note: It is required only if UseSSL is enabled. |
DBUser |
mongodb |
The admin username used to log into the MongoDB Server. Note: The value of the DBUser and DBPassword parameters cannot contain any of the following special characters, and their length cannot exceed 64 characters. |
DBPassword |
mongodb |
The admin password used to log into the MongoDB Server. |
CPULimit |
55% |
The maximum CPU utilization that can be consumed by the MongoDB Server. To make both MongoDB Server and Index Server share the CPU resources of the same machine, the recommended value is 55%. |
MemoryLimit |
55% |
The maximum memory capacity of the machine that can be consumed by the MongoDB Server. To make both MongoDB Server and Index Server utilize the memory resources of the same machine, the recommended value is 55%. |
ReplicaSetMembers |
192.168.1.1:27017 |
Enter the IP address or FQDN, and port number of the server. Note: Enter those of the cluster members in order if you deploy a replica set. |
See also:
▪Installing MongoDB Replica Set on Linux