MongoDB作为一种文档型的NoSQL数据库,使用起来非常灵活,回避了关系型数据库前期的复杂数据库设计。MongoDB存储基于JSON格式,同
MongoDB部署实验系列文章,MongoDB做为NoSQL数据库,最近几年持续升温,越来越多的企业都开始尝试用MongoDB代替原有Database做一些事情。MongoDB也在集群,分片,复制上也有相当不错的的表现。我通过将做各种MongoDB的部署实验进行介绍。
前言
MongoDB作为一种文档型的NoSQL数据库,使用起来非常灵活,回避了关系型数据库前期的复杂数据库设计。MongoDB存储基于JSON格式,同时用Javascript做为数据库操作语言,给了使用者无限想象的空间,可以通过编程在MongoDB服务器中解决非常复杂的条件查询的问题。
目录
1 MongoDB在Windows中安装在Windows系统上安装MongoDB数据库是件非常简单的事情,下载可执行安装文件(exe),双击安装即可。下载地址:
本文使用的Linux是Ubuntu 12.04.2 LTS 64bit的系统,安装MongoDB数据库软件包可以通过apt-get实现。但我们修要安装官方提供MongoDB软件源。
修改apt的source.list文件,增加10gen的设置。
# 下载密钥文件 ~ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.kVFab9XYw0 --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 gpg: 下载密钥‘7F0CEB10’,从 hkp 服务器 keyserver.ubuntu.com gpg: 密钥 7F0CEB10:公钥“Richard Kreuter在Linux Ubuntu中安装MongoDB数据库
#安装MongoDB服务器端 ~ sudo apt-get install mongodb-10gen安装完成后,MongoDB服务器会自动启动,我们检查MongoDB服务器程序
# 检查MongoDB服务器系统进程 ~ ps -aux|grep mongo mongodb 6870 3.7 0.4 349208 39740 ? Ssl 10:27 2:23 /usr/bin/mongod --config /etc/mongodb.conf # 通过启动命令检查MongoDB服务器状态 ~ netstat -nlt|grep 27017 tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN # 通过启动命令检查MongoDB服务器状态 ~ sudo /etc/init.d/mongodb status Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service mongodb status Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the status(8) utility, e.g. status mongodb mongodb start/running, process 6870 # 通过系统服务检查MongoDB服务器状态 ~ sudo service mongodb status mongodb start/running, process 6870通过web的控制台,查看MongoDB服务器的状态。在浏览器输入 :28017 ,,就可以打开通过web的控制台了。
安装MongoDB服务器,会自动地一起安装MongoDB命令行客户端程序。
在本机输入mongo命令就可以启动,客户端程序访问MongoDB服务器。
~ mongo MongoDB shell version: 2.4.9 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see Questions? Try the support group # 查看命令行帮助 > help db.help() help on db methods db.mycoll.help() help on collection methods sh.help() sharding helpers rs.help() replica set helpers help admin administrative help help connect connecting to a db help help keys key shortcuts help misc misc things to know help mr mapreduce show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms show logs show the accessible logger names show log [name] prints out the last segment of log in memory, 'global' is default useMongoDB服务器,默认情况下是允许外部访问的。这样单节的MongoDB,我们已经成功地安装在Linux Ubuntu系统中。
MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里
相关阅读:
MongoDB备份与恢复
CentOS编译安装MongoDB
CentOS 编译安装 MongoDB与mongoDB的php扩展
CentOS 6 使用 yum 安装MongoDB及服务器端配置
Ubuntu 13.04下安装MongoDB2.4.3
如何在MongoDB中建立新数据库和集合
MongoDB入门必读(概念与实战并重)
《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
