Centos 6.8編譯安裝LNMP環境

来源:http://www.cnblogs.com/bjx2020/archive/2017/12/18/8057253.html
-Advertisement-
Play Games

Centos 6.8編譯安裝LNMP環境 參考資料: http://www.jb51.net/article/107429.htm https://phperzh.com/articles/1360 一 準備工作 環境介紹: OS:Centos 6.8 最小化安裝 Nginx:nginx-1.12. ...


Centos 6.8編譯安裝LNMP環境

參考資料:

http://www.jb51.net/article/107429.htm

https://phperzh.com/articles/1360

準備工作

 

環境介紹:

 

OSCentos 6.8 最小化安裝

 

Nginxnginx-1.12.2.tar.gz

 

mysqlmysql-boost-5.7.20.tar.gz

 

phpphp-7.2.0.tar.bz2

 

1.1、關閉SELINUX

# 修改配置文件,重啟服務後永久生效。

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

# 命令行設置立即生效

setenforce 0

[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

[root@localhost ~]# setenforce 0

[root@localhost ~]# 

1.2、防火牆設置

 

cp /etc/sysconfig/iptables /root/iptables.bak
cat >/etc/sysconfig/iptables <<EOF 
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT DROP [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 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF
# 重啟
/etc/init.d/iptables  restart

 

1.3、修改主機名稱

hostname webserver
sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=webserver/g' /etc/sysconfig/network
sed -n '/HOSTNAME/p' /etc/sysconfig/network
[root@localhost ~]# hostname webserver
[root@localhost ~]# sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=webserver/g' /etc/sysconfig/network
[root@localhost ~]# sed -n '/HOSTNAME/p' /etc/sysconfig/network
HOSTNAME=webserver
[root@localhost ~]# 

1.4、修改網卡ip信息

cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=172.16.210.126
NETMASK=255.255.255.0
GATEWAY=172.16.210.250
EOF

#  重啟網卡服務
/etc/init.d/network restart

1.5、修改dns

#  修改dns
cat >/etc/resolv.conf <<EOF
nameserver 172.16.110.11
nameserver 8.8.8.8
EOF

[root@webserver ~]# cat >/etc/resolv.conf <<EOF
> nameserver 172.16.110.11
> nameserver 8.8.8.8
> EOF
[root@webserver ~]# 

1.6Centos最小化安裝推薦常用依賴包

#    Centos最小化安裝推薦常用依賴包
yum  clean all
yum -y update
yum -y install gcc-c++ gd libxml2-devel libjpeg-devel libpng-devel net-snmp-devel wget telnet   
yum -y install curl-devel libxslt-devel pcre-devel libjpeg libpng libcurl4-openssl-dev 
yum -y install libcurl-devel libcurl freetype-config freetype freetype-devel unixODBC libxslt 
yum -y install gcc automake autoconf libtool openssl-devel bison vim gcc-g77
yum -y install perl-devel perl-ExtUtils-Embed libcurl-devel.x86_64 zip unzip
yum -y install cmake ncurses-devel.x86_64  openldap-devel.x86_64 lrzsz  openssh-clients    
yum -y install libmcrypt libmcrypt-devel mhash mhash-devel bzip2 bzip2-devel
yum -y install ntpdate rsync svn  patch  iptables iptables-services
yum -y install libevent libevent-devel  cyrus-sasl cyrus-sasl-devel libcurl.x86_64
yum -y install gd-devel libmemcached-devel memcached git libssl-devel libyaml-devel auto make
yum -y install gcc.x86_64 libxml2.x86_64 libxml2-devel.x86_64 openssl.x86_64 openssl-devel.x86_64   
yum -y install gd.x86_64 gd-devel.x86_64  gcc-c++.x86_64 readline.x86_64 readline-devel.x86_64 
yum -y groupinstall "Server Platform Development" "Development tools"
yum -y groupinstall "Development tools" 

1.7、時間同步服務

cat >/root/ntp.sh <<EOF
#!/bin/bash
# ntp.sh
#NTP伺服器數組列表
ntpServer=(
[0]=1.cn.pool.ntp.org
[1]=2.cn.pool.ntp.org
[2]=3.cn.pool.ntp.org
[3]=0.cn.pool.ntp.org
)

#校驗#
serverNum=`echo \${#ntpServer[*]}`
NUM=0
for ((i=0; i<=\$serverNum; i++)); do
    echo -n "正在和NTP伺服器:\${ntpServer[\$NUM]}校驗中..."
    /usr/sbin/ntpdate \${ntpServer[\$NUM]} >> /dev/null 2>&1
    if [ \$? -eq 0 ]; then
        echo -e "\e[1;32m\t[成功]\e[0m"
        echo -e "\e[1;32m同步成功,退出......\e[0m"
        break
    else
        echo -e "\e[1;31m\t[失敗]\e[0m"
        echo -e "\e[1;31m繼續同步下一個!!!!!\e[0m"
        let NUM++
    fi
    sleep 2
done
EOF
chmod +x /root/ntp.sh
sh /root/ntp.sh

二、安裝Nginx

2.1、下載源碼包

# 上Nginx官網,複製最新穩定版的下載地址過來,然後用wget下載
cd /usr/local/src
wget https://nginx.org/download/nginx-1.12.2.tar.gz
[root@webserver ~]# cd /usr/local/src
[root@webserver src]# wget https://nginx.org/download/nginx-1.12.2.tar.gz

2.2、編譯安裝

 

tar xvf nginx-1.12.2.tar.gz
cd /usr/local/src/nginx-1.12.2
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/home/log/nginx/error.log \
--http-log-path=/home/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/home/tmp/nginx/client \
--http-proxy-temp-path=/home/tmp/nginx/proxy \
--http-fastcgi-temp-path=/home/tmp/nginx/fcgi \
--http-uwsgi-temp-path=/home/tmp/nginx/uwsgi \
--http-scgi-temp-path=/home/tmp/nginx/scgi \
--user=nginx \
--group=nginx \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module

 

#  完成後執行編譯:
#  make && make install
make -j `grep processor /proc/cpuinfo | wc -l` 
make -j `grep processor /proc/cpuinfo | wc -l`  install

2.3、創建相應的目錄

 

mkdir -p /home/tmp/nginx/client
mkdir -p /home/log/nginx
chmod 777 /home/tmp/
chmod 777 /home/log/
[root@webserver nginx-1.12.2]# mkdir -p /home/tmp/nginx/client
[root@webserver nginx-1.12.2]# mkdir -p /home/log/nginx
[root@webserver nginx-1.12.2]# chmod 777 /home/tmp/
[root@webserver nginx-1.12.2]# chmod 777 /home/log/

 

2.4、啟動nginx服務

 

cd /root/
useradd -s /sbin/nologin -M nginx
/usr/sbin/nginx
ps -ef|grep nginx
curl http://172.16.210.126

[root@webserver ~]# cd /root/
[root@webserver ~]# useradd -s /sbin/nologin -M nginx
[root@webserver ~]# /usr/sbin/nginx
[root@webserver ~]# ps -ef|grep nginx
root     19206     1  0 15:41 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx    19207 19206  0 15:41 ?        00:00:00 nginx: worker process
root     19209  1625  0 15:41 pts/0    00:00:00 grep nginx
[root@webserver ~]# 
[root@webserver ~]# curl http://172.16.210.126
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@webserver ~]# 

 

2.5、設置nginx快捷方式

 

alias nginx.start='/usr/sbin/nginx'
alias nginx.stop='/usr/sbin/nginx -s stop'
alias nginx.reload='/usr/sbin/nginx -s reload'
alias nginx.config_test='/usr/sbin/nginx -t'

cat >>/root/.bashrc <<EOF
alias nginx.start='/usr/sbin/nginx'
alias nginx.stop='/usr/sbin/nginx -s stop'
alias nginx.reload='/usr/sbin/nginx -s reload'
alias nginx.config_test='/usr/sbin/nginx -t'

EOF
cat /root/.bashrc
source  /root/.bash_profile 

[root@webserver ~]# alias nginx.start='/usr/sbin/nginx'
[root@webserver ~]# alias nginx.stop='/usr/sbin/nginx -s stop'
[root@webserver ~]# alias nginx.reload='/usr/sbin/nginx -s reload'
[root@webserver ~]# alias nginx.config_test='/usr/sbin/nginx -t'
[root@webserver ~]# cat /root/.bashrc 
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
alias nginx.start='/usr/sbin/nginx'
alias nginx.stop='/usr/sbin/nginx -s stop'
alias nginx.reload='/usr/sbin/nginx -s reload'
alias nginx.config_test='/usr/sbin/nginx -t'
[root@webserver ~]#
[root@webserver ~]# source  /root/.bash_profile 

 

二、安裝mysql

3.1、版本選擇

在安裝之前必須明白一件事情,mysql有很多種安裝方式,每種不一樣,不要弄混了。比如源碼編譯安裝和二進位安裝這裡我們用源碼自己編譯安裝。

3.2、資料庫存放目錄及許可權修改

 

mkdir -p /home/data/mysql
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin mysql
id mysql
# 更改數據目錄許可權。
chown -R mysql:mysql /home/data/mysql

[root@webserver ~]# mkdir -p /home/data/mysql
[root@webserver ~]# groupadd -r mysql
[root@webserver ~]# useradd -r -g mysql -s /sbin/nologin mysql
[root@webserver ~]# id mysql
uid=497(mysql) gid=497(mysql) groups=497(mysql)
[root@webserver ~]# chown -R mysql:mysql /home/data/mysql

 

3.3、下載解壓安裝

下載並解壓編譯官網下載的穩定版的源碼包。在下載的時候註意一下版本,下載對應的版本。我們源碼編譯,要下載長這樣的安裝包:同時在安裝的時候我們需要boost庫,5.7需要1.59版本的庫;你可以下載boost庫然後編譯boost,或者像我一樣,下載帶有boost庫的mysql版本,再開始解壓編譯。

 

################# 報錯處理說明開始################
## 報錯信息,原因是網路問題,導致無法下載boost_1_59_0.tar.gz,可以手工下載,
# 然後拷貝到對應的目錄下,重新解壓mysql,進入目錄編譯
#  -- Packaging as: mysql-5.7.20-Linux-x86_64
#  -- Downloading boost_1_59_0.tar.gz to /usr/local/mysql/boost/boost_1_59_0
#  -- Download failed, error: 22;"HTTP response code said error"
#  CMake Error at cmake/boost.cmake:194 (MESSAGE):
#    You can try downloading
#    http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
#    manually using curl/wget or a similar tool
#  Call Stack (most recent call first):
#    CMakeLists.txt:491 (INCLUDE)
#  [root@php1 ~]# wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
#  [root@php1 ~]# cp boost_1_59_0.tar.gz /usr/local/mysql/boost/boost_1_59_0/
#  [root@php1 ~]# ll /usr/local/mysql/boost/boost_1_59_0/
#  total 81756
#  drwx------ 8 mysql mysql     4096 Dec  8 10:04 boost_1_59_0
#  -rw-r--r-- 1 mysql mysql 83709983 Dec  8 10:04 boost_1_59_0.tar.gz
#  [root@php1 ~]# 
cd /usr/local/mysql/boost/boost_1_59_0/
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
# cp boost_1_59_0.tar.gz /usr/local/mysql/boost/boost_1_59_0 
cd /usr/local/src/
rm -rf mysql-5.7.20/
tar xvf mysql-boost-5.7.20.tar.gz -C /usr/local/src
cd /usr/local/src/mysql-5.7.20
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/home/data/mysql_3310  \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_TCP_PORT=3310 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld_3310.sock \
-DDEFAULT_CHARSET=utf8 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/mysql/boost/boost_1_59_0 

#  make && make install
make -j `grep processor /proc/cpuinfo | wc -l` &&
make -j `grep processor /proc/cpuinfo | wc -l`  install
#  參考資料: https://my.oschina.net/Kilar/blog/540856

################# 報錯處理說明結束################

 

cd /usr/local/src/
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.20.tar.gz
tar xvf mysql-boost-5.7.20.tar.gz -C /usr/local/src
cd /usr/local/src/mysql-5.7.20
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/home/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DMYSQL_TCP_PORT=3310 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld_3310.sock \
-DDEFAULT_CHARSET=utf8 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/mysql/boost/boost_1_59_0 

#  make && make install
make -j `grep processor /proc/cpuinfo | wc -l` 
make -j `grep processor /proc/cpuinfo | wc -l`  install
#  參考資料: https://my.oschina.net/Kilar/blog/540856

3.4、修改目錄許可權

 

chown -R mysql:mysql /usr/local/mysql/
[root@webserver mysql-5.7.20]# chown -R mysql:mysql /usr/local/mysql/

 

3.5、創建my.cnf配置文件

 

# 排除干擾因素
if [ -f "/etc/my.cnf" ]; then
    mv /etc/my.cnf /etc/my.cnf.bak
fi

cat > /usr/local/mysql/my_3310.cnf <<EOF
[client]
port = 3310
socket=/usr/local/mysql/mysqld_3310.sock
#character_set_server = utf8
#default-character-set = utf8mb4
#default-character-set = utf8

[mysqld]
basedir=/usr/local/mysql
datadir=/home/data/mysql_3310/
socket=/usr/local/mysql/mysqld_3310.sock
user = mysql
port = 3310

#character_set_server = utf8mb4
#init-connect = 'SET NAMES utf8'
character_set_server = utf8
init-connect = 'SET NAMES utf8'

#skip-name-resolve
#skip-networking
back_log = 512

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 1024
max_allowed_packet = 32M
binlog_cache_size = 32M
max_heap_table_size = 32M
tmp_table_size = 32M
 
read_buffer_size = 8M
read_rnd_buffer_size =32M
sort_buffer_size = 16M
join_buffer_size = 16M
key_buffer_size = 16M
 
thread_cache_size = 256
 
query_cache_type = 0
query_cache_size = 0
#query_cache_limit = 2M
 
server_id = 1503310
log-bin = /home/data/mysql_3310/mysql-bin
log_bin_index = /home/data/mysql_3310/binlog.index
binlog_format = row
expire_logs_days = 60

lower_case_table_names = 1
#binlog_ignore_db = mysql
#replicate-do-db = mysql
sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"

performance_schema = 0
explicit_defaults_for_timestamp=1

log_error = /home/data/mysql_3310/err_mysql_3310.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/data/mysql_3310/mysql-slow.log

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 1024
innodb_buffer_pool_size = 2G
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 60
innodb_lock_wait_timeout = 120
 
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
 
interactive_timeout = 28800
wait_timeout = 28800


[mysql.server]
character_set_server = utf8
socket=/usr/local/mysql/mysqld_3310.sock

[mysqld_safe]
log-error=/home/data/mysql_3310/err_mysql_3310.log
pid-file=/home/data/mysql_3310/mysql_3310.pid
character_set_server = utf8

[mysql]
socket=/usr/local/mysql/mysqld_3310.sock
default-character-set = utf8

[mysqldump]
socket=/usr/local/mysql/mysqld_3310.sock
default-character-set = utf8
[mysqladmin]
socket=/usr/local/mysql/mysqld_3310.sock
character_set_server = utf8" 
EOF

 

# 具體執行如下
[root@webserver mysql-5.7.20]# rm -rf /etc/my.cnf
[root@webserver mysql-5.7.20]# cat /usr/local/mysql/my_3310.cnf
[client]
port = 3310
socket=/usr/local/mysql/mysqld_3310.sock
#character_set_server = utf8
#default-character-set = utf8mb4
#default-character-set = utf8

[mysqld]
basedir=/usr/local/mysql
datadir=/home/data/mysql_3310/
socket=/usr/local/mysql/mysqld_3310.sock
user = mysql
port = 3310

#character_set_server = utf8mb4
#init-connect = 'SET NAMES utf8'
character_set_server = utf8
init-connect = 'SET NAMES utf8'

#skip-name-resolve
#skip-networking
back_log = 512

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 1024
max_allowed_packet = 32M
binlog_cache_size = 32M
max_heap_table_size = 32M
tmp_table_size = 32M
 
read_buffer_size = 8M
read_rnd_buffer_size =32M
sort_buffer_size = 16M
join_buffer_size = 16M
key_buffer_size = 16M
 
thread_cache_size = 256
 
query_cache_type = 0
query_cache_size = 0
#query_cache_limit = 2M
 
server_id = 1503310
log-bin = /home/data/mysql_3310/mysql-bin
log_bin_index = /home/data/mysql_3310/binlog.index
binlog_format = row
expire_logs_days = 60

lower_case_table_names = 1
#binlog_ignore_db = mysql
#replicate-do-db = mysql
sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"

performance_schema = 0
explicit_defaults_for_timestamp=1

log_error = /home/data/mysql_3310/err_mysql_3310.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/data/mysql_3310/mysql-slow.log

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 1024
innodb_buffer_pool_size = 2G
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 60
innodb_lock_wait_timeout = 120
 
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
 
interactive_timeout = 28800
wait_timeout = 28800


[mysql.server]
character_set_server = utf8
socket=/usr/local/mysql/mysqld_3310.sock

[mysqld_safe]
log-error=/home/data/mysql_3310/err_mysql_3310.log
pid-file=/home/data/mysql_3310/mysql_3310.pid
character_set_server = utf8

[mysql]
socket=/usr/local/mysql/mysqld_3310.sock
default-character-set = utf8

[mysqldump]
socket=/usr/local/mysql/mysqld_3310.sock
default-character-set = utf8
[mysqladmin]
socket=/usr/local/mysql/mysqld_3310.sock
character_set_server = utf8" 
[root@webserver mysql-5.7.20]# 

3.6、初始化資料庫

#需要註意這裡是mysql5.7的初始化命令,5.7以下的都是用:

#/usr/local/mysql/scripts/mysql_install_db user=mysql datadir=/home/data/mysql_3310/

#在初始化成功之後,5.7initial命令會產生一個隨機的root登錄密碼,你要用這個密碼登錄,

#然後修改(必須修改生成的隨機密碼不然無法後續操作)。在最後有一個類似這樣的密碼:root@localhost : QAEwfe@dvs!

 

# /usr/local/mysql/bin/mysqld –-initialize –user=mysql –-basedir=/usr/local/mysql –-datadir=/home/data/mysql_3310/
# /usr/local/mysql/bin/mysqld --initialize-insecure –-user=mysql –-basedir=/usr/local/mysql –-datadir=/home/data/mysql_3310/ --defaults-file=/usr/local/mysql/my_3310.cnf
/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my_3310.cnf --initialize-insecure &

[root@webserver mysql-5.7.20]# /usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my_3310.cnf --initialize-insecure &
[1] 4717
[root@webserver mysql-5.7.20]#

 

3.7、啟動資料庫

 

#  啟動資料庫
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my_3310.cnf &
ps -ef| grep -v 'grep' | grep mysql

[root@webserver mysql-5.7.20]# #  啟動資料庫
[root@webserver mysql-5.7.20]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my_3310.cnf &
[1] 4774
[root@webserver mysql-5.7.20]# ps -ef| grep -v 'grep' | grep mysql
root      4773  1665  0 17:31 pts/1    00:00:00 tail -f /home/data/mysql_3310/err_mysql_3310.log
root      4774  1625  0 17:32 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my_3310.cnf
[root@webserver mysql-5.7.20]# 
[root@webserver mysql-5.7.20]# 2017-12-15T09:33:00.906941Z mysqld_safe Logging to '/home/data/mysql_3310/err_mysql_3310.log'.
2017-12-15T09:33:00.966304Z mysqld_safe Starting mysqld daemon with databases from /home/data/mysql_3310

[root@webserver mysql-5.7.20]# ps -ef| grep -v 'grep' | grep mysql
root      4773  1665  0 17:31 pts/1    00:00:00 tail -f /home/data/mysql_3310/err_mysql_3310.log
root      4774  1625  0 17:32 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my_3310.cnf
mysql     5590  4774  2 17:33
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 安裝腳本setup.sh if ! test -d ./packages ; then 1.shell腳本編程中的if判斷配合test命令,判斷目錄是否存在 2.if判斷格式如,寫成一行 ,if test 條件;then 動作;else 動作;fi 3.判斷條件相等用-eq 或者 =,不相等 -ne ...
  • 有時候會出現烏班圖系統剛安裝,無法使用apt下載安裝軟體工具,此時需要修改apt下載源。 1、進入/etc/apt/目錄下 2、備份sources.list文件(如果不在root用戶下,需在前面加sudo許可權) cp sources.list sources.list.bak 3、清空sources ...
  • Linux系統目錄結構 目錄 描述 備註 /bin a.存放著最經常使用的命令 b.可執行文件,用戶命令 c.構建最小系統所需要的命令 /boot a.內核與啟動文件 b.系統啟動相關文件 c.啟動Linux時的一些核心文件 /dev a.各種設備文件 b.設備文件 c.Linux系統的外部設備 / ...
  • Linux 下查看日誌時,使用 可以不斷的刷新日誌信息。 例如: 此時要想暫停刷新,使用ctrl+s暫停終端。若想繼續終端,使用ctrl+q。 若想退出tail命令,直接使用ctrl+c。 ...
  • 在Linux中vim的三種模式分別為:命令模式、末行模式、編輯模式。以下是三者的關係圖: 三種模式的彼此切換: 命令模式是vim中的預設模式。 命令模式切換至末行模式: 使用英文冒號(:)。 末行模式切換至命令模式: 按一下esc 或者 兩下esc 或者 刪除末行的全部命令。 命令模式切換至編輯模式 ...
  • 一、Why Docker預設的鏡像和容器存儲位置在/var/lib/docker中,如果僅僅是做測試,我們可能沒有必要修改,但是當大量使用的時候,我們可能就要預設存儲的位置了。 二、How 2.1 修改docker.service文件 --graph=/data/docker:docker新的存儲位 ...
  • ls
    ls命令 命令英語原意:list 命令所在路徑:/bin/ls 執行許可權:所有用戶 功能描述:顯示目錄文件 語言:ls 選項 [-ald] [文件或目錄] -a 顯示所有路徑 drwxr-xr-x 2 root root 4096 2017-12 -18 reader.conf.d 文件類型:“d” ...
  • Nginx+Keeplived雙機熱備(主從模式) 參考資料: http://www.cnblogs.com/kevingrace/p/6138185.html 雙機高可用一般是通過虛擬IP(漂移IP)方法來實現的,基於Linux/Unix的IP別名技術。 雙機高可用方法目前分為兩種: 1.雙機主從 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...