centos related

Centos Records

 

No IP address in the virtual machine

vi /etc/sysconfig/network-scripts/ifcfg-eth0        (centos7为ifcfg-ens33)

 

Modify: ONBOOT=yes

 

Install openjdk1.8

yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

 

wget: command not found

yum -y install wget

 

wget default directory

/root directory

 

install gcc

yum install gcc-c++

 

open port number

 永久:firewall-cmd --zone=public --add-port=21/tcp --permanent

 

Check if the port number is open

 firewall-cmd    --query-port=9200/tcp

Turn off the firewall (not applicable for centos7)

shutdown command:

 

service iptables stop

Permanently turn off the firewall:

 

chkconfig iptables off

Run the two commands at the same time, check the firewall shutdown status after running:

 

service iptables status

 

redis installation

wget http://download.redis.io/releases/redis-3.0.1.tar.gz

tar xzf redis-3.0.1.tar.gz

 cd redis-3.0.1

make

make install  

redis start

redis-server &

crtl + c exits the current command (without adding & will exit and close)

Centos7 closes the firewall

CentOS 7.0 uses firewall as the firewall by default, here is the iptables firewall step.

Turn off firewall:

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #Prohibit firewall from starting

firewall-cmd --state #View the default firewall status (notrunning is displayed when it is closed, and running is displayed when it is opened)

 

MySQL5.7 installation (can be any version)

1. Configure the YUM source

Download the YUM source rpm installation package on the MySQL official website: http://dev.mysql.com/downloads/repo/yum/ 

# Download the mysql source installation package
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# install mysql source
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm

Check if the mysql source is installed successfully

shell> yum repolist enabled | grep "mysql.*-community.*"

2. Install MySQL

shell> yum install mysql-community-server

3. Start the MySQL service

shell> systemctl start mysqld

Check the startup status of MySQL

shell> systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since  2016-06-24 04:37:37 CST; 35min ago
 Main PID: 2888 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─2888 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
 
6  24  04 :37 :36  localhost.localdomain  systemd[1]: Starting MySQL Server...
6  24  04 :37 :37  localhost.localdomain  systemd[1]: Started MySQL Server.

4. Start up

shell> systemctl enable mysqld
shell> systemctl daemon-reload

5. Modify the root local login password

After the mysql installation is complete, a default password is generated for root in the /var/log/mysqld.log file. Find the root default password in the following way, and then log in to mysql to modify it:

shell> grep 'temporary password' /var/log/mysqld.log

 

shell>  mysql -uroot  -p (password is the temporary password generated above)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'apple'; (先修改密码策略)

or

mysql> set password for 'root'@'localhost'=password('apple'); 

Note: The password security check plugin (validate_password) is installed by default in mysql5.7. The default password check policy requires that the password must contain: uppercase and lowercase letters, numbers and special symbols, and the length cannot be less than 8 characters. Otherwise, it will prompt ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown in the following figure: 

You can view information about password policies through the msyql environment variable:

mysql> show variables like '%password%';

 
validate_password_policy: password policy, the default is MEDIUM policy 
validate_password_dictionary_file: password policy file, the policy is STRONG only need 
validate_password_length: password minimum length 
validate_password_mixed_case_count: upper and lower case character length, at least 1 
validate_password_number_count: number at least 1 
validate_password_special_char_count: special character at least 1 
above parameters is the password checking rule for the default policy MEDIUM .

There are the following password policies:

Strategy

Check the rules

0 or LOW

Length

1 or MEDIUM

Length; numeric, lowercase/uppercase, and special characters

2 or STRONG

Length; numeric, lowercase/uppercase, and special characters; dictionary file

MySQL official website password policy detailed description: http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy

Modify password policy

Add the validate_password_policy configuration to the /etc/my.cnf file to specify the password policy

# Choose one of 0 (LOW), 1 (MEDIUM), 2 (STRONG), choose 2, you need to provide a password dictionary file
validate_password_policy=0

If you do not need a password policy, add the following configuration to the my.cnf file to disable it:

validate_password = off

Restart the mysql service for the configuration to take effect:

systemctl restart mysqld

6. Add remote login user

By default, only the root account is allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or add an account that allows remote connections. For security, I add a new account:

mysql> GRANT ALL PRIVILEGES ON *.* TO loger@'%' IDENTIFIED BY 'apple' WITH GRANT OPTION;

7. Configure the default encoding as utf8

Modify the /etc/my.cnf configuration file and add the encoding configuration under [mysqld], as follows:

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

Restart the mysql service and view the default encoding of the database as follows:

 


