Because of the need to build a Hadoop platform, but there is no ready-to-use Linux server, had to download the CentOS 6.5 from scratch, the installation process encountered a lot of problems, such as network configuration, clock synchronization, environment variable configuration, and various services to start and stop, There are JDK installation and so on (although the system comes with the JDK, but I am too low-end, the installation path of the JDK is not clear, I simply installed a), the time is easy to forget, so write down here as a record, by the way also share to me the same rookie players, Masters can retreat, Of course, if there is criticism, the younger brother knelt.
- New user
The newly installed Linux is generally only the root administrator user, because I want to build the Hadoop platform, so create a new user named Hadoop:
Useradd hadooppasswd Hadoop
New Password:
Follow the prompts to set the user password, and then you will find a Hadoop directory in the/home directory, this is the working directory of Hadoop users, when you switch users to Hadoop, the default path will be switched to the/home/hadoop path. Of course, we need to configure the various parameters of the system, but also need to operate under the root user, because the normal user does not have sufficient permissions to modify the system-level configuration files, if not specifically described below, is the default under the root administrator user operation .
- Modify Host Name
Linux in the installation process has set the hostname, if you feel that the name is too hasty, want to modify it is very simple, under the root user into the/etc/sysconfig directory, modify the network file can be:vi /etc/sysconfig/networknetworking=yeshostname=Master
As in, just modify hostname for the name you need, my host name is master.
- Configure Network Connections
Linux hosts the most important thing is the network configuration, we enter the/etc/sysconfig/network-scripts directory, find the Ifcfg-eth0 file, modify the contents as follows:vi /etc/sysconfig/network-scripts/ifcfg-eth0device=eth0hwaddr=xx: 1a:a0:9d: FA:ipaddr=10.1.5.229NETMASK=255.255.255.0GATEWAY= 10.1.5.254DNS1=202.106.0.20
The gateway address is related to the network of the host, different network segment is different, and ipaddr is the IP address of the machine, according to the Gateway's network segment to fill in at will, generally the bottom is 2~254, as long as not with other host IP address conflict can be ; The netmask subnet mask is typically 255.255.255.0, while the DNS server is generally set to 202.106.0.20 on the domestic network. After the configuration file is set up, use the following command to restart the network service:
Service Network restart
Then you should try a network service, such as ping Baidu:
PingWww.baidu.comPING www.baidu.com (124.16.31.151) About( -) bytes of data. -Bytes from124.16.31.151: icmp_seq=1Ttl= the Time=8.22Ms -Bytes from124.16.31.151: icmp_seq=2Ttl= the Time=7.45Ms -Bytes from124.16.31.151: icmp_seq=3Ttl= the Time=8.77Ms -Bytes from124.16.31.151: icmp_seq=4Ttl= the Time=9.54Ms
This means that the network is already on, and setup is complete.
- Firewalls and SELinux
Firewall iptables and SELinux are the Linux system's own security system, due to various security restrictions, so that many of our system access is limited and failed to run, although it is not reasonable to do so, but we generally disable iptables and SELinux, To disable SELinux first:VI/etc/sysconfig/selinux# ThisfileControls the state of SELinux on the system.# selinux=Can take one of these three values:# enforcing-SELinux security Policy is enforced.# permissive-SELinux Prints warnings instead of enforcing.# disabled-No SELinux policy is loaded. SELINUX= enabled# Selinuxtype=Can take one of these values:# targeted-targeted processes is protected,# MLS-Multi level Security protection. Selinuxtype=targeted SELINUX=Disabled
Change the SELinux parameter to disable.
Then disable iptables slightly more complex, first, turn off Firewall service iptables:
Service Iptables Stop
This is not over, because every time you restart the server, the system is the default self-booting iptables service, so also to turn off the auto-start service:
Chkconfig iptables off
This completely shuts down the firewall and the SELinux service, preventing the future of the system due to the lack of access to the exception caused by the port.
Research a little firewall filtering configuration, that is, without shutting down the iptables service, open some ports separately, such as the system by default open the 22,21 and 20 ports, configured as follows:
VI/etc/sysconfig/iptables# Firewall configuration written by System-config-firewall# Manual Customization of thisfileis not recommended.*filter:input ACCEPT [0:0]:forward ACCEPT [0:0]:output ACCEPT [0:0]-A input-m state--state established,related-J ACCEPT-A input-p ICMP-J ACCEPT-A input-i lo-J ACCEPT-A input-m state--state new-m tcp-p TCP--dport A-J ACCEPT-A input-m state--state new-m tcp-p TCP--dport +-J ACCEPT-A input-m state--state new-m tcp-p TCP--dport --J ACCEPT-a input-m state--state new-m tcp-p TCP--dport 50030 -J ACCEPT-a input-m state--state new-m Tcp-p TCP--dport 50070 -J ACCEPT-A input-m State--state new-m tcp-p TCP--dport 50010 -
j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited-A forward-j REJECT--reject-with icmp-host-Prohibitedcommit
As can be seen in the system default open ports 22,21 and 20, while 50030,50070 and 500,103 ports are I specify open, save the configuration after running the Restart iptables Service command:
Service Iptables Restart
- installation and configuration of sudo
We sometimes want to be able to perform certain root privileges without switching to the root user, which requires the sudo command, sudo is not installed by default in the minimum installation mode of CentOS, and we need to check sudo installation with the Yum command first:Yum grep sudo sudo. i686 1.8. 6p3-. El6 @anaconda-centos-201311271240. i386/ 6.5
The above shows that the system has its own sudo program, can be used directly. If not installed, install it yourself:
Yum Install sudo
Subsequently, we need to add a generic user to the sudo list, we need to switch to the root user, using the Visudo command, will automatically open the/etc/sudoer file:visudo## allow root-to- run any commands anywhereroot all =[All] allHadoop All=(All) ALLhadoop2 all = ( all) All
Where the yellow part for me added the general user Hadoop and HADOOP2, the changes take effect immediately, no need to restart the system. This allows us to start and stop servcie with the sudo command under the Hadoop User:
sudo Service Network restart[sudo for Hadoop:
Just enter the password for the Hadoop user to execute it smoothly.
- installation configuration for JDK
General Linux systems are self-bringing JDK, we can use the command to check if the JDK exists, and confirm the version:Java-"1.7.0_51"1.7. 0_51-24.51-b03, Mixed mode)
As indicated above, the JDK version is 1.7.0_51. The basic steps to manually install the JDK is this, first download the JDK RPM installation package, jdk-7u51-i586.rpm, choose the version needs according to its own operating system, my system for the CentOS 6.5-i586, that is, 32-bit system, so select this version If it is a 64-bit system, select JDK-7U51-LINUX-X86-64.RPM. To install using the RPM installation command:
--prefix=/opt jdk-7u51-linux-/optmv jdk1. 7. 0_51 JDK1. 7
Where the red--prefix parameter specifies the installation path, which is specified as the/OPT directory, and if the installation path is not specified, it is installed by default in the/usr directory. Enter the OPT directory and rename the installation directory to jdk1.7 for later reference.
Because of the Linux built-in JDK, we also need to remove the references from the JDK when we install the new JDK, and replace the JDK with the newly installed JDK, otherwise the newly installed JDK will not work at all:
cd/usr/binrm -f javarm -F javacrm -F javawsRM -F javadocrm -F javaprm -F JPS
Wherein, the/usr/bin directory for our post-installation of the software command of the reference storage path, the command stored in the path can be executed without a path, directly in any directory . We write a reference to the command of the newly installed JDK to the directory:
Ln -s/opt/jdk1. 7/java javaln -s/opt/jdk1. 7/javac javacln -s/opt/jdk1. 7/javadoc javadocln -s/opt/jdk1. 7/javaws javawsln -s/opt/jdk1. 7/javap javapln -s/opt/jdk1. 7/jps JPS
Where the ln command is used to create a link, the-s parameter indicates that the link is a virtual link, similar to a shortcut to Windows.
- Configuration of environment variables
Environment variables under Linux are usually divided into two types: System environment variables and user environment variables. The system environment variable is a common environment variable for all users, and the user environment variable is only valid for that single user, and different users can configure different environment variables. The system environment variable needs to be configured under the root user, the configuration file is/etc/profile, the configuration content is general general parameters, such as Java_home, PATH, Classpath and so on:vi /etc/profileexport java_home=/opt/jdk1. 7 export PATH= $PATH: $JAVA _home/binexport CLASSPATH=.: $JAVA _home/lib
The user environment variables need to be configured under the corresponding user, such as my Hadoop user environment variables, the configuration file is stored in the Hadoop user's working directory,/home/hadoop/.bash_profile,.bash_profile as a hidden file, configured as follows:
Export Hadoop_home= $HOME/Hadoop2export hadoop_mapred_home=${hadoop_home}export hadoop_common_home=${hadoop_home}export hadoop_hdfs_home=${hadoop_home}export yarn_home=${hadoop_home}export Hadoop_conf_dir=${hadoop_home}/etc/Hadoopexport Hdfs_conf_dir=${hadoop_home}/etc/Hadoopexport Yarn_conf_dir=${hadoop_home}/etc/Hadoopexport Hadoop_log_dir=${hadoop_home}/Logsexport hbase_home= $HOME/hbase-0.98Export Hive_home= $HOME/Hiveexport sqoop_home= $HOME/Sqoopexport tomcat_home= $HOME/Tomcat7export solr_home= $HOME/Solrexport maven_home= $HOME/Mavenexport java_library_home= $HOME/Jlibpath= $PATH: $HOME/bin: $HADOOP _home/bin: $HADOOP _home/sbin: $HBASE _home/bin: $HIVE _home/bin: $MAVEN _home/bin:/$SQOOP _ Home/bin: $TOMCAT _home/Binexport CLASSPATH= $CLASSPATH: $HADOOP _home/share/hadoop: $HBASE _home/lib: $HIVE _home/lib: $SQOOP _home/lib: $TOMCAT _home/lib: $SOLR _ home/Dist: $JAVA _library_homeexport PATH
After the configuration is complete, the environment variables need to take effect immediately and the source command must be executed under the appropriate user:
~] $ source. bash_profile
- Linux clock synchronization
We build a variety of distributed clusters on the Linux platform, many require each node in the cluster to do clock synchronization, otherwise it will not start normally. Linux clock synchronization is typically used with the built-in NTP synchronization service. First, use the RPM command to check if the NTP service software is installed:grep ntpntpdate-4.2. 6p5-1. El6.centos.i686fontpackages-filesystem-1.41- 1.1 . EL6.NOARCHNTP-4.2. 6p5-1. el6.centos.i686
If it is not found, then the NTP package is not installed and is installed by the RPM package of the RPM package, which has already been mentioned in the installation command. After the installation is complete, under the root user, check that the NTPD service is started, start the service manually without booting, and start the boot-up NTPD service:
Service NTPD Status
NTPD is stopped
Service NTPD Startchkconfig ntpd on
The Chkconfig command allows you to check if the self-boot of the service has been turned on, taking NTPD as an example:
grep ntpdntpd 0: Off 1: Off 2: On 3: On 4: on 5 :on 6: offntpdate 0: Off 1: Off 2 : Off 3: Off 4: Off 5: Off 6: Off
It shows that the NTPD service is powered on and self-booting, for ntpdate no boot.
I can only remember so much for the time being, if we encounter other problems later, we will continue to add. If there is anything wrong with the above record, please do not hesitate to shoot the bricks.
Reprint Please specify source: http://www.cnblogs.com/bxljoy/p/3868494.html