| 
									
										
										
										
											2016-07-02 02:47:58 +08:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | # Licensed to the Apache Software Foundation (ASF) under one or more | 
					
						
							|  |  |  | # contributor license agreements.  See the NOTICE file distributed with | 
					
						
							|  |  |  | # this work for additional information regarding copyright ownership. | 
					
						
							|  |  |  | # The ASF licenses this file to You under the Apache License, Version 2.0 | 
					
						
							|  |  |  | # (the "License"); you may not use this file except in compliance with | 
					
						
							|  |  |  | # the License.  You may obtain a copy of the License at | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #    http://www.apache.org/licenses/LICENSE-2.0 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  | # distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  | # See the License for the specific language governing permissions and | 
					
						
							|  |  |  | # limitations under the License. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-11 15:08:11 +08:00
										 |  |  | set -ex | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-21 22:39:11 +08:00
										 |  |  | # The version of Kibosh to use for testing. | 
					
						
							|  |  |  | # If you update this, also update tests/docker/Dockerfile | 
					
						
							| 
									
										
										
										
											2019-11-16 07:13:32 +08:00
										 |  |  | export KIBOSH_VERSION=8841dd392e6fbf02986e2fb1f1ebf04df344b65a | 
					
						
							| 
									
										
										
										
											2017-11-21 22:39:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  | path_to_jdk_cache() { | 
					
						
							|  |  |  |   jdk_version=$1 | 
					
						
							|  |  |  |   echo "/tmp/jdk-${jdk_version}.tar.gz" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fetch_jdk_tgz() { | 
					
						
							|  |  |  |   jdk_version=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   path=$(path_to_jdk_cache $jdk_version) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [ ! -e $path ]; then | 
					
						
							|  |  |  |     mkdir -p $(dirname $path) | 
					
						
							| 
									
										
										
										
											2020-07-02 02:01:49 +08:00
										 |  |  |     curl --retry 5 -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk-${jdk_version}.tar.gz" -o $path | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-20 16:08:17 +08:00
										 |  |  | JDK_MAJOR="${JDK_MAJOR:-17}" | 
					
						
							|  |  |  | JDK_FULL="${JDK_FULL:-17-linux-x64}" | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | if [ -z `which javac` ]; then | 
					
						
							|  |  |  |     apt-get -y update | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  |     apt-get install -y software-properties-common python-software-properties binutils java-common | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  |     echo "===> Installing JDK..."  | 
					
						
							| 
									
										
										
										
											2017-03-31 05:40:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-25 14:19:19 +08:00
										 |  |  |     mkdir -p /opt/jdk | 
					
						
							|  |  |  |     cd /opt/jdk | 
					
						
							|  |  |  |     rm -rf $JDK_MAJOR | 
					
						
							|  |  |  |     mkdir -p $JDK_MAJOR | 
					
						
							|  |  |  |     cd $JDK_MAJOR | 
					
						
							|  |  |  |     fetch_jdk_tgz $JDK_FULL | 
					
						
							|  |  |  |     tar x --strip-components=1 -zf $(path_to_jdk_cache $JDK_FULL) | 
					
						
							|  |  |  |     for bin in /opt/jdk/$JDK_MAJOR/bin/* ; do  | 
					
						
							|  |  |  |       name=$(basename $bin) | 
					
						
							|  |  |  |       update-alternatives --install /usr/bin/$name $name $bin 1081 && update-alternatives --set $name $bin | 
					
						
							|  |  |  |     done | 
					
						
							|  |  |  |     echo -e "export JAVA_HOME=/opt/jdk/$JDK_MAJOR\nexport PATH=\$PATH:\$JAVA_HOME/bin" > /etc/profile.d/jdk.sh | 
					
						
							| 
									
										
										
										
											2017-03-31 05:40:54 +08:00
										 |  |  |     echo "JDK installed: $(javac -version 2>&1)" | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | chmod a+rw /opt | 
					
						
							| 
									
										
										
										
											2017-01-28 09:40:10 +08:00
										 |  |  | if [ -h /opt/kafka-dev ]; then | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  |     # reset symlink | 
					
						
							| 
									
										
										
										
											2017-01-28 09:40:10 +08:00
										 |  |  |     rm /opt/kafka-dev | 
					
						
							| 
									
										
										
										
											2014-12-05 21:37:11 +08:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2017-01-28 09:40:10 +08:00
										 |  |  | ln -s /vagrant /opt/kafka-dev | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 05:40:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  | get_kafka() { | 
					
						
							|  |  |  |     version=$1 | 
					
						
							| 
									
										
										
										
											2017-05-11 15:08:11 +08:00
										 |  |  |     scala_version=$2 | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     kafka_dir=/opt/kafka-$version | 
					
						
							| 
									
										
										
										
											2017-07-01 05:36:21 +08:00
										 |  |  |     url=https://s3-us-west-2.amazonaws.com/kafka-packages/kafka_$scala_version-$version.tgz | 
					
						
							| 
									
										
										
										
											2017-06-24 14:48:10 +08:00
										 |  |  |     # the .tgz above does not include the streams test jar hence we need to get it separately | 
					
						
							| 
									
										
										
										
											2017-07-01 05:36:21 +08:00
										 |  |  |     url_streams_test=https://s3-us-west-2.amazonaws.com/kafka-packages/kafka-streams-$version-test.jar | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  |     if [ ! -d /opt/kafka-$version ]; then | 
					
						
							|  |  |  |         pushd /tmp | 
					
						
							| 
									
										
										
										
											2020-07-02 02:01:49 +08:00
										 |  |  |         curl --retry 5 -O $url | 
					
						
							|  |  |  |         curl --retry 5 -O $url_streams_test || true | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  |         file_tgz=`basename $url` | 
					
						
							| 
									
										
										
										
											2017-06-24 14:48:10 +08:00
										 |  |  |         file_streams_jar=`basename $url_streams_test` || true | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  |         tar -xzf $file_tgz | 
					
						
							|  |  |  |         rm -rf $file_tgz | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         file=`basename $file_tgz .tgz` | 
					
						
							|  |  |  |         mv $file $kafka_dir | 
					
						
							| 
									
										
										
										
											2017-06-24 14:48:10 +08:00
										 |  |  |         mv $file_streams_jar $kafka_dir/libs || true | 
					
						
							| 
									
										
										
										
											2015-10-28 06:23:47 +08:00
										 |  |  |         popd | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-21 22:39:11 +08:00
										 |  |  | # Install Kibosh | 
					
						
							|  |  |  | apt-get update -y && apt-get install -y git cmake pkg-config libfuse-dev | 
					
						
							|  |  |  | pushd /opt | 
					
						
							| 
									
										
										
										
											2018-06-17 09:36:51 +08:00
										 |  |  | rm -rf /opt/kibosh | 
					
						
							| 
									
										
										
										
											2017-11-21 22:39:11 +08:00
										 |  |  | git clone -q  https://github.com/confluentinc/kibosh.git | 
					
						
							|  |  |  | pushd "/opt/kibosh" | 
					
						
							|  |  |  | git reset --hard $KIBOSH_VERSION | 
					
						
							|  |  |  | mkdir "/opt/kibosh/build" | 
					
						
							|  |  |  | pushd "/opt/kibosh/build" | 
					
						
							|  |  |  | ../configure && make -j 2 | 
					
						
							|  |  |  | popd | 
					
						
							|  |  |  | popd | 
					
						
							|  |  |  | popd | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-19 09:36:00 +08:00
										 |  |  | # Install iperf | 
					
						
							|  |  |  | apt-get install -y iperf traceroute | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-07 08:00:52 +08:00
										 |  |  | # Test multiple Kafka versions | 
					
						
							| 
									
										
										
										
											2018-05-22 14:17:42 +08:00
										 |  |  | # We want to use the latest Scala version per Kafka version | 
					
						
							|  |  |  | # Previously we could not pull in Scala 2.12 builds, because Scala 2.12 requires Java 8 and we were running the system | 
					
						
							|  |  |  | # tests with Java 7. We have since switched to Java 8, so 2.0.0 and later use Scala 2.12. | 
					
						
							| 
									
										
										
										
											2019-05-24 04:34:00 +08:00
										 |  |  | get_kafka 2.1.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.1.1 | 
					
						
							| 
									
										
										
										
											2019-12-07 05:44:56 +08:00
										 |  |  | get_kafka 2.2.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.2.2 | 
					
						
							|  |  |  | get_kafka 2.3.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.3.1 | 
					
						
							| 
									
										
										
										
											2020-03-31 00:55:35 +08:00
										 |  |  | get_kafka 2.4.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.4.1 | 
					
						
							| 
									
										
										
										
											2020-08-12 04:18:33 +08:00
										 |  |  | get_kafka 2.5.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.5.1 | 
					
						
							| 
									
										
										
										
											2023-12-16 05:07:03 +08:00
										 |  |  | get_kafka 2.6.3 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.6.3 | 
					
						
							|  |  |  | get_kafka 2.7.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.7.2 | 
					
						
							| 
									
										
										
										
											2022-09-11 23:20:07 +08:00
										 |  |  | get_kafka 2.8.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.8.2 | 
					
						
							| 
									
										
										
										
											2022-09-19 19:43:40 +08:00
										 |  |  | get_kafka 3.0.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.0.2 | 
					
						
							|  |  |  | get_kafka 3.1.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.1.2 | 
					
						
							|  |  |  | get_kafka 3.2.3 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.2.3 | 
					
						
							| 
									
										
										
										
											2023-11-10 04:03:12 +08:00
										 |  |  | get_kafka 3.3.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.3.2 | 
					
						
							| 
									
										
										
										
											2023-07-12 16:11:44 +08:00
										 |  |  | get_kafka 3.4.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.4.1 | 
					
						
							| 
									
										
										
										
											2024-01-12 22:55:10 +08:00
										 |  |  | get_kafka 3.5.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.5.2 | 
					
						
							| 
									
										
										
										
											2024-04-05 22:06:23 +08:00
										 |  |  | get_kafka 3.6.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.6.2 | 
					
						
							| 
									
										
										
										
											2024-12-17 01:49:03 +08:00
										 |  |  | get_kafka 3.7.2 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.7.2 | 
					
						
							| 
									
										
										
										
											2024-10-31 01:00:37 +08:00
										 |  |  | get_kafka 3.8.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.8.1 | 
					
						
							| 
									
										
										
										
											2025-05-21 14:09:00 +08:00
										 |  |  | get_kafka 3.9.1 2.12 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-3.9.1 | 
					
						
							| 
									
										
										
										
											2025-03-18 23:56:53 +08:00
										 |  |  | get_kafka 4.0.0 2.13 | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-4.0.0 | 
					
						
							| 
									
										
										
										
											2015-07-29 08:22:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-20 16:08:17 +08:00
										 |  |  | # To ensure the Kafka cluster starts successfully under JDK 17, we need to update the Zookeeper | 
					
						
							|  |  |  | # client from version 3.4.x to 3.5.7 in Kafka versions 2.1.1, 2.2.2, and 2.3.1, as the older Zookeeper | 
					
						
							|  |  |  | # client is incompatible with JDK 17. See KAFKA-17888 for more details. | 
					
						
							|  |  |  | curl -s "https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/3.5.7/zookeeper-3.5.7.jar" -o /opt/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | curl -s "https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper-jute/3.5.7/zookeeper-jute-3.5.7.jar" -o /opt/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | rm -f /opt/kafka-2.1.1/libs/zookeeper-* | 
					
						
							|  |  |  | rm -f /opt/kafka-2.2.2/libs/zookeeper-* | 
					
						
							|  |  |  | rm -f /opt/kafka-2.3.1/libs/zookeeper-* | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cp /opt/zookeeper-3.5.7.jar /opt/kafka-2.1.1/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.1.1/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | cp /opt/zookeeper-3.5.7.jar /opt/kafka-2.2.2/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.2.2/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | cp /opt/zookeeper-3.5.7.jar /opt/kafka-2.3.1/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.3.1/libs/zookeeper-3.5.7.jar | 
					
						
							|  |  |  | cp /opt/zookeeper-jute-3.5.7.jar /opt/kafka-2.1.1/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.1.1/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | cp /opt/zookeeper-jute-3.5.7.jar /opt/kafka-2.2.2/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.2.2/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | cp /opt/zookeeper-jute-3.5.7.jar /opt/kafka-2.3.1/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | chmod a+rw /opt/kafka-2.3.1/libs/zookeeper-jute-3.5.7.jar | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-29 08:22:14 +08:00
										 |  |  | # For EC2 nodes, we want to use /mnt, which should have the local disk. On local | 
					
						
							|  |  |  | # VMs, we can just create it if it doesn't exist and use it like we'd use | 
					
						
							|  |  |  | # /tmp. Eventually, we'd like to also support more directories, e.g. when EC2 | 
					
						
							|  |  |  | # instances have multiple local disks. | 
					
						
							|  |  |  | if [ ! -e /mnt ]; then | 
					
						
							|  |  |  |     mkdir /mnt | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | chmod a+rwx /mnt | 
					
						
							| 
									
										
										
										
											2015-10-30 06:53:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Run ntpdate once to sync to ntp servers | 
					
						
							| 
									
										
										
										
											2015-11-03 06:14:38 +08:00
										 |  |  | # use -u option to avoid port collision in case ntp daemon is already running | 
					
						
							|  |  |  | ntpdate -u pool.ntp.org | 
					
						
							| 
									
										
										
										
											2015-10-30 06:53:19 +08:00
										 |  |  | # Install ntp daemon - it will automatically start on boot | 
					
						
							|  |  |  | apt-get -y install ntp | 
					
						
							| 
									
										
										
										
											2019-11-23 08:32:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Increase the ulimit | 
					
						
							|  |  |  | mkdir -p /etc/security/limits.d | 
					
						
							|  |  |  | echo "* soft nofile 128000" >> /etc/security/limits.d/nofile.conf | 
					
						
							|  |  |  | echo "* hard nofile 128000" >> /etc/security/limits.d/nofile.conf | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ulimit -Hn 128000 | 
					
						
							|  |  |  | ulimit -Sn 128000 |