linux查看mongodb版本
① linux查看版本命令問題
Linux下查看版本號的命令
1,查看內核版本命令:
cat /proc/version
uname -a
uname -rcat /etc/issue
man uname
2,查看linux版本:抄錄如下:
1) 登錄到伺服器執行 lsb_release -a ,即可列出所有版本信息,例如:
[[email protected] ~]# lsb_release -a
LSB Version: 1.3
Distributor ID: RedHatEnterpriseAS
Descrīption: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
Release: 4
Codename: NahantUpdate1
[[email protected] ~]#
這個命令適用於所有的linux,包括Redhat、SuSE、Debian等發行版。
2) 登錄到linux執行cat /etc/redhat-release ,例如如下:
[[email protected] ~]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
[[email protected] ~]#
這種方式下可以直接看到具體的版本號,比如 AS4 Update 1
3)登錄到linux執行rpm -q redhat-release ,例如如下
[[email protected] ~]# rpm -q redhat-release
redhat-release-4AS-2.4
[[email protected] ~]#
這種方式下可看到一個所謂的release號,比如上邊的例子是2.4
這個release號和實際的版本之間存在一定的對應關系,如下:
redhat-release-3AS-1 -> Redhat Enterprise Linux AS 3
redhat-release-3AS-7.4 -> Redhat Enterprise Linux AS 3 Update 4
redhat-release-4AS-2 -> Redhat Enterprise Linux AS 4
redhat-release-4AS-2.4 -> Redhat Enterprise Linux AS 4 Update 1
redhat-release-4AS-3 -> Redhat Enterprise Linux AS 4 Update 2
redhat-release-4AS-4.1 -> Redhat Enterprise Linux AS 4 Update 3
redhat-release-4AS-5.5 -> Redhat Enterprise Linux AS 4 Update 4
更多Linux知識可參考書籍《Linux就該這么學》。
② linux腳本中連接mongo的命令是什麼
Linux下mongo資料庫的安裝及通過shell命令行連接,案例如下:
1、下載運行壓縮文件,不用編譯安裝,解壓後,簡單配置就可以使用了。
wgethttp://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.7.tgz
tarzxfmongodb-linux-i686-2.0.7.tgz
mvmongodb-linux-i686-2.0.7/usr/local/mongodb
cd/usr/local/mongodb
mkdirdatalogsrepair#新建幾個必須的工作目錄
2、運行mongod
/usr/local/mongodb/bin/mongod--dbpath=/usr/local/mongodb/data
--logpath=/usr/local/mongodb/logs/mongodb.log
--repairpath=/usr/local/mongodb/repair
--journal--fork
#mongod命令參數解析:
#--dbpath:存儲數據目錄
#--logpath:日誌目錄
#--journal:為了提高單機版的rability,mongodb會提前為journalfile分配空間,可以在資料庫目錄下面的journal/找到
#--fork選項將會通知mongod在後台運行
#打開日誌文件,如果在文件尾部看見「等待連接」的提示,則說明mongodb已經正常啟動
tail-flogs/mongodb.log
...
MonApr3007:51:08[initandlisten]
3、用shell腳本命令行連接資料庫
/usr/local/mongodb/bin/mongo
MongoDBshellversion:2.0.7
connectingto:127.0.0.1:27017/test
>
③ linux怎麼連接mongodb資料庫
想在shell中連接資料庫,首先要在連接數據的機器上安裝mongodb的客戶端才可以。客戶端的安裝在這里不再重復,自己網路或者google一下吧。連接mongodb的命令如下:/home/test/mongodb/mongodb-2.2.3/bin/mongo 127.0.0.1:8888
這個是我的資料庫配置,沒有設置用戶名密碼。所以直接通過該命令就可以連接。
連結後會有一個默認連接的資料庫。
mongodb常用命令:
查看資料庫命令:
show dbs;
查看集合命令:
show collections;
切換資料庫:
use databaseName;
查詢數據:
db.集合名.find()
插入數據:
db.集合名.insert({name:'test',age:1});
刪除:
db.test.remove();
sql="db.test.insert({name:'test',age:1});"//定義執行的sqlecho "$sql"|/home/test/mongodb/mongodb-2.2.3/bin/mongo 127.0.0.1:8888/test --shell
注意,echo命令中的格式必須這樣寫,管線命令後面的是是資料庫安裝地址 然後是ip:埠號,斜線後是資料庫名稱,--shell表示通過shell交互!