阿里云服务器

目录

一:阿里云服务器

配置安全组及导入实例

二:Xshell6

安装

连接远程服务器

三:Xftp

连接远程服务器

 xftp显示 服务器的隐藏文件

 xshell和xftp的互联

四:安装jdk

五:Zookeeper的安装及配置

下载安装

配置

集群配置

启动zk服务端

启动客户端, 来对服务端进行访问

六:Kafka的安装及配置

下载安装(2.13-2.4.0)

环境变量

配置

启动(启动kafka之前要集群启动Zookeeper)

关闭服务

七:Tomcat

八:宝塔面板

安装宝塔面板

阿里云设置端口

开放端口的防火墙

九:安装MySQL(宝塔面板方式)

安装及配置


一:阿里云服务器

云服务器可以放入自己的项目,可以让所有的人进行访问

需要配置好多环境,比如放上Tomcat,jdk等等

配置安全组及导入实例

不同环境软件对应不同端口,所以需要配置安全组

比如这里我要配置Tomcat对应的安全组,该安全组命名为Linux_Tomcat_8080

(这里可以配置需要的端口号-------什么端口号可以访问)

每个安全组还要导入自己的实例

 

二:Xshell6

        本地和远程服务器进行连接,用于写一些命令对linux进行操作,比如解压

安装

        360里找,无脑下一步

连接远程服务器

        主机填阿里云服务器的实例的公网ip

     

三:Xftp

        用于本地和服务器进行传输文件

连接远程服务器

 连接成功

 xftp显示 服务器的隐藏文件

        因为服务器为了保护自己的安全,会隐藏一些文件

 xshell和xftp的互联

目的就是为了不用二次连接,即不用输入用户和密码两次

在xshell调出xftp,或,在xftp中调出xshell

 

四:安装jdk

官网下载地址

Java Archive Downloads - Java SE 8u211 and later

(选这个不要选错啦)

打开xftp把jdk的压缩文件传到服务器中,

 打开xshell,依次输入命令

进入根目录

cd /root

解压

tar -xvf jdk-8u333-linux-x64.tar.gz  -C  /usr/local

进入 /usr/local

cd /usr/local

进入编辑

vim /etc/profile

文件末尾加入

#set java environment
                JAVA_HOME=/usr/local/jdk1.8.0_333
                CLASSPATH=.:$JAVA_HOME/lib.tools.jar
                PATH=$JAVA_HOME/bin:$PATH
                export JAVA_HOME CLASSPATH PATH

按【etc】退出编辑模式

输入冒号:

输入wq保存,点击enter编辑完成

----

加载

source /etc/profile

查看版本,有具体版本表示安装成功

java -version

五:Zookeeper的安装及配置

下载安装

