使用UltraISO制作安装U盘的步骤
常见问题:
Warning: /dev/root does not exist, could not boot
ls /dev/
或者lsblk
查看U盘对应的盘符,比如/dev/sda4. 启一下,上下键选择安装菜单,然后按下Tab键,编辑启动命令,将vmlinuz initrd=initrd.imginst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
改为:vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quite
Linux 下设置DNS位置有3处,其生效顺序如下:
通过设置主机表地址进行特定主机的解析,优先DNS服务器地址,/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中默认的DNS服务器地址配置文件为/etc/resolv.conf:
nameserver 114.114.114.114 #配置DNS服务器地址,可配置多个
nameserver 8.8.8.8
在网卡配置文件中添加DNS服务器地址, /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
根据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,否则无法解析域名,可参考常用公共DNS服务器地址
service network restart
重启网络
ping baidu.com
是否能够ping通百度
自动生成配置文件:nmcli con add con-name ens3f0 type ethernet ifname ens3f0
配置多个网卡
配置第二个时,需要自己创建配置文件,在重启网卡之前,停止NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
虚拟机克隆后发现网卡名称从eth0改成了eth1,如何改回呢:
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:94:65:9c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:aa:e3:ea", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
```
配置本地时区:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
同步网络时间:
yum install ntpdate
ntpdate pool.ntp.org
手动配置时间:
date –s '2016-12-09 15:50:59'
clock -r //读CMOS日期
clock –w //将日期写入CMOS
hwclock --show //查看硬件时钟
hwclock --set --date="11/23/2016 22:16:59" //设置硬件时钟
或者使用RHEL7及CentOS7中新增的systemd的timedatectl命令,具体参考Linux(RHEL7及CentOS7)的时间设置篇(timedatectl,date,hwclock)-系统管理(2)
# timedatectl
Local time: Thu 2019-03-07 09:10:03 CST
Universal time: Thu 2019-03-07 01:10:03 UTC
RTC time: Thu 2019-03-07 01:10:03
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
# timedatectl -h
timedatectl [OPTIONS...] COMMAND ...
Query or change system time and date settings.
-h --help Show this help message
--version Show package version
--no-pager Do not pipe output into a pager
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--adjust-system-clock Adjust system clock when changing local RTC mode
Commands:
status Show current time settings
set-time TIME Set system time
set-timezone ZONE Set system time zone
list-timezones Show known time zones
set-local-rtc BOOL Control whether RTC is in local time
set-ntp BOOL Control whether NTP is enabled
# 【虚拟机】-【安装VMWare-tools】
mount /dev/cdrom /mnt
cd /mnt
tar xvf /mnt/VMwareTools-9.9.0-2304977.tar.gz -C /tmp
cd /tmp/vmware-tools-distrib
./vmware-install.pl # 一路回车即可
【问题1】安装过程中报错:vmhgfs-only/page.c:1625:23: 错误:提供给函数‘wait_on_bit’的实参太多
1、在解压后的 vmware-tools-distrib/ 目录中,进入到 lib/modules/source/,解压 vmhgfs.tar,得到 vmhgfs-only 目录。
2、修改文件 vmhgfs-only/page.c :把第1622行
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
改成
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) 因为 CentOS 7 的内核版本是 3.10.0。
3、重新把 vmhgfs-only 目录打包为 vmhgfs.tar。
4、重新执行安装脚本 vmware-install.pl。
【问题2】vmvare安装后,共享的文件夹在/mnt/hgfs目录并没有显示出来
1、运行/usr/bin/vmware-config-tools.pl会出现错误
2、/usr/lib/vmware-tools/modules/source目录,同问题的解决步骤进行修改
3、在运行/usr/bin/vmware-config-tools.pl
默认情况下,一般账号是没有 root 权限的。为什么不直接用 root 账号,而是要给一般账号 root 权限呢?
假设账户名为 seisman,要授予他 root 权限,则要修改配置文件 /etc/sudoers :
$ su
# echo 'seisman ALL=(ALL) ALL'>> /etc/sudoers # 向配置文件中加入语句
# tail -1 /etc/sudoers # 检查一下是否正确
seisman ALL=(ALL) ALL
其中 seisman 为当前用户名。
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
这里顺便说一下搭建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
,设置密码
重启服务
service smb restart
service nmb restart
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
安装iptables服务
yum install iptables-services
Linux下客户端测试
smbclient -L //192.168.0.122/samba -U samba_user
设置开机启动
systemctl enable smb.service
Win8下添加网络位置
进入我的电脑,【右击】-【添加网络位置】根据向导一直点击【下一步】,在Internet地址或网络位置下填写\\192.168.0.122\samba
,【下一步】根据提示填写用户与密码。
yum -y install gcc
yum -y install gcc-c++
yum -y install gcc-go
yum -y install lrzsz screen
yum -y install socat nc nmap
yum -y install tree
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"
}
安装完系统,我们常常意愿使用国内的yum源或本地源以提高下载速度,使用第三方库源来获取不在标准库中的资源。常用管理总结如下
yum工具配置文件/etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever # basearch就是架构,如x86_64,releasever版本号,如7
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
系统镜像:CentOS-7-x86_64-DVD-1810.iso
# cat /etc/yum.repos.d/CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
baseurl中可以知道,会去/media/cdrom这项去找源sudo mkdir /media/cdrom;sudo mount /dev/cdrom /media/cdrom
挂载ISOyum repolist all
查看源的状态c7-media CentOS-7 - Media disabled
yum-config-manager --enable c7-media
查看CentOS源的帮助,根据CentOS版本进行对应的操作
CentOS7
yum localinstall http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
# ffmpeg 2.8.15
yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
# ffmpeg 3.4.7
CentOS6.7为例
yum install yum-priorities
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
以上URL请按实际情况修改
rpm -q epel-release
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
在[epel]最后添加一条属性 priority=11
vi /etc/yum.repos.d/epel.repo
意思是yum先去官方源查,官方没有再去epel的源找
yum makecache
在一些软件编译时,对编译器的版本有要求,比如gcc不低于某某或者不高于某某。
Centos7 gcc版本默认4.8.3,为了兼容CentOS6的包,提供了compat-gcc安装包
# yum search compat-gcc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
====================================== N/S matched: compat-gcc ======================================
compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler
compat-gcc-44-gfortran.x86_64 : Fortran support for compatibility compiler
Red Hat 为了软件的稳定和版本支持,yum 上gcc版本也是4.8.3,所以无法使用yum进行软件更新。要升级更高版本的gcc,我们需要scl源
yum install -y centos-release-scl
yum install -y scl-utils-build
yum install -y devtoolset-4-toolchain
scl --list
scl enable devtoolset-4 bash
参考: Centos7升级gcc版本方法之一使用scl软件集
http://vault.centos.org/
yum install man-pages libstdc++-docs
安装开发手册虚拟机长时间不用,最可能发生的事情是忘记root密码
https://www.cnblogs.com/zhangjianghua/p/6094496.html
参考: