Operation and maintenance specifications finishing

Server management practices

1, for there is no proven command must not be allowed to run on the server, you must fully understand the results of the command before execution. You must determine the current working directory when executing commands.

2, minimize the use of server rm -rf command, did not encounter the way files can use mv filename / tmp, the files in the / tmp catalog, automatically deleted from the system after 10 days.

3, modify the configuration file must be backed up, such as cp filename filename.20160504, and then modified.

4, when the project must back up the original release date file format packaged as tar zcvf filename20160504.zip filename.

CPU name

Command Rule

  • Hostname allowed to contain only ascii characters in the numbers 0-9, the letters a-zA-Z, hyphen (-). Others are not allowed. For example, does not allow other punctuation, spaces are not allowed, do not allow underscores, Chinese characters are not allowed.
  • Beginning and end of the character of the host name is not allowed hyphen. Hostname is strongly recommended not to start with a number, although this one is not mandatory. Do not even containing only be interpreted as a hexadecimal string of characters, such as "beef".
  • It is not recommended to use special vocabulary of the field of computers, for example, up.
  • Named to the host usually does not consider the letter case problem.

To the host name, we recommend using a legitimate word, so easy to remember.

Normally deployment project based on the deployment document defines the host name, but there are still a large number of hosts using the default localhost, need to be modified into a meaningful host name.

命名示例:

山东项目济南数据库命名:
JNPORTALDB1、JNBODB2

Modify the hostname

Centos/Redhat6.x

1、临时修改,例如将主机名更改为test103
hostname test103

临时修改后,重新打开一个终端,就看到更新了,但服务器重启后会失效。


2、永久修改
vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=test103

将HOSTNAME修改为需要的主机名即可。

1 + 2 can be practical binding step, even after commencement, the server may also take effect the next reboot.

Modify the database server host name

因MySQL服务运行会根据主机名生成pid和err文件,因此修改主机名时需要先关闭数据库服务。

执行:/etc/init.d/mysql stop

关闭后执行修改主机名操作,修改后打开新的终端启动mysql即可。

运行中的mysql如果修改主机名,会导致服务异常关闭,当然修改后杀掉所有进程mysql应该还可以正常启动,不过不建议这么操作。

Centos7

hostnamectl直接修改生效:
hostnamectl set-hostname test103

查看主机名:
hostnamectl status

一旦修改了静态主机名,/etc/hostname 将被自动更新。然而,/etc/hosts 不会更新以保存所做的修改,所以你每次在修改主机名后一定要手动更新/etc/hosts,之后再重启CentOS 7。否则系统再启动时会很慢。

vim /etc/hosts
#127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1  test103
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
::1        test103

user

Turn off unnecessary services

Document Management

Package storage path

Script storage

data backup

Common Commands

Commonly used third-party tools

iotop

Common script

ntpdate

database backup

find

grep

Guess you like

Origin www.cnblogs.com/szz1113/p/11769894.html