下载地址Index of /dist/zookeeper(下zk3.5.6和kafka2.4.0版本对应)(得先保证服务器中有jdk环境

(给4台服务器同时安装Zookeeper,需要打开xshell,分别连接4台服务器,添加4个会话,然后右键选择【发送键输入到所有回话】---这要操作相当于同时操作4台服务器啦)

通过远程工具将本地apache-zookeeper-3.5.6-bin.tar.gz压缩包,分别上传到4台服务器的/opt/software目录

xshell操作

进入压缩包的所在目录

cd /opt/software

解压到/opt/module下

tar -zxvf apache-zookeeper-3.5.6-bin.tar.gz -C /opt/module

修改文件夹的名字,为zookeeper3.5.6 

cd /opt/module
mv apache-zookeeper-3.5.6-bin zookeeper3.5.6

配置

1:进入/opt/module/zookeeper3.5.6目录下,创建data 文件夹。

cd /opt/module/zookeeper3.5.6
mkdir data

2:修改文件名

用xftp操作,进入conf目录, 将mv zoo_sample.cfg zoo.cfg 把 zoo_sample.cfg 改名为 zoo.cfg

3:修改zoo.cfg的配置信息

cd /opt/module/zookeeper3.5.6/conf
 vim zoo.cfg

输入i编辑

修改 dataDir=/opt/module/zookeeper3.5.6/data
【esc】退出

:wq

集群配置

1:修改云服务器的hosts的映射和修改本地windows的hosts映射

2:创建并修改myid文件

进入cd /opt/module/zookeeper3.5.6/data下创建myid文件

用xftp编辑myid文件,给每个服务器的myid文件标记唯一编号,分别是1,2,3,4

3:修改zoo.cfg

使用xftp进入 /opt/module/zookeeper3.5.6/data/conf目录下,修改zoo.cfg的内容

myid文件最末尾加入以下内容,4台服务器都要加


quorumListenOnAlllPs=true

server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888
server.4=node4:2888:3888

启动zk服务端

(如果是已经进行了集群配置,就不要单个启动一个服务器的Zookeeper啦,否则查看状态报错)

启动 4台服务器(xshell右键,点击【发送键到所有回话】)

cd /opt/module/zookeeper3.5.6/bin
./zkServer.sh start

 启动失败解决Zookeeper无法启动的问题_在京奋斗者的博客-CSDN博客_zookeeper启动不了

 查看状态--看看自己事master还是follower-----显示matser或follower就表示搭建集群成功

(如果是已经进行了集群配置,就不要单个启动一个服务器的Zookeeper啦,否则查看状态报错)

./zkServer.sh status

停止服务

./zkServer.sh stop

启动客户端, 来对服务端进行访问

./zkCli.sh

查看节点 (发现有一个【Zookeeper节点】)

 ls /

退出

quit

六:Kafka的安装及配置

下载安装(2.13-2.4.0)

 下载地址Apache Kafka (用已经编译好的)(前边2.13表示语言版本,2.4.1表示软件版本)

在每个服务器的/opt目录下,用xftp创建/module文件夹

使用xftp,将压缩包上传至每个服务器的/opt/software目录下 

 进入root目录

cd /opt/software

 解压,到/opt/module目录下

tar -zxvf kafka_2.13-2.4.0.tgz -C /opt/module

环境变量

在/etc/hosts文件中编辑

 刷新

 source /ect/profile

配置

1:修改云服务器的hosts的映射和修改本地windows的hosts映射

2:用xftp修改/opt/module/kafka_2.13-2.4.0/config下的server.properties文件

# 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.

# see kafka.server.KafkaConfig for additional details and defaults

############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://172.19.42.30:9092

# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://47.106.250.46:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3

# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=1048576000


############################# Log Basics #############################

# A comma separated list of directories under which to store log files


# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# Internal Topic Settings  #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.

transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

############################# Log Flush Policy #############################

# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.

# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000

# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000

############################# Log Retention Policy #############################

# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.

# The minimum age of a log file to be eligible for deletion due to age
#log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000

############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.


# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000


############################# Group Coordinator Settings #############################

# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0

#advertised.host.name=47.106.250.46
#advertised.port=9092
#host.name=47.106.250.46
broker.id=1
log.dirs=/opt/module/kafka_2.13-2.4.0/logs
#zookeeper.connect=172.19.42.30:2181,172.19.42.31:2181,172.19.42.29:2181,172.19.42.28:2181
#zookeeper.connect=47.106.250.46:2181,47.106.248.60:2181,47.106.251.169:2181,47.106.251.46:2181
zookeeper.connect=node1:2181,node2:2181,node3:2181,node4:2181

#listener.security.protocol.map=PUBLIC_CLIENT:PLAINTEXT,PRIVATE_CLIENT:PLAINTEXT
#advertised.listeners=PRIVATE_CLIENT://172.19.42.30,PUBLIC_CLIENT://47.106.250.46

#listeners=INSIDE://172.19.42.30:9092,0UTSIDE://47.106.250.46:9093
#advertised.listeners=INSIDE://172.19.42.30:9092,0UTSIDE://347.106.250.46:9093
#listener.security.protocol.map = INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
#inter.broker.listener.name=INSIDE

#listeners=PLAINTEXT://172.19.42.30:9092
advertised.listeners=PLAINTEXT://node1:9092
#advertised.listeners=PLAINTEXT://47.106.250.46:9092

log.retention.hours=24
#offsets.topic.replication.factor=3
default.replication.factor=3
delete.topic.enable=true

启动(启动kafka之前要集群启动Zookeeper)

进入

cd /opt/module/kafka_2.13-2.4.0

 启动(不加-darmon表示有日志)

bin/kafka-server-start.sh -daemon config/server.properties

查看是否启动成功

   先另外开一个窗口

 在此窗口输入命令jps

        jps

  (这个是java带的命令,需要有java环境)


关闭服务

bin/kafka-server-stop.sh

七:Tomcat

阿里云的安全组,设置对应端口,并导入实例

进入

cd /root

ls

ls

解压

tar -xvf apache-tomcat-8.5.81.tar.gz  -C /usr/local

进入

cd /usr/local

开放linux对8080的端口,(默认情况是不开放端口号的)

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

进入Tomcat的bin目录

cd apache-tomcat-8.5.81/bin/

查看ls

ls

启动Tomcat服务  (./表示当前目录,sh是linux系统的启动文件,bat是window的启动文件)

./startup.sh

用windows本机的浏览器,访问服务器的Tomcat

   (访问出现网址表示成功)

 服务器停止Tomcat服务

./shutdown.sh

八:宝塔面板

给自己的服务器上安装宝塔面板,然后通过windows本地,可视化安装软件到服务器上

安装宝塔面板

选择在线安装,输入服务器公网ip

阿里云设置端口

开放端口的防火墙

 宝塔会自动开启Linux操作系统的防火墙(firewalld.service),如果需要访问某个端口,既需要放通我们自己的服务器安全组,还需要同步在宝塔面板中设置系统防火墙放通对应端口。

        (宝塔面板的防火墙的协议,有的时候单的的tcp和tcp/udp都不好使,两个都放上才行)

九:安装MySQL(宝塔面板方式)

安装及配置

宝塔面板里,软件商城搜索mysql,点击安装

 修改root密码

创建数据库(按需创建)

 修改各个数据库的权限(选择面板方式)

 登录用数据库的账号和密码

 点击修改权限

 点击登录信息(设置在哪些机器上可以登录,这里设置的所有)

阿里云服务器的安全组,设置对应端口

 宝塔面板开放防火墙对应的端口(似乎tcp和tcp/udp都要)

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值