kafka+zookeeper+mongodb+kafka-manager+JDK+maven
kafka+zookeeper+mongodb+kafka-manager+JDK
提取码:1qgd
jdk_install.sh
#!/bin/bash #author:sunli #mail:<1916989848@qq.com> #安装jdk #上传jdk-8u271-linux-x64.tar.gz [ ! -f jdk-8u271-linux-x64.tar.gz ] && echo "not find jdk package" && exit tar xf jdk-8u271-linux-x64.tar.gz mv jdk1.8.0_271 /usr/local/java cat > /etc/profile.d/java.sh << EOF export JAVA_HOME=/usr/local/java export PATH=\$JAVA_HOME/bin:\$PATH EOF source /etc/profile.d/java.sh java -version
安装Maven
Maven是基于项目对象模型(POM project object model),可以通过一小段描述信息(配置)来管理项目的构建,报告和文档的软件项目管理工具
Maven采用纯Java编写, 它采用了一种被称之为Project Object Model(POM)概念来管理项目,所有的项目配置信息都被定义在一个叫做POM.xml的文件中, 通过该文件Maven可以管理项目的整个生命周期,包括清除、编译,测试,报告、打包、部署等等。
软件下载: http://maven.apache.org/
wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
[root@jenkins jenkins]# tar xf apache-maven-3.5.4-bin.tar.gz [root@jenkins jenkins]# mv apache-maven-3.5.4 /usr/local/maven3.5 [root@jenkins jenkins]# cat /etc/profile.d/maven.sh export MAVEN_HOME=/usr/local/maven3.5 export PATH=$MAVEN_HOME/bin:$PATH [root@jenkins jenkins]# . /etc/profile.d/maven.sh [root@jenkins jenkins]# mvn -v Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00) Maven home: /usr/local/maven3.5 Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/local/java/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-514.el7.x86_64", arch: "amd64", family: "unix"
mongodb_install.sh
#!/bin/bash #sunli<1916989848@qq.com> #可修改的端口、账户、密码 PORT="27017" User="sunli" Passwd="mongodb@123" #下载二进制安装包 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-4.0.21.tgz #解压 tar -zxvf mongodb-linux-x86_64-rhel62-4.0.21.tgz #删除原来的tgz(可选) #rm -rf mongodb-linux-x86_64-rhel62-4.0.21.tgz #安装路径,数据/日志目录 mv mongodb-linux-x86_64-rhel62-4.0.21/ /usr/local/mongodb mkdir -p /usr/local/mongodb/{data,logs} touch /usr/local/mongodb/logs/mongo.log #配置环境变量 cat > /etc/profile.d/mongodb.sh <<- EOF export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:$MONGODB_HOME/bin EOF source /etc/profile.d/mongodb.sh #bash xxx.sh次方式执行脚本环境变量才能生效 #创建配置文件,默认27017端口 cat > /usr/local/mongodb/mongo.conf <<- EOF dbpath=/usr/local/mongodb/data logpath=/usr/local/mongodb/logs/mongo.log logappend=true journal=true quiet=true port=$PORT fork=true bind_ip=0.0.0.0 auth=true EOF #加入systemd启动 cat > /usr/lib/systemd/system/mongodb.service <<- EOF [Unit] Description=mongodb After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongo.conf ExecReload=/bin/kill -s HUP \$MAINPID ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/mongo.conf PrivateTmp=true Restart=always RestartSec=1 [Install] WantedBy=multi-user.target EOF #启动并设置开机启动 systemctl daemon-reload systemctl start mongodb.service systemctl enable mongodb.service systemctl status mongodb.service #添加mongodb账户密码 [ `echo $?` == 0 ] && /usr/local/mongodb/bin/mongo --port $PORT admin --eval "db.createUser({user:'$User',pwd:'$Passwd',roles:['userAdminAnyDatabase','root']});" && /usr/local/mongodb/bin/mongo --port $PORT admin --eval "db.auth("$User","$Passwd");"
zk_install.sh
#!/bin/bash #author:sunli #mail:<1916989848@qq.com> #安装zookeeper-3.6.1 #上传apache-zookeeper-3.6.1-bin.tar.gz HostIP=`hostname -I |awk '{print $1}'` [ ! -f apache-zookeeper-3.6.1-bin.tar.gz ] && echo "Not find zookeeper package" && exit tar -zxf apache-zookeeper-3.6.1-bin.tar.gz mv apache-zookeeper-3.6.1-bin /usr/local/zookeeper mkdir -p /usr/local/zookeeper/data{,log} cd /usr/local/zookeeper/conf cp zoo_sample.cfg zoo.cfg #修改配置文件 sed -i "s#dataDir=/tmp/zookeeper#dataDir=/usr/local/zookeeper/data#g" zoo.cfg echo "dataLogDir=/usr/local/zookeeper/datalog" >> zoo.cfg echo "server.1=$HostIP:2888:3888" >> zoo.cfg echo 1 > /usr/local/zookeeper/data/myid #设置环境变量 cat > /etc/profile.d/zookeeper.sh << EOF export ZK_HOME=/usr/local/zookeeper export PATH=\$ZK_HOME/bin:\$PATH EOF source /etc/profile.d/zookeeper.sh #systemd管理 cat > /usr/lib/systemd/system/zookeeper.service << EOF [Unit] Description=zookeeper.service After=network.target ConditionPathExists=/usr/local/zookeeper/conf/zoo.cfg [Service] Type=forking Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/java/bin" User=root Group=root ExecStart=/usr/local/zookeeper/bin/zkServer.sh start ExecStop=/usr/local/zookeeper/bin/zkServer.sh stop [Install] WantedBy=multi-user.target EOF systemctl daemon-reload #启动 #zkServer.sh start systemctl enable zookeeper systemctl start zookeeper #systemctl stop zookeeper
kafka_install.sh
#!/bin/bash #author:sunli #mail:<1916989848@qq.com> #安装kafka-2.13 #上传kafka_2.13-2.6.0.tgz HostIP=`hostname -I |awk '{print $1}'` IP=${1:-$HostIP} PORT=9092 [ ! -f kafka_2.13-2.6.0.tgz ] && echo "Not find kafka package" && exit tar -zxf kafka_2.13-2.6.0.tgz mv kafka_2.13-2.6.0 /usr/local/kafka mkdir -p /usr/local/kafka/kafka-logs cd /usr/local/kafka/config cp server.properties server.properties_default #修改配置文件 sed -i "s#broker.id=0#broker.id=1#g" server.properties sed -i "s#log.dirs=/tmp/kafka-logs#log.dirs=/usr/local/kafka/kafka-logs#g" server.properties echo "listeners=PLAINTEXT://:$PORT" >> server.properties echo "advertised.listeners=PLAINTEXT://$IP:$PORT" >> server.properties #设置环境变量 cat > /etc/profile.d/kafka.sh << EOF export KAFKA_HOME=/usr/local/kafka export PATH=\$KAFKA_HOME/bin:\$PATH EOF source /etc/profile.d/kafka.sh #sed -i "/export KAFKA_HEAP_OPTS/a\\\ export JMX_PORT="9999"" /usr/local/kafka/bin/kafka-server-start.sh #systemd管理 cat > /usr/lib/systemd/system/kafka.service << EOF [Unit] Description=Apache Kafka server (broker) After=network.target zookeeper.service [Service] Type=simple Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/java/bin" User=root Group=root ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh [Install] WantedBy=multi-user.target EOF systemctl daemon-reload #启动 #kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties systemctl enable kafka systemctl start kafka #systemctl stop kafka
kafka-manager_install.sh
#!/bin/bash #author:sunli #mail:<1916989848@qq.com> #安装kafka-manager-2.0.2 #上传kafka-manager-2.0.0.2.zip HostIP=`hostname -I |awk '{print $1}'` IP=${1:-$HostIP} USER=monitor PASSWD=Baodian1608 [ ! -f kafka-manager-2.0.0.2.zip ] && echo "Not find kafka-manager package" && exit unzip kafka-manager-2.0.0.2.zip mv kafka-manager-2.0.0.2 /usr/local/kafka-manager #mkdir -p /usr/local/kafka/kafka-logs cd /usr/local/kafka-manager/conf cp application.conf application.conf_default_bak #修改配置文件 sed -i ""s#kafka-manager-zookeeper:2181"#"localhost:2181"#g" application.conf #sed -i "s#basicAuthentication.enabled=false#basicAuthentication.enabled=true#g" application.conf #sed -i "s#admin#$USER#g" application.conf #sed -i "s#password#$PASSWD#g" application.conf #启动 nohup /usr/local/kafka-manager/bin/kafka-manager -Dconfig.file=/usr/local/kafka-manager/conf/application.conf -Dhttp.port=8090 -java-home /usr/local/java &