mongodb安装

发布时间 2023-12-26 19:25:25作者: EJW
#!/bin/bash
##############################################################
# File Name: install_redis.sh
# Version: V1.0
# Author: junwang
# Organization: 
# Created Time : 2021-04-14 17:12:54
# Description:
##############################################################
tools_path=/server/tools
install_path=/web
THP=`grep sys/kernel/mm/transparent_hugepage/enabled  /etc/rc.local -rl|wc -l`
yum install -y  gcc wget 
mkdir -p $tools_path
mkdir -p $install_path

# install_mongodb

install_mongodb(){
if [  $THP  -le 1  ]
then
echo '
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' >> /etc/rc.local
fi
/bin/sh /etc/rc.local
cd $tools_path &&  wget http://47.105.153.221:33389/data/User/admin/home/caeri/MongoDB/MongoDB-3.2.16/mongodb-linux-x86_64-rhel70-3.2.16.tgz
tar -xf mongodb-linux-x86_64-rhel70-3.2.16.tgz
mkdir -p $install_path/mongodb/bin
mkdir -p $install_path/mongodb/conf
mkdir -p $install_path/mongodb/log
mkdir -p $install_path/mongodb/data
cp -a $tools_path/mongodb-linux-x86_64-rhel70-3.2.16/bin/* $install_path/mongodb/bin
echo 'export PATH=$PATH:'$install_path'/mongodb/bin' >> /etc/profile
source /etc/profile
echo 'systemLog:
   destination: file
   path: "'$install_path'/mongodb/log/mongodb.log"
   logAppend: true
storage:
   journal:
      enabled: true
   dbPath: "'$install_path'/mongodb/data/"
processManagement:
   fork: true
net:
   port: 27017' > $install_path/mongodb/conf/mongo.conf
   wget http://47.105.153.221:33389/data/User/admin/home/caeri/MongoDB/MongoDB-3.2.16/mongod -O /etc/init.d/mongod
   chmod +x /etc/init.d/mongod
   /etc/init.d/mongod start
# mongod -f $install_path/mongodb/conf/mongo.conf
if [ $? -eq 0  ]
then
   echo -e "###################### Mongodb installed successfully ####################################  \n
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@*++======++++++++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@=++======++++++++*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**====****===*#@@@@@#**===****==*#@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@=+++=====++++++++=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*++#@@@@@@#=+=*@@@@@@++=@@@@@=++#@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@=++++====++++++++=@@@@@@@@#@@@###@@@@@###@@@@@@@@@@#####@@@@@@@@@#@@##*#@@@@@@@@@####@@@@@@@@@@#####@@@@@@@@*++#@@@@@@@@#++=@@@@@=+=@@@@@*+=#@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@=++++====++++++++*@@@@@#=-.+*==+-.+*===+.-*@@@@@#++***=--+#@@#=---===+-.-#@@@@*+=*#*---++#@@*+=***+--=@@@@@@*++#@@@@@@@@@=++#@@@@=+=###*=+*@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@=++++===+++++++=@@@@@@@@+.+@@@@#-.=@@@@=.-@@@@*.-@@@@@@+.-#@@@=.-#@@@@+.-@@@*.-@@@@#..#@@@+.=@@@@@#-.+@@@@@*++#@@@@@@@@@*++#@@@@=+=#####*==*@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@#=++++==++++++=@@@@@@@@@+.=@@@@@-.*@@@@#..#@@@-.+@@@@@@#..*@@@=.-@@@@@=.-@@@#-.=@@@*.+@@@#..=@@@@@@=..#@@@@*++#@@@@@@@@@=+=@@@@@=+=@@@@@@#++=@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@*++++++++++*@@@@@@@@@@+.=@@@@@-.*@@@@#..#@@@=..*@@@@@*.-#@@@=.-@@@@@=.-@@@@#=-+***@@@@@@+.-#@@@@@+.+@@@@@*++#@@@@@@@#=+*@@@@@@++=@@@@@@*++#@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@#=++=+++=#@@@@@@@@@#*-.+*@@#*-.+#@@#=..=#@@@*--+*##*+=@@@@*+..=#@@*+..=#@@*-.+===**#@@@@=--=*#*=+*@@@@@#=++=*####**=*@@@@@@#*+++*####*=*@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@#****#@@@@@@@@@@@######@@######@@######@@@@@#***##@@@@@@*#####@@*#####@@#++====+-.-@@@@@#***##@@@@@@###########@@@@@@@@@@##########@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=.=@@@@@@@--#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=--=*###*==@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*===**#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
"
for i in `pgrep mongod` ;do echo -e "$i `ls -l /proc/$i|grep cwd` \n `netstat -lntup|grep $i`" ;done
cd $tools_path && rm -rf *
else
    echo "###################### Mongodb installed failed ####################################"
    exit 1
fi
}

install_mongodb