centos6.8集群搭建
关机:halt
重启:reboot
修改本机ip:
1 | vim /etc/sysconfig/network-scripts/ifcfg-eth0 |
1 | DEVICE=eth0 |
修改hosts:
1 | vim /etc/hosts |
1 | 192.168.2.128 hadoop100 |
重启网络服务:
1 | service NetworkManager stop |
关闭关机自启:
1 | chkconfig NetworkManager off |
设置nameserver:
1 | vim /etc/resolv.conf |
配置防火墙:
1 | 关闭 |
Ubuntu黑屏
netsh winsock reset
修改ip之后需要删除一个文件才能成功
1 | rm /etc/udev/rules.d/70-persistent-net.rules |
SSH免密登录
- 生产密钥
ssh-keygen -t rsa
- 私钥发送本机
ssh-copy-id localhost
- 公钥发送其他计算机
ssh-copy-id 192.168.2.128
记一次UUID和HWADDR的坑
在虚拟机设置中获取MAC地址00:50:56:25:32:15
在/etc/sysconfig/network-scripts/ifcfg-eth0
中添加HWADDR=xxx
使用uuidgen eth0
生成UUID
,并在/etc/sysconfig/network-scripts/ifcfg-eth0
中添加
删除rm -rf /etc/udev/rules.d/70-persistent-net.rules
重启
也可以克隆虚拟机后,直接修改
/etc/udev/rules.d/70-persistent-net.rules
,将eth1
改为eth0
,然后复制HWADDR
写入/etc/sysconfig/network-scripts/ifcfg-eth0
设置yum阿里镜像
备份
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
配置软件源
1
2
3
4
5# Centos-6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# Centos-7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo生成缓存
yum makecache
集群分发工具
scp
rsync
xsync
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25!/bin/bash
1 获取输入参数个数,若没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi
2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname
3 获取上级目录的绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir
4 获取当前用户名称
user=`whoami`
5 循环
for((host=103; host<105; host++)); do
echo ----------hadoop$host------------
rsync -rvl $pdir/$fname $user@hadoop$host:$pdir
done
集群时间同步ntp
Centos6.8安装MySQL5.7
下载 https://dev.mysql.com/downloads/mysql, (wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz) 选择对应版本,上传到虚拟机,解压
卸载系统自带MySQL
rpm -qa|grep mysql
,若存在则yum remove ***
创建用户组和用户
创建用户组
groupadd mysql
创建用户
useradd -r -g mysql mysql
给MySQL用户指定专有用户和用户组
- 创建data文件夹
cd /usr/local/mysql
,mkdir data
- 指定用户组和用户
cd /usr/local
,chown -R mysql mysql/
,chgrp -R mysql mysql/
- 创建data文件夹
初始化MySQL
cd /usr/local/mysql/bin
,yum -y install numactl
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
,记住生成的临时密码T(nUEMv&f2-7
如果忘记密码或者想重新初始化,可以先将mysql/data目录中文件删除,然后再执行初始化命令
配置my.cnf
vim /etc/my.cnf
1
2
3[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data启动MySQL
cd /usr/local/mysql/bin
./mysqld_safe --user=mysql &
设置开机自启动
cd /usr/local/mysql/support-files/
cp mysql.server /etc/init.d/mysql
vim /etc/init.d/mysql
1
2basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/授权
chmod +x /etc/init.d/mysql
设为开机启动
chkconfig --add mysql
启动服务
- 启动
service mysql start
- 停止
service mysql stop
- 重启
service mysql restart
- 查看
service mysql status
- 启动
登录MySQL
cd /usr/local/mysql/bin
./mysql -u root -p
修改密码
set password=password("root");
登录授权
grant all privileges on *.* to'root' @'%' identified by '123456';
授权生效
flush privileges;
Centos6.8安装Redis
进入redis目录,
make && make install
将redis安装为系统服务并后台启动
cd /usr/local/redis/utils
./install_server.sh
查看redis服务启动情况
systemctl status redis_6379.service
centos6没有systemctl命令,可以使用service —status-all显示所有服务
启动redis客户端
设置允许远程连接
- 编辑redis配置文件
vim /etc/redis/6379.conf
- 将
bind 127.0.0.1
改为0.0.0.0
- 设置访问密码,将
#requirepass foobared
注释去掉,并将foobared
改为密码。使用auth password
进行验证 - 重启redis
systemctl restart redis_6379.service
- 编辑redis配置文件
Docker部署Redis
docker pull redis
`mkdir -p /root/redis/redis01/conf
mkdir -p /root/redis/redis01/data
cd /root/redis/redis01/conf下载一个redis.conf文件
cd ../ docker run -p 6379:6379 --name hbk_redis -v $PWD/conf/redis.conf:/etc/redis/redis.conf -v $PWD/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
修改redis.conf
1
2
3
4
5
6
7
8
9
10# bind 127.0.0.1
bind 0.0.0.0
# protected-mode yes
protected no
# requirepass foobared
requirepass 123456
#daemon 不能是yes
Centos6.8安装RabbitMQ
- 安装Erlang
- 安装依赖包
yum install xmlto gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC-devel wxBase wxGTK wxGTK-gl perl -y
- Erlang下载
yum install -y erlang-19.0.4-1.el6.x86_64.rpm
- 安装依赖包
- 安装RabbitMQ
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm
.sh | sudo bash
- 使用Docker部署RabbitMQ(management才有页面)
docker pull rabbitmq:management
docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
Ubuntu18.04更换阿里镜像
查找源配置文件
find / -name sources.list
修改source.list
1
2
3
4
5
6
7
8
9
10deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiversesudo apt-get update