mongodb is a database based on distributed file storage. Written in C++ language. The aim is to provide a scalable and high performance data storage solution for WEB applications.
MongoDB is a product between relational database and non-relational database, which has the most abundant functions and resembles relational database.
Install MongoDB
1. Create repo
vi /etc/yum.repos.d/mongodb-org-3.2.repo
[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1
2. Installing MongoDB and related tools
sudo yum install -y mongodb-org
3. Start MongoDB
4. Verify that MongoDB started successfully
cat /var/log/mongodb/mongod.log
Check if there is a sentence: [initandlisten] wait for connections on port < port >
Where < port > is configured in / etc/mongod.conf, port 27017 by default.
There is another way:
# sudo service mongod status Redirecting to /bin/systemctl status mongod.service ● mongod.service - High-performance, schema-free document-oriented database Loaded: loaded (/usr/lib/systemd/system/mongod.service; disabled; vendor preset: disabled) Active: active (running) since One 2016-09-12 09:50:16 CST; 15s ago Process: 8787 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited, status=0/SUCCESS) Main PID: 8842 (mongod) CGroup: /system.slice/mongod.service └─8842 /usr/bin/mongod --quiet -f /etc/mongod.conf run 9 Month 1209:50:13 192.168.1.155 systemd[1]: Starting High-performance, schema-free document-oriented database... 9 Month 1209:50:14 192.168.1.155 mongod[8787]: about to fork child process, waiting until server is ready for connections. 9 Month 1209:50:14 192.168.1.155 mongod[8787]: forked process: 8842 9 Month 1209:50:16 192.168.1.155 mongod[8787]: child process started successfully, parent exiting 9 Month 1209:50:16 192.168.1.155 systemd[1]: Started High-performance, schema-free document-oriented database.
You will see "Active: active (running)" indicating that it is running.
Not in operation:
# sudo service mongod status Redirecting to /bin/systemctl status mongod.service ● mongod.service - High-performance, schema-free document-oriented database Loaded: loaded (/usr/lib/systemd/system/mongod.service; disabled; vendor preset: disabled) Active: inactive (dead)
Active: inactive (dead)
5. Make MongoDB boot up automatically
sudo chkconfig mongod on
6. Stop MongoDB
sudo service mongod stop
7. Restart MongoDB
sudo service mongod restart
Enter the Mongo command line
# mongo MongoDB shell version: 2.6.12 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Server has startup warnings: 2016-09-12T09:50:14.195+0800 [initandlisten] 2016-09-12T09:50:14.195+0800 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb is set to 4096KB 2016-09-12T09:50:14.195+0800 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2016-09-12T09:50:14.195+0800 [initandlisten] ** http://dochub.mongodb.org/core/readahead >
MongoDB extension for installing PHP under Linux
Because MongoDB is manually installed, you also need to compile and install MongoDB extensions, as follows:
1) Download the latest PHP mongodb extension source code, the source code can be in http://pecl.php.net/package/mongo Download.
2) Unzip and enter the installation directory
wget http://pecl.php.net/get/mongo-1.4.0.tgz tar -zxvf mongo-1.4.0.tgz cd mongo-1.4.0
3) After entering the folder, first run phpize to compile the extended environment
/usr/bin/phpize
PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212
4) After running, we run the. / configure script to configure it.
`
./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
The parameter with-php-config tells the configuration script the path of the program php-config
5) Upon completion, edit your [php](http://lib.csdn.net/base/php).ini file and add a line extension=mongo.so.`
The default INI file for compiling PHP / usr/local/php/etc/php.ini restarts Apache/Nginx [or / etc/init.d/php-fpm restart] opens phpinfo to see the mongo module, proving that mongodb The php extension was successfully installed.
OK, so you can use php to operate MongoDB