CentOS7开发环境搭建

Posted Brenda

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7开发环境搭建相关的知识,希望对你有一定的参考价值。

Bios开启VT支持


CentOS DNS配置

Linux 下设置DNS位置有3处,其生效顺序例如以下:

  • /etc/hosts
  • 网卡配置文件DNSserver地址
  • /etc/resolv.conf

通过设置主机表地址进行特定主机的解析,优先DNSserver地址,/etc/hosts:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
123.125.114.144 www.baidu.com #手动指定百度的IP

在/etc/hosts配置www.baidu.com的网址后,可以用ping www.baidu.com命令来观看ping的地址是否是123.125.114.114

Linux中默认的DNSserver地址配置文件为/etc/resolv.conf:

nameserver 114.114.114.114 #配置DNSserver地址,可配置多个
nameserver 8.8.8.8

在网卡配置文件里加入DNSserver地址。 /etc/sysconfig/network-scripts/ifcfg-eno16777736:

DNS1=114.114.114.114
DNS2=8.8.8.8

解析域名的方法:

[root@localhost]# nslookup baidu.com
Server:     114.114.114.114
Address:    114.114.114.114#53

Non-authoritative answer:
Name:   baidu.com
Address: 220.181.57.217
Name:   baidu.com
Address: 111.13.101.208
Name:   baidu.com
Address: 123.125.114.144
Name:   baidu.com
Address: 180.149.132.47

[root@localhost]# host baidu.com
baidu.com has address 180.149.132.47
baidu.com has address 220.181.57.217
baidu.com has address 111.13.101.208
baidu.com has address 123.125.114.144
baidu.com mail is handled by 10 mx.n.shifen.com.
baidu.com mail is handled by 20 mx1.baidu.com.
baidu.com mail is handled by 20 jpmx.baidu.com.
baidu.com mail is handled by 20 mx50.baidu.com.
[root@localhost]# dig baidu.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33094
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;baidu.com.         IN  A

;; ANSWER SECTION:
baidu.com.      202 IN  A   111.13.101.208
baidu.com.      202 IN  A   123.125.114.144
baidu.com.      202 IN  A   180.149.132.47
baidu.com.      202 IN  A   220.181.57.217

;; Query time: 28 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: Wed Nov 18 13:31:29 2015
;; MSG SIZE  rcvd: 91

CentOS网络配置

依据centos7.0安装教程安装虚拟机。

su root切换到root用户,编辑配置文件vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

HWADDR=00:0C:29:23:C4:B1 #ip link show查看
TYPE=Ethernet
#BOOTPROTO=dhcp
BOOTPROTO=static
IPADDR=192.168.0.122
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=114.114.114.114
DNS2=8.8.8.8
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NM_CONTROLLED=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ebd7eace-f0b7-4d48-b4d6-fd6ee3f7e21d #nmcli con show
# ONBOOT=no
ONBOOT=yes

注意配置可以使用的DNS,否则无法解析域名,可參考经常使用公共DNSserver地址

service network restart重新启动网络

ping baidu.com是否可以ping通百度

配置多个网卡
配置第二个时,须要自己创建配置文件。在重新启动网卡之前,停止NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager


时间配置

配置本地时区:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
同步网络时间:
yum install ntpdate
ntpdate pool.ntp.org

Samba服务配置

yum install samba samba-client samba-common安装相关软件

# rpm -qa | grep samba
samba-4.1.12-23.el7_1.x86_64
samba-libs-4.1.12-23.el7_1.x86_64
samba-common-4.1.12-23.el7_1.x86_64
samba-client-4.1.12-23.el7_1.x86_64

这里顺便说一下搭建sambaserver所须要的基本软件包:
1. samba 这个软件包包括了基本的daemon文件(smbd和nmbd)
2. samba-common 提供samba的主要配置文件(smb.conf)、smb.conf语法检測程序(testparm)等
3. samba-client 当linux作为samba 客户端的时候。提供了一套所需的工具和指令。

备份配置文件cp /etc/samba/smb.conf /etc/samba/smb.conf.$(date +%F)
编辑vim /etc/samba/smb.conf

[global]
    workgroup = MYGROUP
    server string = Samba Server Version %v
    log file = /var/log/samba/log.%m
    max log size = 50
    security = user
    passdb backend = tdbsam
    load printers = yes
    cups options = raw

[samba]
    comment = my share dir
    path = /home/user
    browseable = yes
    guest ok = yes
    writable = yes
    public = yes

加入用户smbpasswd -a samba_user,设置password
重新启动服务
service smb restart
service nmb restart

关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0

Linux下客户端測试
smbclient -L //192.168.0.122/samba -U samba_user

设置开机启动
systemctl enable smb.service

Win8下加入网络位置
进入我的电脑。【右击】-【加入网络位置】依据向导一直点击【下一步】,在Internet地址或网络位置下填写\\\\192.168.0.122\\samba,【下一步】依据提示填写用户与password。

安装必备软件

  • 安装gcc: yum -y install gcc
  • 安装g++: yum -y install gcc-c++
  • 安装gccgo: yum -y install gcc-go
  • 安装小工具:
    • yum -y install lrzsz screen
    • yum -y install socat nc nmap

获取本机公网ip

  • curl http://members.3322.org/dyndns/getip
  • curl ipinfo.io

    {
    "ip": "36.110.42.197",
    "hostname": "No Hostname",
    "city": "Beijing",
    "region": "Beijing Shi",
    "country": "CN",
    "loc": "39.9289,116.3883",
    "org": "AS4847 China Networks Inter-Exchange"
    }

參考:

以上是关于CentOS7开发环境搭建的主要内容,如果未能解决你的问题,请参考以下文章

centos7安装python3.5并配置pyqt开发环境

Hadoop运行环境搭建

记一次centos7.3开发环境配置

Docker Compose一键搭建lnmp开发环境

centos7 hadoop2.7.7 分布式环境搭建

一个网卡配置多个ip配置实现,centos7系统