当前位置: > CentOS > CentOS服务器 > 环境配置 >

CentOS开发环境配置

时间:2018-02-02 13:14来源:linux.it.net.cn 作者:IT

1,网络配置

# vim /etc/sysconfig/network-scripts/ifcfg-eth0

参考配置如下:

BOOTPROTO="static"
DEVICE="eth0"
IPADDR="8.0.186.115"
NATMASK="255.255.254.0"
STARTMODE="onboot"
GATEWAY="8.0.186.0"

执行以下命令使配置生效:

# service network restart

若无法重启,可能因为ip地址冲突,查看日志:

# cat /var/log/messages|grep network

2,调整分区大小

# df -h

调整根目录大小确保其足够使用。

1、vgdisplay 查询卷组的信息:

[root@CentOS-78 /]# vgdisplay  
  --- Volume group ---  
  VG Name               vg_centos  
  System ID  
  Format                lvm2  
  Metadata Areas        1  
  Metadata Sequence No  5  
  VG Access             read/write  
  VG Status             resizable  
  MAX LV                0  
  Cur LV                3  
  Open LV               3  
  Max PV                0  
  Cur PV                1  
  Act PV                1  
  VG Size               465.27 GiB  
  PE Size               4.00 MiB  
  Total PE              119109  
  Alloc PE / Size       86472 / 337.78 GiB  
  Free  PE / Size       32637 / 127.49 GiB  
  VG UUID               1k4ooN-RFV9-uyf1-uMYf-aERG-YaGs-ZNoSD6  

Free PE / Size指定的应该是现在可在分配的空间。

2、增加vg_centos-lv_root分区的大小

将可用的空间添加到vg_centos-lv_root分区上面:

[root@CentOS-78 /]# lvextend -L +127.40G /dev/mapper/vg_centos-lv_root  
  Rounding up size to full physical extent 127.40 GiB  
  Extending logical volume lv_root to 177.40 GiB  
  Logical volume lv_root successfully resized  

从新设定该分区的大小:

[root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_root  
resize2fs 1.41.12 (17-May-2010)  
Filesystem at /dev/mapper/vg_centos-lv_root is mounted on /; on-line resizing required  
old desc_blocks = 4, new_desc_blocks = 12  
Performing an on-line resize of /dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks.  
The filesystem on /dev/mapper/vg_centos-lv_root is now 46504960 blocks long.  

详见:  http://blog.csdn.net/sunshine920103/article/details/54138345

3,sshd配置

检查sshd服务是否开启:

# ps -aux|grep sshd 

编辑配置文件:

# vim /etc/ssh/sshd_config

设置
permitRootIn yes
注释
#AllowUsers ...
#MACs ...

这样就可以通过XShell连接登录该单板,若要保持长连接:

# vim /etc/profile

注释TMOUT或设为0#export TMOUT=0

执行以下命令使配置生效:

# source /etc/profile

注:多网卡环境ssh不上也有可能是网卡配置文件不对或网关缺失

以eth1接口为例,通过BMC远程登录创建如下文件:

# vim /etc/sysconfig/network-scripts/ifcfg-eth1

BOOTPROTO="dhcp"
DEVICE="eth1"
STARTMODE="onboot"


// 执行以下命令使配置生效:

# service network restart

// 查看及添加网关:
# route -n
# route add default gw 192.168.10.1

4,yum源配置

# cd /etc/yum.repos.d
# ls

需要增加新的源:

# vim version.repo

[euler_compile]
name=uvp
baseurl=http://10.175.100.158/.../repos/Euler_compile_RPMS
enable=1
gpgcheck=0
priority=1

[eulerbase]
name=eulerbase
baseurl=http://10.175.100.158/.../repos/Euler_compile_RPMS
enable=1
gpgcheck=0
priority=2

包括两个源:  [euler_compile] : 安装的.iso所在路径前几级找到的repos路径  [eulerbase] : 再上一级的repos路径

5,git配置

# git config --global user.name "xxx"
# git config --global user.email "xxx"
# git config --global http.sslverify false
# git config --global https.sslverify false
# git config remote.origin.push refs/xxx/*  #配置默认push分支
# git config --list 

使用ssh-keygen生成密钥,并复制到gerrit代码库的Add SSH Key:

# ssh-keygen -t rsa -C "邮箱名"
# vim C:\Users\...\.ssh\id_rsa.pub (Windows)# vim /root/.ssh/id_rsa.pub  (Linux/Unix)

6,DNS配置

在没有dns的server中需要手动配置hosts文件,否则git push失败。这里直接将配置好的hosts文件写入/etc/hosts,保存ip与网址的对应关系:

# cat hosts > /etc/hosts

项目开发额外需要安装:

# yum install update
# yum install gcc automake make kernel-devel kerner-source kernel-debug-devel numactl-devel libtool
# yum install zlib-devel openssl-devel dpdk-devel qemu-devel

git分支查询与切换:

# git branch -a -l
# git checkout xxx 


(责任编辑:IT)
------分隔线----------------------------