CentOS7日常操作记录
2018-04-14 本文已影响0人
mr_xl
1.安装vim
首先使用命令查看相关的是不是安装了vim:如下:
[root@localhost ~]# rpm -qa|grep vim
出现如下的结果
vim-minimal-7.4.160-1.el7.x86_64
再输入下面的命令,则可以安装完vim相关工具了。
[root@localhost ~]# yum -y install vim*
输入结果:
已加载插件:fastestmirror
......
软件包 2:vim-minimal-7.4.160-2.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
......
--> 解决依赖关系完成
依赖关系解决
正在安装:
......
安装 4 软件包 (+72 依赖软件包)
总下载量:30 M
安装大小:94 M
......
---------------------------------------------------------------------------------------------------------------
总计 5.1 MB/s | 30 MB 00:00:05
......
已安装:
......
作为依赖被安装:
atk.x86_64 0:2.22.0-3.el7 avahi-libs.x86_64 0:0.6.31-17.el7
......
perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7
perl-libs.x86_64 4:5.16.3-292.el7 perl-macros.x86_64 4:5.16.3-292.el7
perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7
perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7
pixman.x86_64 0:0.34.0-1.el7 stix-fonts.noarch 0:1.1.0-5.el7
完毕!
2.修改ip地址
1.我们先查看网关
[root@server-mysql ~]# ip route show
default via 192.168.8.2 dev ens33 proto static metric 100
192.168.8.0/24 dev ens33 proto kernel scope link src 192.168.8.101 metric 100
2.输入以下命令打开网卡配置文件
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
默认配置如下:
默认网卡配置.png
3.我们将上面的配置修改为如下:
上图中GETWAY应该是GATEWAY.png
3.安装JDK1.8
方式一:
1.使用命令检查是否安装了jdk, 如果输出任何信息就是没有安装.
rpm -qa |grep java
rpm -qa |grep jdk
rpm -qa |grep gcj
2.如果有信息输出, 使用下面的命令卸载掉
rpm -qa | grep java | xargs rpm -e --nodeps
3.接着java或者java1.8检索
yum list java*
yum list java-1.8*
结果:
[root@localhost ~]# yum list java-1.8*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
可安装的软件包
java-1.8.0-openjdk.i686 1:1.8.0.161-0.b14.el7_4 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.161-0.b14.el7_4 updates
......
4.使用命令安装(会自动设置环境变量)
yum install java-1.8.0-openjdk* -y
5.查看是否安装成功(显示版本号即为成功)
java -version
输出
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
方式二:
1.到官网http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html下载jdk-8u161-linux-x64.tar.gz
2.上传到linux系统中的'/usr/local'目录下, 并用命令 'cd /usr/local'进到此目录下.
3.用'tar -zxvf jdk-8u161-linux-x64.tar.gz'解压文件.
4.使用'vim /etc/profile'打开环境变量配置文件.
5.在文件末尾加上下面语句并保存.
export JAVA_HOME=/usr/local/jdk1.8.0_161
export PATH=$PATH:$JAVA_HOME/bin
6.用命令'source /etc/profile'刷新配置文件.
7.查看是否安装成功(显示版本号即为成功)
java -version
输出
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
4.开启和关闭端口
1.开启端口
firewall-cmd --add-port=8080/tcp --permanent
2.关闭端口
firewall-cmd --remove-port=8080/tcp --permanent
3.重新加载
firewall-cmd --reload
4.查看开放的端口
firewall-cmd --list-port
5.修改主机名
vim /etc/sysconfig/network 将HOSTNAME修改为你的主机名
vim /etc/hostname 将原来的主机名删除,添加你的新主机名
vim /etc/hosts 将原来的映射主机名修改为你的新主机名
6.关闭selinux
查看状态
[root@common-server ~]# /usr/sbin/sestatus -v
输出
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
Process contexts:
Current context: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Init context: system_u:system_r:init_t:s0
/usr/sbin/sshd system_u:system_r:sshd_t:s0-s0:c0.c1023
File contexts:
Controlling terminal: unconfined_u:object_r:user_devpts_t:s0
/etc/passwd system_u:object_r:passwd_file_t:s0
/etc/shadow system_u:object_r:shadow_t:s0
/bin/bash system_u:object_r:shell_exec_t:s0
/bin/login system_u:object_r:login_exec_t:s0
/bin/sh system_u:object_r:bin_t:s0 -> system_u:object_r:shell_exec_t:s0
/sbin/agetty system_u:object_r:getty_exec_t:s0
/sbin/init system_u:object_r:bin_t:s0 -> system_u:object_r:init_exec_t:s0
/usr/sbin/sshd system_u:object_r:sshd_exec_t:s0
永久关闭
[root@common-server ~]# vim /etc/selinux/config
将SELINUX=enforcing修改为SELINUX=disabled
7.开启和关闭firewalld(防火墙)
开启
$ sudo systemctl start firewalld.service
关闭
$ sudo systemctl stop firewalld.service
查看是否关闭
$ firewall-cmd --list-port
FirewallD is not running
$ sudo systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 五 2018-12-07 12:04:11 CST; 23s ago
Docs: man:firewalld(1)
Process: 24529 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 24529 (code=exited, status=0/SUCCESS)
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C OUTPUT -m addrtype --dst-type LOCAL -j DOCKER ! --dst 127.0.0.0/8' failed: iptables: No chain/target/match by that name.
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 -j DOCKER' failed: iptables: No chain/target/match by that name.
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT' failed: iptables: Bad rule (does a...in that chain?).
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -j DOCKER-ISOLATION-STAGE-1' failed: iptables: No chain/target/match by that name.
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -n -L DOCKER-USER' failed: iptables: No chain/target/match by that name.
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C DOCKER-USER -j RETURN' failed: iptables: Bad rule (does a matching rule exist in that chain?).
12月 07 12:03:35 localhost firewalld[24529]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -j DOCKER-USER' failed: iptables: No chain/target/match by that name.
12月 07 12:04:10 localhost systemd[1]: Stopping firewalld - dynamic firewall daemon...
12月 07 12:04:11 localhost systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.