Linux and Common tool configurations
as the code farmers, said very much hate the server on a variety of messy configuration, usually rarely used to Linux commands, Linux has been kept learning to forget, forget to learn the death cycle, so do this note, may later look at the opportunity is not much, after all, always useful to the time
PS: This article only for CentOS, use other distributions Linux please bypass, there is a supplementary can fork me
In addition, the article does not contain installation parts, will not be installed please check yourself First, prepare
Operating system
* CentOS
(I use 7, recommended installation minimal version, do not use the system with tools, all their own installation)
Virtual machine software (only for learning CentOS under the WINDOWS/MAC operating system, or skip this)
* VirtualBox
(It is recommended to use open source software, and this article only for this virtual machine) Two, system article
Description |
Command |
View System kernel |
Uname-r |
View all kernel information |
Uname-a |
Open Firewall (for CentOS 7 only) |
Systemctl Start Firewalld.service |
Turn off the firewall (for CentOS 7 only, recommend close with virtual machine practice) |
Systemctl Stop Firewalld.service |
Third, the network articleView IP (minimal version does not have ifconfig command)
IP addr
Modify configuration file (filename not necessarily called this)
Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Change Onboot to Yes, meaning whether or not to activate the NIC at system startup to change nm_controlled to Yes, if this line is not added, meaning it takes effect immediately, without restarting the NIC to restart the network service
Service Network restart
Iv. Communication Articles
By default, the host is not able to access the VirtualBox internal, so to do the following to view the host network connection, the installation of VirtualBox will default to create a network connection named VirtualBox host-only Network
* View IP segment, usually 192.168.56.*, do not need to modify, remember can
* Modify the virtual machine network settings, add network card 2, connect mode select only Host (HOST-ONLY) adapter, save
* Use IP addr in the virtual machine, remember the IP segment of the new network card, must be consistent with the IP segment of VirtualBox host-only network, if consistent, access the virtual machine in the host, see if it can ping
* Check the VSFTPD software is installed, the default is not installed, can not remotely connect the system
Rpm-qa|grep vsftpd
Install VSFTPD
Yum-y Install VSFTPD
Modify the Ftpusers and user_list files under/etc/vsftpd/to delete accounts that deny remote logins start VSFTPD Service
Service VSFTPD Start
v. Basic ToolsUpdate Yum
Yum Update
Install Vim (text editor, minimal version default only installed VI, no VIM)
Yum-y Install Vim
Install GCC (c language source code compilation)
Yum-y Install gcc-c++
Install zlib (decompression tool)
Yum-y Install Zlib
Install wget (download tool)
Yum-y Install wget
Install Pcre (Regular expression)
Yum-y Install Pcre
Install OpenSSL (for HTTPS)
Yum-y Install OpenSSL
Install make (Installation tool)
Yum-y Install make
VI. Environment Variables
Linux environment variables are divided into multiple, different levels
System-Level environment variables
1./etc/profile
2./etc/environment
User-level environment variables
1. ~/.profile
2. ~/.BASHRC
Effective immediately after modification
SOURCE environment variable
Seven, software article
recommended to use the wget [url] command to download, also available FTP upload, do not need to install the recommended to the/usr/lib/path JDK
Configure environment variables to be available without installation, directly after decompression
Take Jdk7 as an example, modify the environment variable, and add the following lines at the end (don't forget to use source to make the environment variable effective after configuration)
Export JAVA_HOME=/USR/LIB/JVM/JDK7 (JDK decompression path)
export Jre_home=${java_home}/jre
export Classpath=.:${java_ Home}/lib:${jre_home}/lib
export path= $PATH: ${java_home}/bin
Scala
configuration environment variables are available without installation, but you need to install the JDK first
Take scala-2.11 as an example, modify the environment variable, and add the following lines at the end (don't forget to use source to make the environment variable effective after configuration)
Export scala_home=/usr/lib/scala/scala-2.11 (SCALA Class Library decompression path)
export path= $PATH: ${scala_home}/bin
Tomcat
configuration environment variables are available without installation, but you need to install the JDK first
Take Tomcat8.0.35 as an example to modify the environment variable and add a row at the end (don't forget to use source to make the environment variable effective after configuration)
Export tomcat_home=/usr/local/tomcat-8.0.35 (TOMCAT decompression path)
Configure virtual memory, add under #!/bin/sh
Java_opts= '-xms256m (initialization heap memory)
-xmx512m (maximum heap memory)
-xx:permsize=256m (initialization stack memory)
-xx:maxpermsize=512m (max stack memory)
Nginx
installation
minimal version does not rely on the source code, you need to download the pcre/openssl/zlib of the source code before installation (not installed, install folder have), the installation package recommended put to the/usr/src/path
After unpacking the installation package, execute the Configure file, and if not, use the chmod to assign the weight and append the parameter
./configure \
--prefix=/usr/local/nginx-1.11.0 (installation path) \
--with-http_ssl_module (support HTTPS) \
--with-http_ Stub_status_module (support status monitoring) \
--with-pcre=/usr/src/pcre (pcre source path)
--with-openssl=/usr/src/openssl ( OpenSSL source path)
--with-zlib=/usr/src/zlib (zlib source path)
Execute in sequence after success
Make make
Install
Start Nginx Server
/usr/local/nginx-1.11.0/sbin/nginx
Stop Nginx Server
/usr/local/nginx-1.11.0/sbin/nginx-s stop
Reload Configuration
/usr/local/nginx-1.11.0/sbin/nginx-s Reload
Base Configuration
Master configuration file: conf/nginx.conf
Worker_processes 1 #nginx进程数, it is recommended to set the total CPU core of the
events {
worker_connections 1024; #单个进程最大连接数, Nginx Maximum connections = number of processes * Single process maximum number of connections
}
http {
include mime.types;
Default_type Application/octet-stream;
Sendfile on ;
Keepalive_timeout #超时时间, the unit is seconds
server {#代理服务器数量, you can configure multiple
listen ; #监听端口
server_name localhost #服务器域名
charset utf-8; #字符集
location/{
proxy_pass http://proxy.com; #反向代理名称, Used to match cluster
proxy_redirect default
;
Error_page 502 503 504 /50x.html; #错误码对应转向
location =/50x.html {
root html;
}
}
upstream proxy.com {#这里匹配反向代理名称
server 192.168.56.1:9000 weight=1; #真实项目地址以及权重
Server 192.168.56.101:9000 weight=1; #权重数字越大被分配到的几率就越高
}
}
MySQL
from a personal point of view, I do not recommend the use of MySQL database, you can use MARIADB as far as possible, the reason for their own Google, if you must use MySQL, please see the following configuration installation
In CentOS 7, the system is installed by default MARIADB, you need to uninstall first, use the following command to view the installed MARIADB related software
Rpm-qa|grep mariadb
Uninstall using the following command
RPM-E--nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
Minimal version also has no Libaio, need to install
Yum-y Install Libaio
and Net-tools
Yum-y Install Net-tools
Linux under the MySQL is divided into source installation and RPM installation, because the source code installation needs to have all the dependencies of the source code, so strongly do not recommend the use of source code installation, the official website to download the RPM integration package is good, Here to mysql-5.7.12 as an example, after the download decompression, do not need all installation, in turn install the following installation package can be, the order can not be reversed
RPM-IVH mysql-community-common-5.7.12-1.el7.x86_64.rpm
RPM-IVH mysql-community-libs-5.7.12-1.el7.x86_64.rpm
rpm-ivh mysql-community-client-5.7.12-1.el7.x86_64.rpm
rpm-ivh mysql-community-server-5.7.12-1.el7.x86_ 64.rpm
Install complete, do not start MySQL configuration First
Modify configuration file
Vim/etc/my.cnf
Add a row under [Mysqld]
Skip-grant-tables
Start MySQL after saving
Service mysqld Start
At this point, you can enter MySQL directly with the null password
Mysql-uroot-p
Switch to the MySQL library and modify the password, the MySQL5.7 version of the password field is authentication_string, the lower version is password
Use MySQL
update user set Authentication_string=password (' 123456 ') where user= ' root ';
Stop the database after exiting, delete the changes in/ETC/MY.CNF, restart the database, configure the mariadb installation
MARIADB is the database recommended by CentOS, the installation requires only one line of command
Yum-y Install mariadb Mariadb-server
Set to power-on self-boot
Systemctl Enable MARIADB
Configuration
Start mariadb after Setup completes
Service MARIADB Start
Run Configuration Wizard
Mysql_secure_installation
The first prompt to enter the current password, direct return to the second prompt whether to set the password, direct return input password, return confirmation password, enter whether to delete anonymous users, direct return to prohibit remote logins, depending on the actual situation and determine whether to delete the test database, direct return to reload permissions, enter, configuration completed
PostgreSQL
installation
PostgreSQL is also the CentOS recommended database, the installation also requires only one line of command
Yum Install postgresql*
Initializing the database
Postgresql-setup Initdb
Set to power-on self-boot
Systemctl Enable PostgreSQL
Configuration
Start PostgreSQL first.
Systemctl start PostgreSQL
Access to the database
Su-postgres
Creating roles
CreateUser Admin (user name)
Creating a Database instance
CREATEDB-E-o admin (user name) TestDB (instance name)
Enter Query Analyzer
Psql
Set Password
\password admin; (username, end with semicolon)
Exit Query Analyzer
\q (no semicolon end required)
Exit database
Exit
Modify Listening
Vim/var/lib/pgsql/data/postgresql.conf
Open and modify this comment
listen_addresses = ' * '
Modify authentication method
Vim/var/lib/pgsql/data/pg_hba.conf
Modify or copy the following
Host all 127.0.0.1/32 (which IP access is allowed, if all is allowed, written as 0.0.0.0/0) MD5 (MD5 for password authentication)
Restart the database
Systemctl Restart PostgreSQL
Log on to the database with a password
Psql-u Admin (username)-D testdb (database)-H 127.0.0.1 (login to which IP)
Login successful, configuration complete Redis
After decompression, enter the Redis directory first, take 3.2.0 as an example
CD redis-2.8.17
Then make
Make
Enter SRC directory
CD src
Run Redis-server start Redis service
./redis-server
However, it does not return to the command line after it is started, so after the command, start Redis and return to the command line.
./redis-server &
Hadoop
no installation, direct decompression, modify configuration file is available, but need to install JDK first
No private key can only play stand-alone version, in terms of personal learning, stand-alone version is enough
Take hadoop-2.7.2 as an example, unpack and go to the Hadoop path, create 4 folders
mkdir tmp
mkdir hdfs
mkdir hdfs/data mkdir hdfs/name
Configure the environment variable and add the following lines at the end (don't forget to use source to make the environment variable effective after configuration)
Export hadoop_home=/root/download/hadoop-2.7.2
export path= $PATH: ${hadoop_home}/bin
Hadoop cannot be accessed by IP, modify hostname and host mappings, host name modification (CentOS 7 only)
Hostnamectl Set-hostname Host Name
Modifying the host mapping file
Vim/etc/hosts
Modify Core-site.xml, note that this is a relative path
Vim Etc/hadoop/core-site.xml
Add in the Configuration tab
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop:9000</value>
the meaning of <!--value is hdfs://host Name: Port number-->
</property>
<property>
<name> hadoop.tmp.dir</name>
<value>file:/root/download/hadoop-2.7.2/tmp</value>
<!-- We need to use absolute path-->
</property>
<property>
<name>io.file.buffer.size</name>
<value>131702</value>
</property>
Modify Hdfs-site.xml, relative path
Vim Etc/hadoop/hdfs-site.xml
Also add in the Configuration tab
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/root/download/ Hadoop-2.7.1/hdfs/data</value>
<!--modify absolute path-->
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/root/download/hadoop-2.7.1/fdfs/data< /value>
<!--modify absolute path-->
</property>
<property>
<name>dfs.replication </name>
<value>2</value>
</property>
<property>
<name> dfs.namenode.secondary.http-address</name>
<value>hadoop:9001</value>
<!-- Don't forget to change the-->
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
Renaming templates
MV Etc/hadoop/mapred-site.xml.template Etc/hadoop/mapred-site
Modify Mapred-site.xml
Vim Etc/hadoop/mapred-site.xml
Also add in the Configuration tab
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
< Value>hadoop:10020</value>
<!--here, don't forget to modify-->
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>hadoop:19888</value>
<!--Here, don't forget to modify-->
</property>
Modify Yarn-site.xml, relative path
Vim Etc/hadoop/yarn-site.xml
Also add in the Configuration tab
<property> <name>yarn.nodemanager.aux-services</name> <value> mapreduce_shuffle</value> </property> <property> <name> Yarn.nodemanager.auxservices.mapreduce.shuffle.class</name> <value> org.apache.hadoop.mapred.shufflehandler</value> </property> <property> <name> Yarn.resourcemanager.address</name> <value>hadoop:8032