用于大数据开发的Centos7操作系统安装过程中遇到的问题总结

1.1 操作系统

机器域名 机器别名

xxx.xxx.xxx.xxx bigdata1
xxx.xxx.xxx.xxx bigdata2
xxx.xxx.xxx.xxx bigdata3

3台机器用户名和密码:
用户名 密码

root    xxxx
bigdata xxxxx

1.1.1 装机注意事项

一、 U盘安装的时候报错的解决方案

参考解决问题的网址:https://www.cnblogs.com/freeweb/p/5213877.html
/dev/sda /dev/sda4 /dev/sdb /dev/sdb1~3

将
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
更改为(即更改inst.stage2=hd:后面的内容即可)
vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sda4:/ quiet

二、修改/etc/resolv.conf,将配置中的值改成

nameserver 202.xxx.xxx.xx    前面两个要和测试服务器上的这两个nameserver保持一致
nameserver 202.xxx.xxx.xx    这两个用于联网使用
nameserver 8.8.8.8          下面这两个必须有,否则在使用yum的时候使用不了
nameserver 8.8.4.4

三、修改/etc/sysconfig/network-scprits/ifcfg-*,内容如下:

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp3s0"
UUID="xxxxxxxxxxxxxxxxxxxxxxxx"
DEVICE="enp3s0"
ONBOOT="yes"
IPADDR="xxx.xxx.xxx.xxx"
IPADDR1="xxx.xxx.xxx.xxx"   #这里是虚拟ip
PREFIX="24"
GATEWAY="xxx.xxx.xxx.xxx"
IPV6_PRIVACY="no"
DNS1=xxx.xxx.xxx.xxx
DNS2=xxx.xxx.xxx.xxx
DNS3=8.8.8.8
DNS4=8.8.4.4

修改完成之后,执行重启网络配置命令:

service network restart

四、修改hosts,hostname.效果如下:

[root@bigdata3 ~]# cat /etc/hosts   (3台服务器的这个配置一致)
#127.0.0.1   localhost localhost.localdo:wqmain localhost4 localhost4.localdomain4
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
xxx.xxx.xxx.xxx  bigdata1
xxx.xxx.xxx.xxx  bigdata2
xxx.xxx.xxx.xxx  bigdata3
[root@bigdata3 ~]#
[root@bigdata1 ~]# cat /etc/hostname 
bigdata1
[root@bigdata2 ~]# cat /etc/hostname 
bigdata2
[root@bigdata3 ~]# cat /etc/hostname 
bigdata3

五、为了让服务能够被远程工具连接,配置/etc/ssh/sshd_config中监听的端口和ip地址

Port 22                           这里可以不放开,默认是22端口
PermitRootLogin yes
PasswordAuthentication yes


http://blog.csdn.net/tuntun1120/article/details/65443757

即:将/etc/ssh下的sshd_config文件中的,关于监听端口、监听地址前的#号去除。

六、centos yum报错Loaded plugins: fastestmirror

解决办法参考:http://blog.csdn.net/zvall/article/details/52180699

vim  /etc/yum/pluginconf.d/fastestmirror.conf 
enabled = 0

vim /etc/yum.conf
plugins=0

yum clean dbcache

如果发现还是不可以使用yum命令安装各种软件,这时候说明是DNS的配置有问题
解决办法是:
A:修改vim /etc/sysconfig/network-scripts/ifcfg-eth
添加如下内容:

ONBOOT=yes
MM_CONTROLLED=no        这个若没有添加上去
DNS1=8.8.8.8
DNS2=8.8.4.4

上面的dns名称不能重复

同时在/etc/resolv.conf中添加:

nameserver 8.8.8.8
nameserver 8.8.4.4

然后重启项目即可

六、安装wget

yum –y install wget

七、更新安装vim,安装vim增强包

yum –y install vim-enhanced

八、解决netstat:command not found问题

yum install net-tools

九、Centos7防火墙配置:

http://blog.csdn.net/lukaixiao/article/details/53946243

将默认Firewall改为iptables防火墙

关闭firewall:
service network restart    #重启网络

systemctl stop firewalld.service   #停止firewall

systemctl disable firewalld.service   #禁止Firewall开启启动

firewall-cmd –state    #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

配置iptable防火墙

vi /etc/sysconfig/iptables     #编辑防火墙配置文件

# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter <!-- 本行请查看下面备注-->
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT

:wq! #保存退出

备注:这里使用80和8080端口为例
filter
以上部分一般添加到下行的上面或者下面

-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT

切记不要添加到最后一行,否则防火墙重启后不生效

