(简易)集群搭建
关闭windows防火墙
能关的全关
Linux 网络设置
若想要几台计算机可以互相访问,需要将这几台计算机,放到同一子网1网段中
VM虚拟网络配置
设置子网网段,子网网关
windows网络设置
设置windows端的 ip地址 IP地址要在第一步设置的子网网段中
linux网络配置
修改配置相关文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.133.33
NETMASK=255.255.255.0 (另一种写法 PREFIX=24)
GATEWAY=192.168.133.1
DNS1=192.168.133.1
验证设置是否成功
关闭linux防火墙服务
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 关闭防火墙开机自启动
关闭NetworkManager 网络服务
为避免与Network服务冲突 需要关闭 Networkmanager 服务
systemctl stop NetworkManager 关闭NetworkManager服务
systemctl disable NetworkManager 关闭NetworkManager开机自启动
设置主机名
vi /etc/hostname 修改主机名
reboot 重启生效
配置映射文件
windows
C:\Windows\System32\drivers\etc\hosts
[if !supportLists]· [endif]添加
[if !supportLists]· [endif]192.168.133.33 linux01
[if !supportLists]· [endif]192.168.133.44 linux02
[if !supportLists]· [endif] 192.168.133.55 linux03
[if !supportLists]· [endif]192.168.133.2 windows
linux
vi /etc/hosts
[if !supportLists]· [endif]添加
[if !supportLists]· [endif]192.168.133.33 linux01
[if !supportLists]· [endif]192.168.133.44 linux02
[if !supportLists]· [endif] 192.168.133.55 linux03
[if !supportLists]· [endif]192.168.133.2 windows
安装JDk
1.安装xftp7 从windows上传输一个JDK到Linux中/opt/apps下
2.对/opt/apps下的JDK压缩包进行解压 tar -zxvf jdk-8u191-linux-x64.tar.gz
3.配置 /etc/profile文件 vi /etc/profile
在文件最后添加
[if !supportLists]· [endif] export JAVA_HOME=/opt/apps/jdk1.8.0_191
[if !supportLists]· [endif] export PATH=$PATH:$JAVA_HOME/bin
[if !supportLists]· [endif]注意不要忘记/bin
[if !supportLists]· [endif]保存退出
4.source /etc/profile
安装成功
安装mysql
1. 进入到/opt/apps文件夹
2. yum -y install wget
3. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
4. yum -y install mysql57-community-release-el7-10.noarch.rpm
5. yum -y install mysql-community-server --nogpgcheck
6. systemctl start mysqld
7. netstat -nltp | grep 3306
8. grep "password" /var/log/mysqld.log
2021-11-21T19:13:01.139721Z 1 [Note] A temporary password is generated for root@localhost: hUk5ak36Pn%T
9. mysql -uroot -phUk5ak36Pn%T
10. 修改密码
登陆mysql后
#这两个设置后 密码可以简单设置
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
#修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
时间同步
yum -y install ntp
vi /etc/ntp.conf
server npt1.aliyun.com
server time.windows.com
server time.apple.com
启动服务
systemctl start ntpd
systemctl enable ntpd
保存快照
克隆
1.关闭虚拟机
修改被克隆出的系统的配置
修改linux的IP地址
vi /etc/sysconfig/network-scripts/ifcfg-ens33
192.168.133.44
修改主机名称
vi /etc/hostname
linux02
远程复制
将linux01的hosts文件远程复制给linux02和linux03
scp /etc/hosts linux02:/etc/
scp /etc/hosts linux03:/etc/
复制完可以cat一下验证 是否复制成功
远程复制
scp -r 目录 ip:/目录位置
scp -r 目录 ip:$PWD 远程复制到当前文件夹下 要求对方必须有对应的文件夹
ssh免登录
如果系统中没有ssh命令,则说明工具包没有安装或者安装不完整,可用yum进行安装
yum - y install openssh
ssh是用于远程登录的工具(CRT本质是就是一个ssh客户端程序,windows版本的)
使用ssh登陆其他计算机
ssh linux02
输入密码
ssh linux03
输入密码
免密配置
在linux01上生成密钥
ssh-keygen
将生成好的公钥发送给linux01 linux02 linux03
ssh-copy-id linux01
ssh-copy-id linux02
ssh-copy-id linux03
相同操作在linux02 linux03上再操作一遍
这样3台计算机就可以免密连接了