<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                #### Mongodb發行了兩個可用的服務版本:社區版和企業版 我們所使用的的Mongodb為社區版 **官方推薦:** 為了獲得最佳的安裝體驗,MongoDB提供了適用于流行Linux發行版的軟件包。 這些軟件包是運行MongoDB的首選方式。 **1、linux平臺支持** #### 在Red Hat上安裝 支持在Red Hat Enterprise和相關Linux系統上安裝MongoDB Community Edition。 #### 在Ubuntu上安裝 支持在Ubuntu Linux系統上安裝MongoDB Community Edition。 #### 在Debian上安裝 支持在Debian系統上安裝MongoDB Community Edition。 #### 在SUSE上安裝 支持在SUSE Linux系統上安裝MongoDB Community Edition。 #### 在亞馬遜上安裝 支持在Amazon Linux AMI系統上安裝MongoDB Community Edition。 ### MongoDB不支持Linux的Windows子系統(WSL)。 **2、Mac OS平臺支持** MongoDB 4.2 Community Edition支持macOS 10.12或更高版本。 **3、Windos平臺支持** MongoDB 4.2 Community Edition在x86_64架構上支持Windows的以下64位版本: >Windows Server 2019 Windows 10 / Windows Server 2016 Windows 8.1 / Windows Server 2012 R2 Windows 8 / Windows Server 2012 Windows 7 / Windows Server 2008 R2 MongoDB僅支持這些平臺的64位版本。 ### **Centos 系統安裝Mongodb 前系統優化** 1、系統禁止THP 2、設置系統 `ulimit` 3、關閉iptables和SElinux #### **1、為什么要禁止THP** 自[CentOS]6版本開始引入了Transparent Huge Pages(THP),從CentOS7版本開始,該特性默認就會啟用。盡管THP的本意是為提升內存的性能,不過某些數據庫廠商還是建議直接關閉THP(比如說[Oracle]、MariaDB、MongoDB等),透明的Huge Pages可能會在運行時引起內存分配延遲,透明的大頁(THP)是一種Linux內存管理系統,它可以減少機器上的后備緩沖區(TLB)查找的開銷。 **查看THP的啟動狀態:** >[root@master ~]# cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never [root@master ~]# cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never **運行以下命令即時禁用THP** >[root@master ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled [root@master ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag [root@master ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] [root@master ~]# cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never] 但是系統重啟一會就不生效了。 #### **使用服務來控制THP** 兩重方式都可以 **systemd (systemctl)** [root@master ~]# cat /etc/systemd/system/disable-transparent-huge-pages.service ``` [Unit] Description=Disable Transparent Huge Pages (THP) DefaultDependencies=no After=sysinit.target local-fs.target Before=mongod.service [Service] Type=oneshot ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null' ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/defrag > /dev/null' [Install] WantedBy=basic.target ``` >[root@master ~]# systemctl daemon-reload [root@master ~]# systemctl enable disable-transparent-huge-pages [root@master ~]# systemctl start disable-transparent-huge-pages **System V Init (service)** [root@master ~]# /etc/init.d/disable-transparent-hugepages ``` #!/bin/bash ### BEGIN INIT INFO # Provides: disable-transparent-hugepages # Required-Start: $local_fs # Required-Stop: # X-Start-Before: mongod mongodb-mms-automation-agent # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Disable Linux transparent huge pages # Description: Disable Linux transparent huge pages, to improve # database performance. ### END INIT INFO case $1 in start) if [ -d /sys/kernel/mm/transparent_hugepage ]; then thp_path=/sys/kernel/mm/transparent_hugepage elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then thp_path=/sys/kernel/mm/redhat_transparent_hugepage else return 0 fi echo 'never' | tee ${thp_path}/enabled > /dev/null unset thp_path ;; esac ``` >[root@master ~]# chmod 755 /etc/init.d/disable-transparent-hugepages [root@master ~]# chkconfig --add disable-transparent-hugepages [root@master ~]# /etc/init.d/disable-transparent-hugepages start ### 2、UNIX ulimit 設置 大多數類似UNIX的操作系統(包括Linux和macOS)都提供了一種方法來限制和控制基于進程和用戶的系統資源(例如線程,文件和網絡連接)的使用。這些“ ulimit”可防止單個用戶使用過多的系統資源。有時,這些限制的默認值較低,在正常的MongoDB操作過程中可能會導致許多問題。 mongod并且mongos每次使用線程和文件描述符跟蹤連接并管理內部操作。本節概述了MongoDB的常規資源利用模式。將這些數字與有關您的部署及其使用的實際信息結合使用,以確定理想的ulimit設置。 通常,所有mongod和mongos實例: * 使用文件描述符和線程跟蹤每個傳入的連接。 * 跟蹤每個內部線程或pthread作為系統進程 `ulimit`指的是針對每個用戶的各種資源限制。因此,如果您的[`mongod`]實例是以同時運行多個進程或多個[`mongod`]進程的用戶身份執行的,則可能會看到這些資源的爭用。另外,請注意,`processes`值(即`-u`)是指不同進程和子進程線程的組合數量。 您可以`ulimit`通過發出以下格式的命令來更改設置: > ulimit -n <值> 硬和軟的ulimit設置會影響到Mongodb的性能,硬ulimit是指用戶可以激活的最大進程數, 紅帽企業Linux和CentOS 6和7強制執行一個單獨的最大進程限制`nproc`,該限制將覆蓋`ulimit`設置。該值在以下配置文件中定義,具體取決于版本: | 系統版本 | 值 | 文件 | | --- | --- | --- | | RHEL / CentOS 7 | 4096 |/etc/security/limits.d/20-nproc.conf| |RHEL / CentOS 6 | 1024|/etc/security/limits.d/90-nproc.conf | **修改ulimit兩種方法** ``` 1、添加配置信息: [root@master ~]# vim /etc/security/limits.d/20-nproc.conf * soft nproc 64000 * soft nofile 64000 ``` 重啟mongodb服務 ``` 2、添加配置 [root@master ~]#vim /etc/security/limits.conf mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 32000 mongod hard nproc 32000 ``` 重啟 mongodb服務: ### 3、關閉iptables和SElinux >systemctl status firewalld.service systemctl stop firewalld.service systemctl disable firewalld.service 配置文件:/etc/selinux/config 將參數設置為: SELINUX=disabled ### 服務器時區:我們要配置時間服務保證服務器時間是一致的。 ### 4、Mongodb 啟動和停止服務 mongodb 啟動: 推薦第二種方式 1、mongod --port 12345 --dbpath /srv/mongodb/ 2、mongod -f /data/mongodb/conf/mongodb.conf >停止mongod進程可以采用 1、kill -2 (mongod process ID) 2、kill (mongod process ID) 3、mongod --shutdown 4、db.shutdownServer() 前兩種方式就不介紹了: 3、 --shutdown ``` [root@10-1-1-159 ~]# sudo -u mongod /data/mongodb-4.2.2/bin/mongod -f /data/mongodb/conf/mongodb.conf --shutdown killing process with pid: 28761 ``` 4、db.shutdownServer() ``` [root@10-1-1-159 ~]# sudo -u mongod /data/mongodb-4.2.2/bin/mongo 10.1.1.159:27010 rs02:SECONDARY> db.getMongo().setSlaveOk() rs02:SECONDARY> use admin switched to db admin rs02:SECONDARY> db.shutdownServer() 2020-03-20T14:37:28.602+0800 E QUERY [js] Error: shutdownServer failed: { "operationTime" : Timestamp(1584686240, 1), "ok" : 0, "errmsg" : "shutdown must run from localhost when running db without auth", "code" : 13, "codeName" : "Unauthorized", "$clusterTime" : { "clusterTime" : Timestamp(1584686240, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype.shutdownServer@src/mongo/shell/db.js:426:19 @(shell):1:1 rs02:SECONDARY> ``` 需要使用localhost連接mongo實例,在配置文件啟動時候添加: >bindIp: 10.1.1.159,localhost ``` [root@10-1-1-159 ~]# sudo -u mongod /data/mongodb-4.2.2/bin/mongo localhost:27020 > use admin switched to db admin > db.shutdownServer() 2020-03-20T14:47:49.186+0800 I NETWORK [js] DBClientConnection failed to receive message from localhost:27020 - HostUnreachable: Connection closed by peer server should be down... ``` 切勿使用kill -9(即SIGKILL)終止mongod實例。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看