项目采用亚马逊云服务器,需要SSH证书访问,
部署 zookeeper、kafka、redis、mysql、clichkhouse
其中zookeeper、kafka、redis采用docker部署
一、首先连接服务器(使用亚马逊云下载的pem密钥文件)
[HOST]# ssh -i AWS-Host.pem centos@18.25.99.1
[HOST]@ip-172-31-2-111~]$
sudo -i 切换到root权限
[HOST]@ip-172-31-2-111~]$ sudo -i
[root@ip-172-31-2-111~]#
二、解下来开始安装各个服务
yum安装java
[root@ip-172-31-2-111~]# yum -y install java-1.8.0-openjdk.x86_64
[root@ip-172-31-2-111~]# java -version
openjdk version "1.8.0_392"
OpenJDK Runtime Environment (build 1.8.0_392-b08)
OpenJDK 64-Bit Server VM (build 25.392-b08, mixed mode)
【linux安装mysql 8.0】
1、安装本地YUM源
[root@ip-172-31-2-111~]# yum -y localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
2、安装mysql服务
yum -y install mysql-community-server
如果报错
Failing package is: mysql-community-client-8.0.32-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
执行
[root@ip-172-31-2-111~]#rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
3、启动MySql服务
(1)systemctl start mysqld
(2)systemctl enable mysqld
(3)service mysqld status
4、查看默认密码
[root@ip-172-31-2-111~]# grep 'temporary password' /var/log/mysqld.log
2023-11-21T07:40:19.629699Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost:;qVw3%rGIbql
5、登陆重置密码
先按照规则设置一个密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Zxc123456!';
修改密码规则和长度限制:
(3)修改mysql密码校验规则与密码长度(必须先修改密码,否则这个无法执行)
mysql> set global validate_password.policy=0;
mysql> set global validate_password.length=1;
再次修改容易记的密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
6、远程登录授权
update mysql.user set host='%' where user="root";
flush privileges;
select user,host from mysql.user;
7、用户授权
grant all privileges on *.* to 'root'@'%';
flush privileges;
【linux安装clickhouse】
1、下载以下rpm包
wget https://packages.clickhouse.com/rpm/stable/clickhouse-client-22.1.2.2-2.noarch.rpm
wget https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-22.1.2.2-2.x86_64.rpm
wget https://packages.clickhouse.com/rpm/stable/clickhouse-server-22.1.2.2-2.noarch.rpm
2、安装,要输入默认用户密码
rpm -ivh *.rpm
算出随机密码和加密(绿色部分为明文,红色部分为密文放于xml文件 )
[root@ip-172-31-2-111~ clickhouse]# PASSWORD=(base64 \< /dev/urandom \| head -c8); echo "PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
39YoaNiw
a674efe083d6590d0d8df13c822a945cf19d3bb65dda28651f8331223cd35cdc
可以在此编辑修改密码
vi /etc/clickhouse-server/users.d/default-password.xml
<clickhouse>
<users>
<default>
<password remove='1' />
<password_sha256_hex>a674efe083d6590d0d8df13c822a945cf19d3bb65dda28651f8331223cd35cdc </password_sha256_hex>
</default>
</users>
</clickhouse>
3、命令
启动service clickhouse-server start
重启service clickhouse-server restart
连接客户端:clickhouse-client --password
【docker安装 zookeeper】
#yum -y install docker
#service docker start
#docker pull zookeeper:3.8.0
创建容器
#docker run -d -p 2181:2181 --name zookeeper --restart always 3fae25920878
【docker安装kafka】
拉取kafka镜像#docker pull wurstmeister/kafka
创建容器#docker run -d --name kafka -p 9092:9092 --link zookeeper -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 -e KAFKA_ADVERTISED_HOST_NAME=localhost -e KAFKA_ADVERTISED_PORT=9092 wurstmeister/kafka:latest
测试kafka
docker exec -it kafka /bin/bash
root@a61e9830f5d8:/# cd /opt/kafka_2.13-2.8.1/
root@a61e9830f5d8:/opt/kafka_2.13-2.8.1#
root@a61e9830f5d8:/opt/kafka_2.13-2.8.1# ./bin/kafka-topics.sh --create --topic test-kafka --bootstrap-server localhost:9092
Created topic test-kafka.
root@a61e9830f5d8:/opt/kafka_2.13-2.8.1# ./bin/kafka-topics.sh --describe --topic test-kafka --bootstrap-server localhost:9092
Topic: test-kafka TopicId: nYPB4M1WR-WI1G98dl4HZA PartitionCount: 1 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: test-kafka Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1001
root@a61e9830f5d8:/opt/kafka_2.13-2.8.1#
【docker安装redis】
[root@172-31-2-111~]# docker pull redis:7.0.9
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/redis 7.0.9 f9c173b0f012 8 months ago 117 MB
创建redis容器并设置密码
docker run --name redis --restart always -it -d -p 6379:6379 redis:7.0.9 --requirepass "password"
69ccd6d7becffd5ee58821e3588f521676e0a0599cb11a7defc9d6e1bd237a51
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69ccd6d7becf redis:7.0.9 "docker-entrypoint..." 3 seconds ago Up 2 seconds 0.0.0.0:6379->6379/tcp redis
docker exec -it redis /bin/bash
root@0b976b6241d3:/data# redis-cli
127.0.0.1:6379>
127.0.0.1:6379> set test 1
(error) NOAUTH Authentication required.
127.0.0.1:6379>
127.0.0.1:6379> auth "password"
OK
127.0.0.1:6379> set test yunwei
OK
127.0.0.1:6379> get test
"yunwei"
127.0.0.1:6379> quit
到此,所有服务已成功安装完成。