systemctl restart iptables.service     #最后重启防火墙使配置生效
systemctl enable iptables.service     #设置防火墙开机启动

它防火墙参数配置:
其修改防火墙配置文件之前,需要对之前防火墙做好备份
重启防火墙后,需要确认防火墙状态和防火墙规则是否加载,若重启失败或规则加载失败,则所有请求都会被防火墙

firewall-cmd --state        
#查看firewall的状态
firewall-cmd --list-all 
#查看防火墙规则(只显示/etc/firewalld/zones/public.xml中防火墙策略)
firewall-cmd --list-all-zones 
#查看所有的防火墙策略(即显示/etc/firewalld/zones/下的所有策略)
firewall-cmd --reload
#重新加载配置文件

2、关闭firewall:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

1、firewalld的基本使用

启动: systemctl start firewalld
查看状态: systemctl status firewalld 
停止: systemctl disable firewalld
禁用: systemctl stop firewalld

2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

那怎么开启一个端口呢
添加

firewall-cmd --zone=public --add-port=80/tcp --permanent    --permanent永久生效,没有此参数重启后失效)

重新载入

firewall-cmd --reload

查看

firewall-cmd --zone= public --query-port=80/tcp

删除

firewall-cmd --zone= public --remove-port=80/tcp --permanent

因为在/usr/lib/firewalld/services/中事先定义了ssh.xml的相应的规则

十、关闭selinux
关闭selinux:https://www.linuxidc.com/Linux/2016-11/137723.htm

十一、关闭使用交换空间

编辑/etc/sysctl.conf,改vm.overcommit_memory=0,然后sysctl -p 使配置文件生效

关于参数说明,参考:https://blog.csdn.net/whycold/article/details/21388455

十二:添加iptables
安装iptables

[root@bigdata2 ~]# yum install iptables-services

iptables其它命令:

#编辑防火墙文件 (建议都在配置文件配置,不要命令配置)
vi /etc/sysconfig/iptables 
#添加80和3306端口 等等(自己配置)
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT           #80端口开放
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT    #3306端口开放
-I INPUT -s 113.106.93.110 -p tcp --dport 8089 -j DROP                         #禁止指定IP访问 8089
-I INPUT -s 113.106.93.110 -p tcp --dport 8080 -j ACCEPT                    #开放固定ipIP访问 8080

#重启防火墙使配置文件生效  
systemctl restart iptables.service
#设置iptables防火墙为开机启动项 
systemctl enable iptables.service

service iptables  start        #启动服务
service iptables  stop     #停止服务
service iptables  restart  #重启服务

在设置iptable之后,需要执行以下命令
[root@localhost sbin]# service iptables save
[root@localhost sbin]# service iptables restart

以下案例是将192.168.18.141机器上的9095端口映射到192.168.18.1459095端口
iptables -t nat -A PREROUTING -d 192.168.18.141 -p tcp -m tcp --dport 9095 -j DNAT --to-destination 192.168.18.145:9095

Iptable其它知识点:

1、安装iptable iptable-service
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables(安装的最新版本则不需要)
yum update iptables 
#安装iptables-services
yum install iptables-services
2、禁用/停止自带的firewalld服务
#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld
3、设置现有规则
#查看iptables现有规则
iptables -L -n
#先允许所有,不然有可能会杯具
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器归0
iptables -Z
#允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
#开放22端口
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#开放21端口(FTP)
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#开放80端口(HTTP)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#开放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#允许ping
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
#允许接受本机请求之后的返回数据 RELATED,是为FTP设置的
iptables -A INPUT -m state --state  RELATED,ESTABLISHED -j ACCEPT
#其他入站一律丢弃
iptables -P INPUT DROP
#所有出站一律绿灯
iptables -P OUTPUT ACCEPT
#所有转发一律丢弃
iptables -P FORWARD DROP

4、其他规则设定
#如果要添加内网ip信任(接受其所有TCP请求)
iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT
#过滤所有非以上规则的请求
iptables -P INPUT DROP
#要封停一个IP,使用下面这条命令:
iptables -I INPUT -s ***.***.***.*** -j DROP
#要解封一个IP,使用下面这条命令:
iptables -D INPUT -s ***.***.***.*** -j DROP

5、保存规则设定
#保存上述规则
service iptables save

6、开启iptables服务 
#注册iptables服务
#相当于以前的chkconfig iptables on
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service
7、映射端口(如将mysql默认的3306端口映射成1306对外提供服务)
iptables -t mangle -I PREROUTING -p tcp --dport 1306 -j MARK --set-mark 883306 
iptables -t nat -I PREROUTING -p tcp --dport 1306 -j REDIRECT --to-ports 3306 
iptables -I INPUT -p tcp --dport 3306 -m mark --mark 883306 -j ACCEPT

