六月丁香五月婷婷,丁香五月婷婷网,欧美激情网站,日本护士xxxx,禁止18岁天天操夜夜操,18岁禁止1000免费,国产福利无码一区色费

學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 網(wǎng)絡(luò)知識 > 網(wǎng)絡(luò)技術(shù) >

Linux安裝配置mongodb方法教程

時間: 加城1195 分享

  MongoDB 是一個基于分布式文件存儲的數(shù)據(jù)庫,不少用戶在Linux系統(tǒng)安裝和配置mongodb上吃了一些苦頭,下面小編就給大家介紹下mongodb的安裝配置方法。

  Linux安裝配置mongodb的方法

  1. 安裝準(zhǔn)備

  將mongodb移動到/usr/local/server/mongdb文件夾

  mv mongodb-linux-i686-1.4.4 /usr/local/mongodb

  創(chuàng)建數(shù)據(jù)庫文件夾與日志文件

  mkdir /usr/local/mongodb/data

  touch /usr/local/mongodb/logs

  3. 設(shè)置開機(jī)自啟動

  將mongodb啟動項(xiàng)目追加入rc.local保證mongodb在服務(wù)器開機(jī)時啟動

  echo “/usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –auth –port=27017″ 》》 /etc/rc.local

  echo “/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data –

  logpath=/usr/local/mongodb/logs –logappend –auth –port=27017″ 》》 /etc/rc.local

  4. 啟動mongodb

  cd到mongodb目錄下的bin文件夾啟動mongodb

  //下面這個是需要權(quán)限的登錄方式, 用戶連接需要用戶名和密碼

  /usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –auth –port=27017 –fork

  //這個是不需要密碼的

  /usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –port=27017 –fork

  5. 參數(shù)解釋: –dbpath 數(shù)據(jù)庫路徑(數(shù)據(jù)文件)

  –logpath 日志文件路徑

  –master 指定為主機(jī)器

  –slave 指定為從機(jī)器

  –source 指定主機(jī)器的IP地址

  –pologSize 指定日志文件大小不超過64M.因?yàn)閞esync是非常操作量大且耗時,最好通過設(shè)置一個足夠大的

  oplogSize來避免resync(默認(rèn)的 oplog大小是空閑磁盤大小的5%)。

  –logappend 日志文件末尾添加

  –port 啟用端口號

  –fork 在后臺運(yùn)行

  –only 指定只復(fù)制哪一個數(shù)據(jù)庫

  –slavedelay 指從復(fù)制檢測的時間間隔

  –auth 是否需要驗(yàn)證權(quán)限登錄(用戶名和密碼)

  -h [ --help ] show this usage information

  –version show version information

  -f [ --config ] arg configuration file specifying additional options

  –port arg specify port number

  –bind_ip arg local ip address to bind listener – all local ips

  bound by default

  -v [ --verbose ] be more verbose (include multiple times for more

  verbosity e.g. -vvvvv)

  –dbpath arg (=/data/db/) directory for datafiles 指定數(shù)據(jù)存放目錄

  –quiet quieter output 靜默模式

  –logpath arg file to send all output to instead of stdout 指定日志存放目錄

  –logappend appnd to logpath instead of over-writing 指定日志是以追加還是以覆蓋的方

  式寫入日志文件

  –fork fork server process 以創(chuàng)建子進(jìn)程的方式運(yùn)行

  –cpu periodically show cpu and iowait utilization 周期性的顯示cpu和io的使用情

  況

  –noauth run without security 無認(rèn)證模式運(yùn)行

  –auth run with security 認(rèn)證模式運(yùn)行

  –objcheck inspect client data for validity on receipt 檢查客戶端輸入數(shù)據(jù)的有效性檢

  查

  –quota enable db quota management 開始數(shù)據(jù)庫配額的管理

  –quotaFiles arg number of files allower per db, requires –quota 規(guī)定每個數(shù)據(jù)庫允許的文

  件數(shù)

  –appsrvpath arg root directory for the babble app server

  –nocursors diagnostic/debugging option 調(diào)試診斷選項(xiàng)

  –nohints ignore query hints 忽略查詢命中率

  –nohttpinterface disable http interface 關(guān)閉http接口,默認(rèn)是28017

  –noscripting disable scripting engine 關(guān)閉腳本引擎

  –noprealloc disable data file preallocation 關(guān)閉數(shù)據(jù)庫文件大小預(yù)分配

  –smallfiles use a smaller default file size 使用較小的默認(rèn)文件大小

  –nssize arg (=16) .ns file size (in MB) for new databases 新數(shù)據(jù)庫ns文件的默認(rèn)大小

  –diaglog arg 0=off 1=W 2=R 3=both 7=W+some reads 提供的方式,是只讀,只寫,還是讀寫都

  行,還是主要寫+部分的讀模式

  –sysinfo print some diagnostic system information 打印系統(tǒng)診斷信息

  –upgrade upgrade db if needed 如果需要就更新數(shù)據(jù)庫

  –repair run repair on all dbs 修復(fù)所有的數(shù)據(jù)庫

  –notablescan do not allow table scans 不運(yùn)行表掃描

  –syncdelay arg (=60) seconds between disk syncs (0 for never) 系統(tǒng)同步刷新磁盤的時間,默認(rèn)是

  60s

  Replication options:

  –master master mode 主復(fù)制模式

  –slave slave mode 從復(fù)制模式

  –source arg when slave: specify master as 《server:port》 當(dāng)為從時,指定主的地址和端口

  –only arg when slave: specify a single database to replicate 當(dāng)為從時,指定需要從主復(fù)

  制的單一庫

  –pairwith arg address of server to pair with

  –arbiter arg address of arbiter server 仲裁服務(wù)器,在主主中和pair中用到

  –autoresync automatically resync if slave data is stale 自動同步從的數(shù)據(jù)

  –oplogSize arg size limit (in MB) for op log 指定操作日志的大小

  –opIdMem arg size limit (in bytes) for in memory storage of op ids指定存儲操作日志的內(nèi)存

  大小

  Sharding options:

  –configsvr declare this is a config db of a cluster 指定shard中的配置服務(wù)器

  –shardsvr declare this is a shard db of a cluster 指定shard服務(wù)器

  6. 進(jìn)入數(shù)據(jù)庫的CLI管理界面

  cd到mongodb目錄下的bin文件夾,執(zhí)行命令。/mongo

  運(yùn)行如下:

  [root@namenode mongodb]# 。/bin/mongo

  MongoDB shell version: 1.8.2

  connecting to: test

  》 use test;

  switched to db test

  若數(shù)據(jù)庫出現(xiàn)如不能連上,則是一個data目錄下的mongod.lock文件的問題,可以用如下的修復(fù)的命令,

  mongod –repair

  補(bǔ)充:MySQL 數(shù)據(jù)庫常用命令

  create database name; 創(chuàng)建數(shù)據(jù)庫

  use databasename; 進(jìn)入數(shù)據(jù)庫

  drop database name 直接刪除數(shù)據(jù)庫,不提醒

  show tables; 顯示表

  describe tablename; 查看表的結(jié)構(gòu)

  select 中加上distinct去除重復(fù)字段

  mysqladmin drop databasename 刪除數(shù)據(jù)庫前,有提示。

  顯示當(dāng)前mysql版本和當(dāng)前日期

  select version(),current_date;

  數(shù)據(jù)庫維護(hù)方法

  在MySQL使用的過程中,在系統(tǒng)運(yùn)行一段時間后,可能會產(chǎn)生碎片,造成空間的浪費(fèi),所以有必要定期的對MySQL進(jìn)行碎片整理。

  當(dāng)刪除id=2的記錄時候,發(fā)生的現(xiàn)象

  這個時候發(fā)現(xiàn)磁盤的空間并沒有減少。這種現(xiàn)象就叫做碎片化(有一部分的磁盤空間在數(shù)據(jù)刪除以后(空),還是無法被操作系統(tǒng)所使用。)

  常見的優(yōu)化:

  # alter table xxx engine myisam;

  # optimize table t1;

  注意: 在實(shí)際開發(fā)的過程中,上面兩個語句盡量少使用,因?yàn)樵谑褂玫倪^程中,MySQL的表的結(jié)構(gòu)會整體全部重新整理,需要消耗很多的資源,建議在凌晨兩三點(diǎn)鐘的時候執(zhí)行。(在linux下有定時器腳本可以執(zhí)行,crontab)


DB數(shù)據(jù)庫相關(guān)文章:

1.linux sqlite3命令

2.qq聊天記錄db文件怎么打開

3.db是什么意思

4.linux關(guān)閉db2數(shù)據(jù)庫命令

5.MyEclipse9.0怎么配置數(shù)據(jù)庫

4015299