The first definition corresponds to maximal tori and should be used; the second corresponds to maximal split tori.
The answer by ಠ_ಠ correctly states the definition of Cartan subalgebras for general Lie algebras: It is a subalgebra that is nilpotent and its own normaliser. In the case at hand, it is useful to introduce the following concepts:
Let $\mathfrak{g}$ be a semisimple Lie algebra over any field of characteristic 0. A subalgebra of $\mathfrak{g}$ is called toral if it is abelian and consists of semisimple elements. It is called split toral if it is abelian and consists of diagonalisable elements.
(Of course this is made to resemble tori and split tori in the group setting; I will just write "(split) torus" occasionally.)
Now one has:
Lemma: For $\mathfrak{g}$ as above, a subalgebra is maximal toral iff it is a Cartan subalgebra (= self-normalising & nilpotent).
(This is e.g. exercise 3 to ch. VII $\S$ 2 in Bourbaki's Lie Groups and Lie Algebras.)
As long as one works over algebraically closed fields, one rarely hears of toral and split toral subalgebras, since by algebraic closedness, toral is the same as split toral ("every torus is split"), so that by the lemma:
For a subalgebra of a semisimple Lie algebra over $\mathbb{C}$,
maximal toral = maximal split toral = Cartan subalgebra.
But over other fields, in our case $\mathbb{R}$, we have distinct notions of
- maximal toral subalgebras, and
- maximal split toral subalgebras.
By the lemma, 1. corresponds to the first (Knapp's) definition you give, and the generally accepted notion of Cartan subalgebras.
The second usage that you describe corresponds to 2. That is, what they call a Cartan subalgebra there is actually a maximal split toral subalgebra (in the group setting, it would be a maximal split torus, as opposed to a maximal torus). I have not seen this usage myself and would advise against it, since it does not match the general definition of Cartan subalgebra. Also, it would make the notion not invariant under scalar extension. Calling $\mathfrak{a}_0$ a maximal split torus is much better.
As to your last question, even in split Lie algebras, i.e. when there exists a split maximal torus [Beware the order of words: this is a maximal torus which happens to be split; not, as in notion 2, a maximal one among the split tori], the second usage would be more restrictive, since there can still be maximal tori which are not split.
-- Example: $\mathfrak{g_0} = \mathfrak{sl}_2(\mathbb{R}) = \lbrace \pmatrix{a & b \\
c &-a } : a,b,c \in \mathbb{R}\rbrace$. Then the second usage sees the split Cartan subalgebras (= one-dimensional subspaces) in $\mathfrak{p}_0 = \pmatrix{a & b \\
b &-a }$, but misses the non-split one that constitutes $\mathfrak{k}_0$, $\pmatrix{0 & b \\
-b &0 }$. --
If $\mathfrak{g}_0$ is not split, notion 2 does not even give a subset of notion 1, but they are disjoint: The ones in notion 2 have dimension strictly less than those in notion 1. And $\mathfrak{g}_0$ can still be far from compact. As an example, the following 8-dimensional real Lie algebra is a matrix representation of the quasi-split form of type $A_2$:
$\mathfrak{g}_0 = \lbrace
\begin{pmatrix}
a+bi & c+di & ei\\
f+gi & -2bi & -c+di\\
hi & -f+gi & -a+bi
\end{pmatrix} : a, ..., h \in \mathbb{R} \rbrace$; according to the nomenclature here, one might call this $\mathfrak{su}_{1,2}$.
One has $\mathfrak{k}_0 = \begin{pmatrix}
bi & -f+gi & hi\\
f+gi & -2bi & f+gi\\
hi & -f+gi & bi
\end{pmatrix}$ (i.e. $a=0, c=-f, g=d, h=e$) and
$\mathfrak{p}_0 = \begin{pmatrix}
a & c+di & ei\\
c-di & 0 & -c+di\\
-ei & -c-di & -a
\end{pmatrix}$ (i.e. $b=0, c=f, g =-d, h=-e$).
The maximal split tori $\mathfrak{a}_0$ in this case are the one-dimensional subspaces of $\mathfrak{p}_0$. But one can compute how each of them has a non-trivial centraliser in $\mathfrak{k}_0$ which has to be added to get a maximal torus = Cartan subalgebra in the generally accepted sense; the most obvious choice being
$\mathfrak{a}_0 = \begin{pmatrix}
a & 0 & 0\\
0 & 0 & 0\\
0 & 0 & -a
\end{pmatrix}$ which demands $\mathfrak{t}_0 = \begin{pmatrix}
bi & 0 & 0\\
0 & -2bi & 0\\
0 & 0 & bi
\end{pmatrix}$ as a complement, so that $\mathfrak{a}_0 \oplus \mathfrak{t}_0$ is a maximal torus and becomes the standard maximal split = split maximal torus in the complexification $\mathfrak{g}_{0}^\mathbb{C} \simeq \mathfrak{sl}_3(\mathbb{C})$.
No such ideal exists.
A simple Lie algebra $\mathfrak{g}$ over a field $k$ is called absolutely simple if for every algebraic extension $K\vert k$ (or equivalently: for an algebraic closure $K\vert k$) , the scalar extension $K\otimes \mathfrak{g}$ is also simple (note that it necessarily is semisimple; for an example where it is not simple, see below).
One can show that if a Lie algebra over a field $k$ is simple but not absolutely simple, it is the scalar restriction of an absolutely simple Lie algebra over some algebraic extension $K \vert k$. Actually, one can compute $K$ as the (associative) subalgebra of $End_k(\mathfrak{g})$ consisting of those elements that commute with all $ad_\mathfrak{g}(x), x \in \mathfrak{g}$. As far as I know, this was first shown by Jacobson in Duke Math. J., Volume 3, Number 3 (1937), 544-548, doi:10.1215/S0012-7094-37-00343-0, and holds for more general kinds of algebras. I wrote a little overview of that in section 4.1 of my thesis, a lot of it is now reproduced in this answer of mine.
Now to your question: Since scalar extension commutes with direct sums, and ideals of semisimple Lie algebras are direct summands, your question is equivalent to asking whether there exists a simple compact real Lie algebra $\mathfrak{g}$ which is not absolutely simple. But by the above theory, and the fact that the only proper algebraic extension of $\Bbb R$ is $\Bbb C$, the only simple but not absolutely simple real Lie algebras are: the simple complex Lie algebras considered as $\Bbb R$-algebras. The first example maybe being $\mathfrak{sl}_2(\Bbb C)$ viewed as a Lie algebra over $\Bbb R$ (six-dimensional); it is simple, but not absolutely simple, as its scalar extension $\Bbb C \otimes_{\Bbb R} \mathfrak{sl}_2(\Bbb C)$ actually is isomorphic to the sum of two copies of $\mathfrak{sl}_2(\Bbb C)$.
However, none of these scalar restrictions of simple complex Lie algebras correspond to compact Lie groups, e.g. because they obviously contain nilpotent elements.
Best Answer
I will focus on reductive Lie algebras $\mathfrak{g}$ of semisimple rank $\geq 1$ (so they're not abelian, for which the question is easy).
In that case, the set of semisimple element is dense in $\mathfrak{g}$, but is neither open, nor closed, nor locally closed in the Zariski topology.
Density is easy to see in $\mathfrak{sl}_n$, because any matrix whose characteristic polynomial has no multiple roots over $\bar{k}$ (such matrices form a non-empty open hence dense subset) is semisimple. In general, the same proof works, noting that the set of regular semisimple elements is a dense open subset of $\mathfrak{g}$.
The set of nilpotent elements $\mathcal{N}$ in $\mathfrak{g}$ is Zariski closed (this being defined by the vanishing of all polynomial invariants of the Lie algebra); in the case of $\mathfrak{sl}_n$ this is because nilpotency is defined by having characteristic polynomial coefficients equal to zero. If $\mathfrak{g}_s$ were open in $\mathfrak{g}$, the set of semisimple nilpotent elements $\mathfrak{g}_s\cap \mathcal{N}$ would be open in $\mathcal{N}$. However, the only element that is both nilpotent and semisimple is zero, and $\{0\}$ is not open in $\mathcal{N}$. (The last sentences uses the fact that the semisimple rank is $\geq 1$, so $\mathcal{N} \neq \{0\}$ because it contains for example regular nilpotent elements.)
It's now easy to see that $\mathfrak{g}_s$ can't be closed or even locally closed either. Indeed, if it would be, it would be open in its closure. But we showed that its closure is $\mathfrak{g}$ and we showed it's not open in $\mathfrak{g}$!
If you're looking for a positive result, the best thing I can think of is the following: let $G$ be a reductive group with Lie algebra $\mathfrak{g}$ and write $S = \mathfrak{g} // G$ for the space of invariant polynomials for the adjoint action of $G$ on $\mathfrak{g}$. Let $\pi \colon \mathfrak{g} \rightarrow \mathfrak{g} // G$ be the morphism of taking invariants. In the case of $G = SL_n$, $\mathfrak{g} // G$ is the space of monic polynomials with no $x^{n-1}$ term and $\pi$ is the morphism of sending a matrix to its characteristic polynomial. Then the theorem is (I think this is due to Kostant) that the intersection of $\mathfrak{g}_s$ with every fibre of $\pi$ is closed. (Taking the fibre above zero, you get the subvariety of nilpotent elements.) So somehow $\mathfrak{g}_s$ is well-behaved and closed in every fibre where you have fixed the invariants, but packaging all the fibres together gives a slightly weird set with bad topological properties.
If you want to read more about this, I highly recommend Kostant's papers 'Lie Group Representations on Polynomial Rings' and 'The Principal Three-Dimensional Subgroup and the Betti Numbers of a Complex Simple Lie Group'.