十三 brctl命令管理网桥
安装brctl命令包

yum install bridge-utils

我们创建了网桥之后如何删除呢?若要想将这个网桥上的port卸下来。

brctl show
#查看网桥状态
brctl delif <网桥名> <端口名>
#卸载网桥上的端口
ifconfig
#查看是否有网桥网卡名
ifconfig <网桥名> down
#关闭此网卡
brctl delbr <网桥名>
#删除网桥

1.2 下载软件

软件清单:

jdk-8u73-linux-x64.tar.gz   Java JDK1.8+环境
apache-maven-3.3.9-bin.tar.gz   Maven安装文件
apache-tomcat-8.5.12.tar.gz Tomcat安装包
MySQL-5.7.21-linux-glibc2.12-x86_64.tar.gz  MySQL5.7

zookeeper-3.4.11.tar.gz Zookeeper安装软件
hadoop-3.0.0.tar.gz Hadoop安装软件

apache-hive-2.3.2-bin.tar.gz    数据仓库之hive
apache-flume-1.8.0-bin.tar.gz   日志收集框架二进制
sqoop-1.4.7.tar.gz  关系型数据库和hdfs数据之间转换的工具

apache-storm-1.2.1.tar.gz   实时数据处理之storm安装包
azkaban-master-source.zip   任务调度所需的源码包

spark-2.3.0-bin-hadoop2.7.tgz   Spark之针对hadoop2.7版本的安装包
scala-2.13.0-M3.zip Spark编写所需的scala语言包
hbase-1.4.2-bin.tar.gz  Hbase安装包

elasticsearch-6.2.2.rpm ES之Linux rpm安装包
elasticsearch-6.2.2.tar.gz  ES值Linux tar安装包
logstash-6.2.2.rpm  ELK之logstash日志收集框架
logstash-6.2.2.tar.gz   ELK之logstash日志收集框架tar包
kibana-6.2.2-linux-x86_64.tar.gz    ELK套件之视图展示用框架
kibana-6.2.2-x86_64.rpm ELK套件之视图展示用框架rpm安装包

redis-3.2.9.tar.gz  redis安装包
kylin   Apache Kylin™是一个开源的分布式分析引擎,提供Hadoop/Spark之上的SQL查询接口及多维分析(OLAP)能力以支持超大规模数据
presto  Presto是一个开源的分布式SQL查询引擎,适用于交互式分析查询,数据量支持GB到PB字节.

Presto的设计和编写完全是为了解决像Facebook这样规模的商业数据仓库的交互式分析和处理速度的问题

1.3 上传安装包

将安装文件上传到:/home/bigdata/software

1.4 3台服务器间的免密登录

在bigdata1、bigdata2、bigdata3下执行:

ssh-keygen -t rsa   (这个过程中一致打enter)
ssh-copy-id bigdata1
ssh-copy-id bigdata2
ssh-copy-id bigdata3

执行完成上面的命令之后,分别bigdata1、bigdata2、bigdata3上执行:

ssh bigdata1
ssh bigdata2
ssh bigdata3

按照如果最后能够免密码登录进去,说明免密登录成功

1.5 搭建ntp时间服务器

让Linux上的时间和网络时间保持一致,避免一些时间不一致的问题(必须在root命令下执行)

[root@bigdata1 ~]# yum install -y ntp
[root@bigdata1 ~]# ntpdate pool.ntp.org && hwclock -w

1.5.1 Ntp时间同步的另外一种搭建方式

1)安装NTP(每个节点)
yum install ntp

2)配置NTP
vim /etc/ntp.conf
master配置:(选用复旦大学ntp服务器)
这里写图片描述

slave配置:(同步master)
这里写图片描述

3)开启NTP服务
service ntpd start
chkconfig ntpd on

4)查看同步效果
命令:ntpstat
这里写图片描述

1.6 常见命令

查看常见命令
查看机器上运行端口

netstat –tunlp

查看某个端口运行在哪个位置

ps –ef | grep PID     (PID即上面netstat –tunlp中查看出来的PID)

centos7下查看哪些端口开放了

firewall-cmdlist-ports

防火墙开放端口:

firewall-cmd --zone=public --add-port=80/tcp –permanent

命令含义:

–zone #作用域add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

通过iptables的方式查看开放的端口:

/etc/init.d/iptables status

查看某个文件夹下含有某个字符串的命令:

grep -rl 'mysqld' ./

安装telnet

[root@bigdata3 ~]# yum install net-tools
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

涂作权的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值