EverKB

Knowledge Base Ever

Installige MongoDB4 CentOS7-le

2019-11-15 11:30:33

Silt: CentOS, MongoDB, CentOS7, MongoDB4, Install MongoDB, Installige MongoDB

Redigeeri faili /etc/yum.repos.d/mongodb-enterprise.repo

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

Installige YUM-i abil

yum -y install mongodb-enterprise

Looge andmekataloog ja logikataloog ning andke kataloogile õigused

mkdir -p /var/lib/mongo
mkdir -p /var/log/mongodb
chown -R mongod:mongod /var/lib/mongo
chown -R mongod:mongod /var/log/mongodb

Seadistage alglaadimine ja käivitage teenus

systemctl enable mongod
systemctl start mongod

Loo kasutaja

[root@carbon ~]# mongo
MongoDB shell version v4.0.11
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("bf1a80fb-6a70-4bdb-86c7-8b3587400f87") }
MongoDB server version: 4.0.11
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.createUser(
...   {
...     user: "admin",
...     pwd: "admin",
...     roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
...   }

Luba volitatud sisselogimine

Vaikimisi on MongoDB juurdepääsetav ainult selles masinas. Volitatud sisselogimist saate lubada, muutes faili /etc/mongod.conf.

Muutke bindIp väärtuseks 0.0.0.0 ja taaskäivitage teenus pärast volitatud konfiguratsiooni lisamist reale #secruity.
# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.

#security:
security:
  authorization: enabled
systemctl restart mongod
Sel hetkel saate kliendi abil kaugühenduse luua. Kliendi konfiguratsioon on järgmine:

IP: [MongoDB IP]
Port: 27017
Loa vorm: admin
Kasutaja: admin
Parool: admin

Veenduge, et installimine õnnestub, testige mongo käsurida täiendusi ja kustutusi

[root@carbon ~]# mongo --port 27017 -u "admin" --authenticationDatabase "admin" -p
MongoDB shell version v4.0.11
Enter password: 
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("dfe7aba3-9c0c-45cb-bf7b-457453c218ce") }
MongoDB server version: 4.0.11
MongoDB Enterprise > db.foo.insert( { x: 1, y: 1 } )
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > db.foo.find()
{ "_id" : ObjectId("5d45f6e21d57d1717b175746"), "x" : 1, "y" : 1 }
MongoDB Enterprise > db.foo.deleteOne({_id: ObjectId("5d45f6e21d57d1717b175746")})
{ "acknowledged" : true, "deletedCount" : 1 }
MongoDB Enterprise > db.foo.find()
MongoDB Enterprise > db.foo.drop()
true
MongoDB Enterprise > exit
bye

Silt

CentOS7 CentOS PHP Linux Python3 Python MySQL MariaDB YUM JavaScript CSS Redis MySQL8 caching_sha2_password HTML mysql_native_password PHP7 unixODBC-devel height network interface Shadowsocks-Libev Aura error_get_last Port 80 string Web Development data INDENTIFIED BY password policy requirements SOCKS Fedora Media Writer msodbcsql Redis5 SVN absolute Deepin jemalloc SQLAlchemy toggle convert FuelPHP mysqlclient Shadowsocks at-symbol Error Control Operator margin PHPUnit Framework ss5.passwd vps daemon process IIS password SOCKET center Fatal Errors MongoDB4 sudoers WiFi .htaccess DATE_SUB Phalcon SQL Server 2017 TestCase Compiling PHP frequency conflict set_error_handler apr Elasticsearch7.3 PHPUnit ss5.conf Vincent Garreau daemon HTTP particles.js Slim Failed to build these modules: _uuid MongoDB Sudo width DATE_ADD ip command pg_bha.conf SQL Server Tcp BBR Compiling Apache Frameworks MySQL-python scrollbar Apache2.4 Elasticsearch libpython3.7m.so.1.0 PHPStorm ss5-3.8.9 VIM CURLOPT_POSTFIELDS NodeJs show Bluetooth Failed to build these modules: _ctypes Minimal ISO substr Wi-Fi date sub INTERVAL PECL SQL Date Funcitons Tag Cloud CodeIgniter font-size root apache httpd dual network interfaces Laravel ss5 vertical-align CURLFille horiz-align node.js ShadowsocksR BarManager exec mb_substr PyCharm SUBDATE WebStorm date add IntelliJIDEA PEAR SOCKS5 Proxy Server Tag Chrome find remi Apache du jQuery PHP5.5 src V2Ray cURL hide nginx Shadowsocks-Python availability eth0 MariaDB10.4 PostgreSQL sub folder Web Server date Install MongoDB pdo_sqlsrv SOCKS5 File Upload mssql-tools register_shutdown_function Symfony Zend Framework ADDDATE DevExpress JetBrain php-fpm sqlsrv