Install the CentOS7 vm using an ISO file

  • Configure static IP addresses. For details, see Configuring Static IP addresses for Mac VMware Fusion CentOS7.

  • Install vim

    [root @ localhost Java] # RPM - qa | grep vim vim - minimal - 7.4.629-6. El7. X86_64 / root @ localhost Java # yum - y install vim *...Copy the code

Install the JDK

  • useFileZillauploadjdkTo Linux/home/software
[root@localhost software]# mkdir /usr/java ... [root@localhost software]# mkdir /home/software ... [root@localhost software]# tar -zxvf jdk-8u231-linux-x64.tar.gz ... [root@localhost software]# mv jdk1.8.0_231 /usr/ Java /...Copy the code
  • Configure Java environment variables
  [root@localhost java]# vim /etc/profile
  ...
	#Add the following three at the bottomExport JAVA_HOME= /usr/jav/jdk1.8.0_231 export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin ... [root@localhost Java]# source /etc/profile [root@localhost Java]# Java -version Java version "1.8.0_231" Java(TM) SE Runtime Environment (Build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)Copy the code

Install Redis

  • Redis. IO /download Download a stable version

  • Use FileZilla to upload Redis to /home/software on Linux

  • Decompression package

    [root@localhost software]# tar -zxvf redis-5.0.7.tar.gz 
    Copy the code

    Because you need to compile and generate Redis, you need to install GCC

    [root@localhost software]# yum -y install gcc-c++ ... Gcc-c ++.x86_64 0:4.8.5-39.el7 installed as a dependency: Cpp.x86_64 0:4.8.5-39.el7 GCC. X86_64 0:4.8.5-39.el7 glibc-devel. X86_64 0:2.17-292.el7 glibc-headers X86_64 0:3.10.0-1062.9.1.el7 libmpc.x86_64 0:1.0.1-3.el7 libstdc++ -vel. X86_64 0:38.5-39.el7 mpfr.x86_64 0:31.1-4. el7 over!Copy the code

    Go to the decompression directory of Redis-5.0.7 and install:

    [root@localhost redis-5.0.7]# make && make install
    Copy the code
  • Configure Redis

    [root@localhost utils]# root root 593 11月 20 01:05 build-static-symbols. TCL -rw-rw-r-- Root 1303 11月 20 01:05 Cluster_fail_time. tcl-rw-rw-r --. 1 Root root 1098 11月 20 01:05 CORRUPt_rdb.c drWxrwxr-x. 2 root Root 60 November 20 01:05 create-cluster-rwxrwxr-x. 1 root root 2149 November 20 01:05 generate-command-help.rb drwxrwxr-x. 3 2 Root root 39 11月 20 01:05 hashtable drwxrwxr-x. 2 root root 70 11月 20 01:05 Hyperloglog -rwxrwxr-x. 1 Root root 9567 November 20 01:05 install_server.sh drwxrwxr-x Lru-rw-rw-r --. 1 root root 1277 11月 20 01:05 redis-copy.rb -rwxrwxr-x. 1 root root 1352 11月 20 01:05 redis_init_script 1 root root 1047 November 20 01:05 redis_init_script. TPL -rw-rw-r--. 1 root root 1762 November 20 01:05 redis-sha1.rb Drwxrwxr-x. 2 root root 135 11月 20 01:05 releasetools -rwxrwxr-x. 1 root root 3787 11月 20 01:05 speed-regression -rwxrwxr-x. 1 root root 693 November 20 01:05 whatisdoon.shCopy the code

    As shown above, in the utils directory, there is a redis_init_script file, which is copied to /etc/init.d/ in order to configure redis to boot automatically.

    [root@localhost utils]# cp redis_init_script  /etc/init.d/
    [root@localhost utils]# mkdir /usr/local/redis -p
    [root@localhost redis-5.0.7]# cp redis.conf /usr/local/redis/
    
    Copy the code

    Create the /usr/local/redis directory to store the redis configuration file.

  • Modify the Redis configuration file

    ################################# GENERAL #####################################
    
    #Change daemonize no to yes to start the Redis background process
    daemonize yes
    #Modify redis working path (data store location)
    dir /usr/local/redis/workingdb
    #Represents can be accessed remotely without IP restrictions
    #bind 127.0.0.1The bind 0.0.0.0#Change the password
    requirepass 12345678
    Copy the code
  • Modify the redis core configuration in the redis_init_script file and modify the file permissions

    REDISPORT=6379 EXEC=/usr/local/bin/redis-server CLIEXEC=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid  CONF="/usr/local/redis/redis.conf" [root@localhost init.d]# chmod 777 redis_init_script#Start the redis
    [root@localhost init.d]# ./redis_init_script start
    
    Copy the code
  • Set automatic startup upon startup

    1. in/etc/init.dAdd it to the startup script file in the path#chkconfig: 22345 10 90 &#description: Start and Stop redis
    [root@iZ2ze7s2v0b78922wia32rZ init.d]# vim redis_init_script 
    #! /bin/sh
    #
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
    
    ### BEGIN INIT INFO
    #Provides: redis_6379
    #Default-Start: 2 3 4 5
    #Default-Stop: 0 1 6
    #Short-Description: Redis data structure server
    #Description: Redis data structure server. See https://redis.io
    ### END INIT INFO
    
    #chkconfig: 22345 10 90
    #description: Start and Stop redisREDISPORT=6379 EXEC=/usr/local/bin/redis-server CLIEXEC=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid  CONF="/usr/local/redis/redis.conf"Copy the code
    1. Run chkconfig redis_init_script on to start the configuration.

    2. Close the redis

      [root@localhost redis]# /etc/init.d/redis_init_script stop
      Stopping ...
      (error) NOAUTH Authentication required.
      Waiting for Redis to shutdown ...
      Waiting for Redis to shutdown ...
      [root@localhost redis]# vim /etc/init.d/redis_init_script 
      #Password authentication also needs to be added to the script to turn off Redisstop) if [ !  -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -a "12345678" -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *)Copy the code
    3. After installation, remote connection fails because firewall is enabled on CentOS7 by default

      #Stopping the Firewall
      [root@localhost ~]# systemctl stop firewalld.service
      #Do not enable the firewall upon startup
      [root@localhost ~]# systemctl disable firewalld.service
      Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
      Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
      
      Copy the code

      Or run the following command to open port 6379

      firewall-cmd --zone=public --add-port=6379/tcp --permanent
      Copy the code

Clone a full VM

  • Directly right-click on the machine that you want to clone in VM Ware Fusion and select Create Full Clone

    • CentOS 7. Change the Ip address directly

      Vim /etc/sysconfig/network-scripts/ifcfg-ens33Copy the code
    • CentOS 6 or some versions need to change the MAC address and IP address

      Rules vim /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33 Restart Resetting the networkCopy the code

Mac configuration environment variables fail

You configure environment variables in ~/.bash_profile, but the Settings do not take effect after each terminal restart. You need to run $source ~/.bash_profile again

ZSH loads the ~/.zshrc file, and the ‘.zshrc ‘file does not define the task environment variables.

The solution

At the end of the ~/.zshrc file, add the line source ~/.bash_profile

Run | blog garden of life