Ali cloud server CentOS server initialization setup steps

  • 2020-05-13 04:12:23
  • OfStack

The initial setup of CentOS server is actually not divided into aliyun or other servers, and the operation and configuration process is similar to the steps below and this site 1.
1. Mount the hard drive

1. Disk partitioning

fdisk-l # view device, 1 normally see device name /dev/xvdb

fdisk /dev/xvdb # partitions the disk

Enter n # to create the new partition

Enter p # to create the primary partition

Enter 1 # to create the first primary partition

Create a partition by entering w # to save and execute the above command

Once the above command has been executed, look at it with fdisk-l, and you'll see something similar

/ dev xvdb1 partitions

Indicates that the partition was successful.

2, disk formatting

mkfs.ext4 /dev/xvdb1 # format the partition (www.ofstack.com)

Note: ext4 is the default partition format for CentOS6.x, please use ext3 for CentOS5.x

When the formatting is complete (depending on the size of the partition and the time required for formatting, please be patient), mount the partition

Mount the disk

For example, mount /dev/xvdb1 to /data

mkdir-p /data # create a directory

mount /dev/xvdb1 /data # mount

df-h # view mount results

vi /etc/fstab # setup startup auto mount, enter the following code on the last line

/dev/xvdb1 /data ext4 defaults 0 0

: wq! # save exit

mount-a # causes partition Settings to take effect immediately

Below is the site this site for you to share 1 some content, convenient for you to learn reference

Modify the locale
[root@oracledb ~]# sudo vim /etc/sysconfig/i18n
Change zh_CH to "en_US.es1064en-8"

Set up yum local source

Methods to be continued

vsftpd installation configuration
Reference: CentOS configuration VSFTP server
yum install vsftpd

Set vsftpd to boot

Last login: Tue Aug 12 08:21:26 2014 from l-001812.lan
[root@oracledb ~]# chkconfig --list|grep vsftpd
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@oracledb ~]# chkconfig vsftpd on
[root@oracledb ~]# chkconfig --list|grep vsftpd
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@oracledb ~]#
Configure firewall
Open the /etc/sysconfig/iptables file

1.vi /etc/sysconfig/iptables
Add the following code before the REJECT line

1.-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
Save and close the file and restart the firewall

1.service iptables restart
Create ftp connection with active connection mode and utf8 character set (optional)

Modify the ftp access rights

View using the command getsebool-a |grep ftp [root@oracledb vsftpd]# getsebool -a|grep ftp
allow_ftpd_anon_write -- > off
allow_ftpd_full_access -- > off
allow_ftpd_use_cifs -- > off
allow_ftpd_use_nfs -- > off
ftp_home_dir -- > off
ftpd_connect_db -- > off
ftpd_use_fusefs -- > off
ftpd_use_passive_mode -- > off
httpd_enable_ftp_server -- > off
tftp_anon_write -- > off
tftp_use_cifs -- > off
tftp_use_nfs -- > off See if the above red is on Use if not setsebool allow_ftpd_full_access on setsebool ftp_home_dir on [root@oracledb vsftpd]# getsebool -a|grep ftp
allow_ftpd_anon_write -- > off
allow_ftpd_full_access -- > on
allow_ftpd_use_cifs -- > off
allow_ftpd_use_nfs -- > off
ftp_home_dir -- > on
ftpd_connect_db -- > off
ftpd_use_fusefs -- > off
ftpd_use_passive_mode -- > off
httpd_enable_ftp_server -- > off
tftp_anon_write -- > off
tftp_use_cifs -- > off
tftp_use_nfs -- > off

vi /etc/profile // Add to the end of the file 
#set Java environment  
export JAVA_HOME=/usr/local/java
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin

Set the static ip address
CentOS has set the address of ip in the desktop environment, but it cannot be logged in through ssh after restarting. You must log in the account under the desktop, and eth0 can only be accessed by ping after starting it. So under the desktop Settings can not boot enabled network card, you must modify the configuration file can be.

If we want to change the host address to a static address or change the host name, the following files need to be modified:
/etc/sysconfig/network sets the hostname and network configuration
/etc/sysconfig/ network-scripts/ifcfg-eth0 is set for a specific network card
/ etc/resolv DNS conf Settings
/etc/hosts sets the domain name resolution address specified

In general, we only need to modify the network card configuration file ifcfg-eth0. The modification method is as follows

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

Edit configuration file


[root@MAP ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 
TYPE=Ethernet
UUID=1e3f09ce-74aa-4d8b-9988-a6db9aef4d32
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
HWADDR=00:50:56:B8:37:90
IPADDR=10.138.16.144
NETMASK=255.255.255.0
PREFIX=24
GATEWAY=10.138.16.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"

explain


DEVICE=eth0 # Describes the device alias for the network card, for example ifcfg-eth0 In the file it is eth0
BOOTPROTO=static # Set the network card to get ip The possible options are static . dhcp or bootp , respectively, corresponding to statically specified  ip Address, via dhcp agreed-upon ip Address, via bootp agreed-upon ip address 
BROADCAST=192.168.0.255 # The corresponding subnet broadcast address 
HWADDR=00:07:E9:05:E8:B4 # The corresponding network card physical address 
IPADDR=12.168.1.2 #ip address 
IPV6INIT=no // You can add or you can not add 
IPV6_AUTOCONF=no // Same as above 
NETMASK=255.255.255.0 # The network mask corresponding to the network card 
GATEWAY=10.138.16.254 # The gateway 
ONBOOT=yes # Whether to set this network interface when the system starts, set to yes , the device is activated when the system is started 

Restart to enable the configuration

service network restart


Related articles: