centos7 mongodb3.4 安装

时间:2022-10-01 15:44:54
  1. 上传tgz 安装包
    [root@localhost install_pack]# ll
    total 274840
    -rw-r--r--. 1 root root 9393241 Jun 2 14:36 apache-tomcat-8.5.15.tar.gz
    -rw-r--r--. 1 root root 185540433 Jun 2 14:35 jdk-8u131-linux-x64.tar.gz
    -rw-r--r--. 1 root root 86497632 Jun 13 14:48 mongodb-linux-x86_64-3.4.4.tgz
  2. 解压
    [root@localhost install_pack]# tar zxvf mongodb-linux-x86_64-3.4.4.tgz -C /usr/local/meiya/soft/
  3. 创建数据和日志目录
    [root@localhost install_pack]# cd ../soft/mongodb/
    [root@localhost mongodb]# mkdir data
    [root@localhost mongodb]# mkdir logs
    [root@localhost mongodb]# mkdir etc
  4. 创建配置文件
    [root@localhost mongodb]# vi ./etc/mongodb.conf
    dbpath = /usr/local/meiya/soft/mongodb/data
    # 设置日志文件的存放目录及其日志文件名
    logpath = /usr/local/meiya/soft/mongodb/logs/mongodb.log
    # 设置端口号(默认的端口号是 27017)
    port = 27017
    # 设置为以守护进程的方式运行,即在后台运行
    fork = true
    # nohttpinterface = true
    nohttpinterface = true
  5. 启动
    [root@localhost mongodb]# ./bin/mongod --config ./etc/mongodb.conf 
    [root@localhost mongodb]# ps -aux | grep mongodb
    root 16190 0.5 0.0 287996 41268 ? Sl 17:45 0:05 ./bin/mongod --config ./etc/mongodb.conf
    root 16598 0.0 0.0 112648 956 pts/1 S+ 18:03 0:00 grep --color=auto mongodb
  6. 设置环境变量
    [root@localhost mongodb]# vi /etc/profile
    export MONGODB_HOME=/usr/local/meiya/soft/mongodb/
    export PATH=$MONGODB_HOME/bin:$PATH
    [root@localhost mongodb]# vi /etc/profile
  7. 检验
    [root@localhost mongodb]# mongod -version
    db version v3.4.4
    git version: 888390515874a9debd1b6c5d36559ca86b44babd
    allocator: tcmalloc
    modules: none
    build environment:
    distarch: x86_64
    target_arch: x86_64