1. 程式人生 > >Centos7基本環境搭建

Centos7基本環境搭建

#!/bin/sh
#基本依賴庫(需要可以訪問網路)
sudo yum -y update
sudo yum -y install epel-release
sudo yum -y install gcc
sudo yum -y install gcc-c++
sudo yum -y install gdb
sudo yum -y install vim
sudo yum -y install git
sudo yum -y install gitk
sudo yum -y install valgrind
sudo yum -y install cmake
sudo yum -y install cmake3

sudo yum -y install glog-devel
sudo yum -y install hiredis-devel
sudo yum -y install opencv-devel
sudo yum -y install protobuf-devel

sudo yum -y install boost-devel
sudo yum -y install redis
sudo yum -y install libcurl-devel

sudo yum -y install leveldb-devel
sudo yum -y install snappy-devel
sudo yum -y install hdf5-devel
sudo yum -y install gflags-devel
sudo yum -y install lmdb-devel
sudo yum -y install openblas-devel
sudo yum -y install atlas-devel

sudo yum -y install libtool
sudo yum -y install pcre-devel

sudo yum -y install java-1.8.0-openjdk.x86_64
sudo yum -y install jsoncpp-devel
sudo yum -y install libjsoncpp-dev
sudo yum -y install zip

sudo yum -y install unzip

sudo yum -y install bash-completion

#檢視是否存在mariadb 命令: rpm -qa | grep -i mariadb
sudo rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
#mysql依賴perl
sudo yum -y install perl
#mysql server 依賴net-tools
sudo yum -y install net-tools

sudo yum -y install rapidjson-devel

chmod +x ./Runtime/install_32bit_compatibility_package_for_x64.sh
sudo ./Runtime/install_32bit_compatibility_package_for_x64.sh
sudo rpm -ivh ./Runtime/aksusbd-7.60-1.i386.rpm


#這樣下載可以保證最新的(需要修改指令碼中MySQL的版本號,舊版不需要),如果不要求最新可以直接copy自帶的code檔案中的,也不與需要安裝wget
#copy自帶的命令:
#cp ~/code/mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar ~/
#sudo yum -y install wget
#wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar

#!!!!!下面的安裝順序必須順序執行,有前後依賴關係
#安裝上面MySQL相關的依賴庫、工具及服務,
mkdir mysql
tar -xf ./code/mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar -C mysql
cd mysql/
sudo rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-devel-5.7.23-1.el7.x86_64.rpm
cd ../

#關閉防火牆
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
sudo systemctl mask firewalld.service

#資料庫目錄:/var/lib/mysql/
#命令配置:/usr/share/mysql  (mysql.server命令及配置檔案)
#相關命令:/usr/bin   (mysqladmin mysqldump等命令)
#啟動指令碼:/etc/rc.d/init.d/   (啟動指令碼檔案mysql的目錄)
#系統配置:/etc/my.conf

#將MySQL加入系統服務
sudo systemctl enable mysqld
sudo systemctl enable redis
#sudo systemctl daemon-reload
sudo systemctl start mysqld.service
sudo service mysqld stop
#這一步主要是修改mysql配置,比如密碼修改規則
sudo cp ./conf/my.cnf /etc/

exit(0)
#--------------------------------------------------------------------------------
#需要手動

#centos下資料庫root使用者的密碼在安裝時略過,給分配的為臨時密碼
#cat /var/log/mysqld.log 檢視mysqlroot的臨時密碼
#獲取root初始化密碼:grep 'temporary password' /var/log/mysqld.log

#改mysql資料庫密碼 set password = password('123456');