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

安装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/查看可选的版本号
Install MongoDB Community Edition on Red Hat or CentOS 安装mongoDB_第1张图片

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.

Install MongoDB Community Edition on Red Hat or CentOS 安装mongoDB_第2张图片
这是因为用户simple没有执行sudo的权限。
/etc/sudoers的权限默认为440。先用root用户修改/etc/sudoers的权限

chmod 644 /etc/sudoers

然后在该文件中添加一行

simple	ALL=(ALL) 	ALL

Install MongoDB Community Edition on Red Hat or CentOS 安装mongoDB_第3张图片
然后恢复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."

Install MongoDB Community Edition on Red Hat or CentOS 安装mongoDB_第4张图片
在执行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

你可能感兴趣的:(linux,mongodb,mongodb,安装,redhat,install,yum)