CentOS7 yumのMongoDBのEnterprise Editionをインストールします

インストール

注意:ネットワークで、あなたはローカルソースはyumをインストール、設定することができない場合は、この記事のyumインストールは、ネットワーク接続モードで実行する必要があります。
インストールファイルをダウンロードしLinux7 https://repo.mongodb.com/yum/redhat/7/mongodb-enterprise/3.6/x86_64/RPMS/
LAN YUM・ソース構成https://blog.csdn.net/baidu_39459954/article/詳細/ 80619307


1、YUM倉庫を設定します

新しいレポファイル

vi /etc/yum.repos.d/mongodb-enterprise.repo

書きます

[mongodb-enterprise]
name=MongoDB Enterprise Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/3.6/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

2、インストール

sudo yum install mongodb-enterprise

インストールの記録

[root@yc ~]# yum install mongodb-enterprise
Loaded plugins: fastestmirror, langpacks
mongodb-enterprise                                                                                                                        | 2.5 kB  00:00:00     
mongodb-enterprise/7/x86_64/primary_db                                                                                                    |  35 kB  00:00:01     
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package mongodb-enterprise.x86_64 0:3.6.5-1.el7 will be installed
--> Processing Dependency: mongodb-enterprise-tools = 3.6.5 for package: mongodb-enterprise-3.6.5-1.el7.x86_64
--> Processing Dependency: mongodb-enterprise-shell = 3.6.5 for package: mongodb-enterprise-3.6.5-1.el7.x86_64
--> Processing Dependency: mongodb-enterprise-server = 3.6.5 for package: mongodb-enterprise-3.6.5-1.el7.x86_64
--> Processing Dependency: mongodb-enterprise-mongos = 3.6.5 for package: mongodb-enterprise-3.6.5-1.el7.x86_64
--> Running transaction check
---> Package mongodb-enterprise-mongos.x86_64 0:3.6.5-1.el7 will be installed
---> Package mongodb-enterprise-server.x86_64 0:3.6.5-1.el7 will be installed
--> Processing Dependency: net-snmp for package: mongodb-enterprise-server-3.6.5-1.el7.x86_64
--> Processing Dependency: libnetsnmpmibs.so.31()(64bit) for package: mongodb-enterprise-server-3.6.5-1.el7.x86_64
--> Processing Dependency: libnetsnmpagent.so.31()(64bit) for package: mongodb-enterprise-server-3.6.5-1.el7.x86_64
---> Package mongodb-enterprise-shell.x86_64 0:3.6.5-1.el7 will be installed
---> Package mongodb-enterprise-tools.x86_64 0:3.6.5-1.el7 will be installed
--> Running transaction check
---> Package net-snmp.x86_64 1:5.7.2-33.el7_5.2 will be installed
--> Processing Dependency: net-snmp-libs = 1:5.7.2-33.el7_5.2 for package: 1:net-snmp-5.7.2-33.el7_5.2.x86_64
---> Package net-snmp-agent-libs.x86_64 1:5.7.2-33.el7_5.2 will be installed
--> Running transaction check
---> Package net-snmp-libs.x86_64 1:5.7.2-28.el7 will be updated
---> Package net-snmp-libs.x86_64 1:5.7.2-33.el7_5.2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================
 Package                                       Arch                       Version                                   Repository                              Size
=================================================================================================================================================================
Installing:
 mongodb-enterprise                            x86_64                     3.6.5-1.el7                               mongodb-enterprise                     5.9 k
Installing for dependencies:
 mongodb-enterprise-mongos                     x86_64                     3.6.5-1.el7                               mongodb-enterprise                      12 M
 mongodb-enterprise-server                     x86_64                     3.6.5-1.el7                               mongodb-enterprise                      21 M
 mongodb-enterprise-shell                      x86_64                     3.6.5-1.el7                               mongodb-enterprise                      12 M
 mongodb-enterprise-tools                      x86_64                     3.6.5-1.el7                               mongodb-enterprise                      59 M
 net-snmp                                      x86_64                     1:5.7.2-33.el7_5.2                        updates                                330 k
 net-snmp-agent-libs                           x86_64                     1:5.7.2-33.el7_5.2                        updates                                705 k
Updating for dependencies:
 net-snmp-libs                                 x86_64                     1:5.7.2-33.el7_5.2                        updates                                749 k

