centos安装MongoDB,并设置开机自启动
2017-11-15 21:35
761 查看
1:安装
2:mongodb启动
mongodb客户端连接
3:以守护进程方式启动
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz tar -zxvf mongodb-linux-x86_64-3.0.6.tgz mv mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb vim /etc/profile(添加如下图环境变量) source /etc/profile(使环境变量生效)
2:mongodb启动
cd /usr/local/momgodb/bin ./mongod
mongodb客户端连接
cd /usr/local/momgodb/bin ./mongo
3:以守护进程方式启动
cd /usr/local/mongodb touch log vi mongodb.conf(创建配置文件)
chmod –R a+x ./mongodb.conf kill掉当前MongoDB进程(以防端口被占用,出现以下错误)
cd /us r/local/mongodb/bin/ ./mongod –f mongodb.conf(如果不是同一目录,输入刚刚创建的配置文件的绝对位置) 出现以下结果 表示配置文件启动成功
cd /etc/init.d vi mongodb(创建启动文件,内容如下,确保下面启动和关闭的命令可以正常执行)
#!/bin/sh # #chkconfig: 2345 80 90 #description: mongodb if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi start() { /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf } stop() { /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf --shutdown } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac
chmod –R a+x mongodb chkconfig --add mongodb chkconfig mongodb on mongodb start(启动之前确保已经kill 掉mongodb,出现如下,表明启动成功)
相关文章推荐
- Centos7 设置Mongodb开机启动-自定义服务
- Linux上安装ZooKeeper并设置开机启动(CentOS7+ZooKeeper3.4.10)
- CentOS6.5(3)----设置自己安装的程序开机自动启动
- Centos7 设置Mongodb开机启动-自定义服务
- Windows下安装mongodb,设置mongodb开机启动,随windows服务启动
- CentOS 7编译安装nginx/redis设置开机启动
- centos安装tomcat设置开机启动
- CentOs7 安装Tengine 并设置成系统服务,开机自动启动。
- Linux上安装ZooKeeper并设置开机启动(CentOS7+ZooKeeper3.4.10)
- CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤
- CentOS6.5 安装Tomcat,设置服务并开机启动
- Ubuntu与Centos安装redis教程,及其设置开机自动启动
- Centos下mysql数据库安装、创建数据库、utf8编码设置、外部访问授权、导入sql执行、开机启动(系列1)
- linux安装mongodb(设置非root用户和开机启动)
- CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤
- centos下安装memcached并设置开机自动启动-两种方法
- CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤
- Linux上安装ZooKeeper并设置开机启动(CentOS7+ZooKeeper3.4.10)
- linux【centos 】 安装tomcat并设置成开机启动