日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Install MongoDB Community Edition on Red Hat or CentOS 安裝mongoDB

作者:win_turn 更新時間: 2022-04-19 編程語言

安裝mongoDB

  • 配置yum
  • yum安裝
  • 碰到的問題
    • sudoers
    • curl

配置yum

創建/etc/yum.repos.d/mongodb-org-4.2.repo文件

cat > /etc/yum.repos.d/mongodb-org-4.2.repo << EOF
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
EOF

文件中的$releasever需要修改成自己系統的版本號
例如,我的版本是7,那么這行就是

baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/

可以用瀏覽器打開https://repo.mongodb.org/yum/redhat/查看可選的版本號
在這里插入圖片描述

yum安裝

執行yum命令安裝

sudo yum install -y mongodb-org

碰到的問題

sudoers

[simple@redhat_1 ~]$ sudo yum install -y mongodb-org

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for simple: 
simple is not in the sudoers file.  This incident will be reported.

在這里插入圖片描述
這是因為用戶simple沒有執行sudo的權限。
/etc/sudoers的權限默認為440。先用root用戶修改/etc/sudoers的權限

chmod 644 /etc/sudoers

然后在該文件中添加一行

simple	ALL=(ALL) 	ALL

在這里插入圖片描述
然后恢復chmod 440 /etc/sudoers文件的默認權限

chmod 440 /etc/sudoers

curl

Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
https://repo.mongodb.org/yum/redhat/%24releasever/mongodb-org/4.2/x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "Peer reports incompatible or unsupported protocol version."
Trying other mirror.


 One of the configured repositories failed (MongoDB Repository),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=mongodb-org-4.2 ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable mongodb-org-4.2
        or
            subscription-manager repos --disable=mongodb-org-4.2

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=mongodb-org-4.2.skip_if_unavailable=true

failure: repodata/repomd.xml from mongodb-org-4.2: [Errno 256] No more mirrors to try.
https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "Peer reports incompatible or unsupported protocol version."

在這里插入圖片描述
在執行sudo yum install -y mongodb-org時,報錯[Errno 14] curl#35 - “Peer reports incompatible or unsupported protocol version.”

更新curl

sudo yum update -y nss curl libcurl

原文鏈接:https://blog.csdn.net/win_turn/article/details/106372335

欄目分類
最近更新