Transaction Summary
=================================================================================================================================================================
Install  1 Package  (+6 Dependent packages)
Upgrade             ( 1 Dependent package)

Total size: 105 M
Total download size: 104 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mongodb-enterprise/packages/mongodb-enterprise-3.6.5-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 91fa4ad5: NOKEY                                                                                ]  0.0 B/s |    0 B  --:--:-- ETA 
Public key for mongodb-enterprise-3.6.5-1.el7.x86_64.rpm is not installed
(1/7): mongodb-enterprise-3.6.5-1.el7.x86_64.rpm                                                                                                                                                                                                       | 5.9 kB  00:00:01     
(2/7): mongodb-enterprise-mongos-3.6.5-1.el7.x86_64.rpm                                                                                                                                                                                                |  12 MB  00:00:03     
(3/7): mongodb-enterprise-server-3.6.5-1.el7.x86_64.rpm                                                                                                                                                                                                |  21 MB  00:00:03     
(4/7): mongodb-enterprise-shell-3.6.5-1.el7.x86_64.rpm                                                                                                                                                                                                 |  12 MB  00:00:01     
(5/7): net-snmp-5.7.2-33.el7_5.2.x86_64.rpm                                                                                                                                                                                                            | 330 kB  00:00:00     
(6/7): net-snmp-agent-libs-5.7.2-33.el7_5.2.x86_64.rpm                                                                                                                                                                                                 | 705 kB  00:00:00     
(7/7): mongodb-enterprise-tools-3.6.5-1.el7.x86_64.rpm                                                                                                                                                                                                 |  59 MB  00:00:04     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                          12 MB/s | 104 MB  00:00:08     
Retrieving key from https://www.mongodb.org/static/pgp/server-3.6.asc
Importing GPG key 0x91FA4AD5:
 Userid     : "MongoDB 3.6 Release Signing Key <[email protected]>"
 Fingerprint: 2930 adae 8caf 5059 ee73 bb4b 5871 2a22 91fa 4ad5
 From       : https://www.mongodb.org/static/pgp/server-3.6.asc
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:net-snmp-libs-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                                    1/9 
  Installing : 1:net-snmp-agent-libs-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                              2/9 
  Installing : 1:net-snmp-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                                         3/9 
  Installing : mongodb-enterprise-server-3.6.5-1.el7.x86_64                                                                                                                                                                                                               4/9 
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
  Installing : mongodb-enterprise-shell-3.6.5-1.el7.x86_64                                                                                                                                                                                                                5/9 
  Installing : mongodb-enterprise-mongos-3.6.5-1.el7.x86_64                                                                                                                                                                                                               6/9 
  Installing : mongodb-enterprise-tools-3.6.5-1.el7.x86_64                                                                                                                                                                                                                7/9 
  Installing : mongodb-enterprise-3.6.5-1.el7.x86_64                                                                                                                                                                                                                      8/9 
  Cleanup    : 1:net-snmp-libs-5.7.2-28.el7.x86_64                                                                                                                                                                                                                        9/9 
  Verifying  : mongodb-enterprise-tools-3.6.5-1.el7.x86_64                                                                                                                                                                                                                1/9 
  Verifying  : 1:net-snmp-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                                         2/9 
  Verifying  : 1:net-snmp-libs-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                                    3/9 
  Verifying  : mongodb-enterprise-3.6.5-1.el7.x86_64                                                                                                                                                                                                                      4/9 
  Verifying  : 1:net-snmp-agent-libs-5.7.2-33.el7_5.2.x86_64                                                                                                                                                                                                              5/9 
  Verifying  : mongodb-enterprise-mongos-3.6.5-1.el7.x86_64                                                                                                                                                                                                               6/9 
  Verifying  : mongodb-enterprise-shell-3.6.5-1.el7.x86_64                                                                                                                                                                                                                7/9 
  Verifying  : mongodb-enterprise-server-3.6.5-1.el7.x86_64                                                                                                                                                                                                               8/9 
  Verifying  : 1:net-snmp-libs-5.7.2-28.el7.x86_64                                                                                                                                                                                                                        9/9 

Installed:
  mongodb-enterprise.x86_64 0:3.6.5-1.el7                                                                                                                                                                                                                                     