Default configuration file path: 
Configuration file: /etc/my.cnf 
Log file: /var/log//var/log/mysqld.log 
Service startup script: /usr/lib/systemd/system/mysqld.service 
socket file:/ var/run/mysqld/mysqld.pid

 

 

Linux view Tomcat log

1. Switch to: cd usr/local/tomcat5/logs

2、tail -f catalina.out

3. In this way, you can view the running log in real time when running

Ctrl+c is to exit the tail command.

 

 

install maven

yum install maven

 

 

install vsftpd

Step 1: Install vsftp

yum install -y vsftpd

 

Step 2: Set up the startup

systemctl enable vsftpd

 

Step 3: Start the ftp service

systemctl start vsftpd.service

 

Step 4: Open the firewall

 firewall-cmd --zone=public --add-port=21/tcp --permanent

 firewall-cmd --permanent --zone=public --add-service=ftp

 firewall-cmd --reload

(permanently add tcp 21 port)

(add ftp service)

(restart firewall)

Step 5: Add users

useradd -g root -d /home/data -s /sbin/nologin vsftpd

Add the new vsftpd user to the root group

But users are not allowed to log in, only ftp can be logged in

The default directory after ftp login is /home/data

 

Step 6: Set User Password

passwd vsftpd

Then follow the prompts to set the password

 

Step 7: Set permissions

chown -R vsftpd:root /home/data

setsebool -P ftpd_full_access on

 

Step 8: Modify the vsftp configuration file to prohibit anonymous login

vi /etc/vsftpd/vsftpd.conf

Change: anonymous_enable=YES to: anonymous_enable=NO

 

set virtual memory

SWAP is a virtual memory in Linux, which is used to store temporary data when the physical memory is insufficient. It is similar to virtual memory in Windows. In Windows, only files can be used as virtual memory. Linux can use files or partitions as virtual memory.

First check the current memory and swap space size (the default unit is k, the -m unit is M):

free -m


It can be seen here that the total memory is 503M, and SWAP does not exist.

View swap information, including file and partition details

# swapon -s

or

# cat /proc/swaps

If not, we need to manually add the swap partition. Note that the VPS of the OPENVZ architecture does not support manually adding a swap partition.

There are two options for adding swap space: adding a swap partition or adding a swap file. It is recommended that you add a swap partition; however, if you do not have much free space available, add a swap file.

1. Increase the swap file

1. Use the dd command to create a swap file

dd if=/dev/zero of=/home/swap bs=1024 count=1024000

This will create a /home/swap partition file with a size of 1G.

2. Make a file in swap format:

mkswap /home/swap

3. Use the swapon command to mount the file partition to the swap partition

/sbin/swapon /home/swap

Let's take a look with the free -m command and find that there is already a swap partition.

But after restarting the system, the swap partition becomes 0 again.

4. In order to prevent the swap partition from becoming 0 after restarting, modify the /etc/fstab file

vi /etc/fstab

At the end of the file (last line) add

/home/swap swap swap default 0 0

In this way, even if the system is restarted, the swap partition is still valuable.

delete swap file

1. Stop the swap partition first

/sbin/swapoff /home/swap

2. Delete the swap partition file

rm -rf /home/swap

3. Delete the automatic mount configuration command

vi /etc/fstab

delete this line

/home/swap swap swap default 0 0

This will delete the manually added swap file.
Note:
1. The operation of adding and deleting swap can only be performed by the root user.
2. It seems that the swap partition allocated when the system is installed cannot be deleted.
3. The swap partition is generally twice as large as the memory, but the maximum is not more than 2G

 

2. Use partitions for SWAP (virtual memory).
1. Use fdisk to create a swap partition (assuming /dev/sdb2 is the created swap partition)
2. Use the mkswap command to set up the swap partition:

# mkswap /dev/sdb2

3 Enable the swap partition:

# swapon / dev / sdb2

4 Write to /etc/fstab to enable at boot:

/dev/sdb2 swap swap defaults 0 0

Delete the swap partition The
steps are as follows:
1. Stop the swap partition first

/sbin/swapoff /dev/sdb2

2. Delete the automatic mount configuration command

vi /etc/fstab

delete this line

/dev/sdb2 swap swap defaults 0 0

This will delete the manually added swap partition.

 

 

 

 

Install JDK

First go to the official website to download the corresponding jdk package, transfer it to the server, and decompress it.

vi /etc/profile

Add the following

 

JAVA_HOME=/home/data/jdk1.8.0_161

PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME

export PATH

 

 

After saving the source profile

 

Create a new user and give the user directory permissions

[root@bogon ~]# useradd elastic

 

[root@bogon ~]# chown -R elastic:elastic /home/es/elasticsearch-5.5.2/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326106878&siteId=291194637