Dependency Installed:
  mongodb-enterprise-mongos.x86_64 0:3.6.5-1.el7 mongodb-enterprise-server.x86_64 0:3.6.5-1.el7 mongodb-enterprise-shell.x86_64 0:3.6.5-1.el7 mongodb-enterprise-tools.x86_64 0:3.6.5-1.el7 net-snmp.x86_64 1:5.7.2-33.el7_5.2 net-snmp-agent-libs.x86_64 1:5.7.2-33.el7_5.2

Dependency Updated:
  net-snmp-libs.x86_64 1:5.7.2-33.el7_5.2                                                                                                                                                                                                                                     

Complete!
[root@yc ~]# 

3、インストールが成功したかどうかをチェック

[root@yc ~]# rpm -qa | grep mongodb
mongodb-enterprise-3.6.5-1.el7.x86_64
mongodb-enterprise-shell-3.6.5-1.el7.x86_64
mongodb-enterprise-mongos-3.6.5-1.el7.x86_64
mongodb-enterprise-tools-3.6.5-1.el7.x86_64
mongodb-enterprise-server-3.6.5-1.el7.x86_64

図4に示すように、コンフィギュレーションのSELinux

方法、開いているポート(デフォルトは27017です)

semanage port -a -t mongod_port_t -p tcp 27017

selinuxをオフにする方法2、

vi /etc/selinux/config

修正

SELINUX=disabled

図5に示すように、設定パラメータ

プロフィールの編集

vi /etc/mongod.conf

YUMのIPアドレスを追加し、ローカル介して接続することができ、システムのデフォルトの127.0.0.1のインストール後192.168.88.58を bindIpに、あなたは、カンマで区切って、複数のIPを追加することができます

bindIp: 127.0.0.1,192.168.88.58

6、開始及び検討

コマンドを起動し
mongod.service開始systemctl
チェックコマンド
systemctlステータスmongod.serviceを

[root@yc ~]# systemctl start mongod.service 
[root@yc ~]# systemctl status mongod.service 
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2018-06-11 12:03:31 CST; 1s ago
     Docs: https://docs.mongodb.org/manual
  Process: 3078 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 3075 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 3073 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 3066 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 3081 (mongod)
   CGroup: /system.slice/mongod.service
           └─3081 /usr/bin/mongod -f /etc/mongod.conf

Jun 11 12:03:30 yc systemd[1]: Starting High-performance, schema-free document-oriented database...
Jun 11 12:03:31 yc mongod[3078]: about to fork child process, waiting until server is ready for connections.
Jun 11 12:03:31 yc mongod[3078]: forked process: 3081
Jun 11 12:03:31 yc mongod[3078]: child process started successfully, parent exiting
Jun 11 12:03:31 yc systemd[1]: Started High-performance, schema-free document-oriented database.
[root@yc ~]# netstat -nltp|grep mongo
tcp        0      0 192.168.88.58:27017     0.0.0.0:*               LISTEN      27984/mongod        
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      27984/mongod 

7、MongoDBのシェルを開きます

MongoDBは、モンゴシェルを開くために、サーバー上で実行されているアドレスとポート番号を指定する* -host *オプションを使用している
例:

mongo --host 127.0.0.1:27017

Mongoの警告:

MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.5
Server has startup warnings: 
2018-07-05T10:12:13.538+0800 I CONTROL  [initandlisten] 
2018-07-05T10:12:13.538+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-05T10:12:13.538+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-05T10:12:13.538+0800 I CONTROL  [initandlisten] 
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] 
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] 
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-07-05T10:12:13.539+0800 I CONTROL  [initandlisten] 

私たちは、実行時にこの問題を解決する場合は、すべてではないが難しい、ちょうどそれにhugepageセットを変更する必要があります。次の2つのコマンドを実行します

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

あなたのMongoDBを再起動することを忘れないでください、この警告は消えました。しかし、あなたは、システムを再起動する次回は、これらの設定が消えてしまいます。それは/etc/rc.localの中で設定することができます


アンインストール

1、MongoDBのを止めます

sudo service mongod stop

2、アンインストールパッケージ

sudo yum erase $(rpm -qa | grep mongodb-enterprise)

3、データベースとログを削除

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo

参考:
https://docs.mongodb.com/manual/tutorial/install-mongodb-enterprise-on-red-hat/

おすすめ

転載: blog.csdn.net/baidu_39459954/article/details/80650473